[10] | 1 | // %flair:license{
|
---|
[15] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[10] | 4 | // %flair:license}
|
---|
[7] | 5 | /*!
|
---|
| 6 | * \file TrajectoryGenerator2DCircle.h
|
---|
| 7 | * \brief Class generating a circle trajectory in 2D
|
---|
| 8 | * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 9 | * \date 2013/04/08
|
---|
| 10 | * \version 4.0
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 | #ifndef TRAJECTORYGENERATOR2DCIRCLE_H
|
---|
| 14 | #define TRAJECTORYGENERATOR2DCIRCLE_H
|
---|
| 15 |
|
---|
| 16 | #include <IODevice.h>
|
---|
| 17 |
|
---|
[15] | 18 | namespace flair {
|
---|
| 19 | namespace core {
|
---|
| 20 | class cvmatrix;
|
---|
| 21 | class Vector2D;
|
---|
[7] | 22 | }
|
---|
[15] | 23 | namespace gui {
|
---|
| 24 | class LayoutPosition;
|
---|
| 25 | }
|
---|
| 26 | }
|
---|
[7] | 27 |
|
---|
| 28 | class TrajectoryGenerator2DCircle_impl;
|
---|
| 29 |
|
---|
[15] | 30 | namespace flair {
|
---|
| 31 | namespace filter {
|
---|
| 32 | /*! \class TrajectoryGenerator2DCircle
|
---|
| 33 | *
|
---|
| 34 | * \brief Class generating a circle trajectory in 2D
|
---|
| 35 | *
|
---|
| 36 | * This class generates position and velocity references, given
|
---|
| 37 | * a maximum velocity and an absolute acceleration, for a circle. \n
|
---|
| 38 | * When trajectory is started (StartTraj), position and velocity will increase
|
---|
| 39 | * at the given acceleration untill maximum velocity is reached. \n
|
---|
| 40 | * When trajectory is asked to be finished (see FinishTraj()), position
|
---|
| 41 | * and velocity will decrease at the given acceleration untill null velocity is
|
---|
| 42 | *reached. \n
|
---|
| 43 | * Position and velocity of the center of the circle can be manually changed
|
---|
| 44 | * through SetCenter() and SetCenterSpeed().
|
---|
| 45 | */
|
---|
| 46 | class TrajectoryGenerator2DCircle : public core::IODevice {
|
---|
| 47 | public:
|
---|
| 48 | /*!
|
---|
| 49 | * \brief Constructor
|
---|
| 50 | *
|
---|
| 51 | * Construct a TrajectoryGenerator2DCircle at position. \n
|
---|
| 52 | * The TrajectoryGenerator2DCircle will automatically be child of
|
---|
| 53 | *position->getLayout() Layout. After calling this function,
|
---|
| 54 | * position will be deleted as it is no longer usefull. \n
|
---|
| 55 | *
|
---|
| 56 | * \param position position to display settings
|
---|
| 57 | * \param name name
|
---|
| 58 | */
|
---|
| 59 | TrajectoryGenerator2DCircle(const gui::LayoutPosition *position,
|
---|
| 60 | std::string name);
|
---|
[7] | 61 |
|
---|
[15] | 62 | /*!
|
---|
| 63 | * \brief Destructor
|
---|
| 64 | *
|
---|
| 65 | */
|
---|
| 66 | ~TrajectoryGenerator2DCircle();
|
---|
[7] | 67 |
|
---|
[15] | 68 | /*!
|
---|
| 69 | * \brief Start trajectory
|
---|
| 70 | *
|
---|
| 71 | * \param start_pos start position
|
---|
| 72 | * \param nb_lap number of laps, -1 for infinite
|
---|
| 73 | */
|
---|
| 74 | void StartTraj(const core::Vector2D &start_pos, float nb_lap = -1);
|
---|
[7] | 75 |
|
---|
[15] | 76 | /*!
|
---|
| 77 | * \brief Stop trajectory
|
---|
| 78 | *
|
---|
| 79 | * Stop abruptly the trajectory.
|
---|
| 80 | */
|
---|
| 81 | void StopTraj(void);
|
---|
[7] | 82 |
|
---|
[15] | 83 | /*!
|
---|
| 84 | * \brief Finish trajectory
|
---|
| 85 | *
|
---|
| 86 | * Finish smoothly the trajectory.
|
---|
| 87 | */
|
---|
| 88 | void FinishTraj(void);
|
---|
[7] | 89 |
|
---|
[15] | 90 | /*!
|
---|
| 91 | * \brief Set center position
|
---|
| 92 | *
|
---|
| 93 | * \param value center position
|
---|
| 94 | */
|
---|
| 95 | void SetCenter(const core::Vector2D &value);
|
---|
[7] | 96 |
|
---|
[15] | 97 | /*!
|
---|
| 98 | * \brief Set center speed
|
---|
| 99 | *
|
---|
| 100 | * \param value center speed
|
---|
| 101 | */
|
---|
| 102 | void SetCenterSpeed(const core::Vector2D &value);
|
---|
[7] | 103 |
|
---|
[15] | 104 | /*!
|
---|
| 105 | * \brief Update using provided datas
|
---|
| 106 | *
|
---|
| 107 | * Uses values specified by StartTraj(),
|
---|
| 108 | * SetCenter() and SetCenterSpeed().
|
---|
| 109 | *
|
---|
| 110 | * \param time time of the update
|
---|
| 111 | */
|
---|
| 112 | void Update(core::Time time);
|
---|
[7] | 113 |
|
---|
[15] | 114 | /*!
|
---|
| 115 | * \brief Position
|
---|
| 116 | *
|
---|
| 117 | * \param point returned position
|
---|
| 118 | */
|
---|
| 119 | void GetPosition(core::Vector2D &point) const;
|
---|
[7] | 120 |
|
---|
[15] | 121 | /*!
|
---|
| 122 | * \brief Speed
|
---|
| 123 | *
|
---|
| 124 | * \param point returned speed
|
---|
| 125 | */
|
---|
| 126 | void GetSpeed(core::Vector2D &point) const;
|
---|
[7] | 127 |
|
---|
[15] | 128 | /*!
|
---|
| 129 | * \brief Output matrix
|
---|
| 130 | *
|
---|
| 131 | * \return matrix
|
---|
| 132 | */
|
---|
| 133 | core::cvmatrix *Matrix(void) const;
|
---|
[7] | 134 |
|
---|
[15] | 135 | /*!
|
---|
| 136 | * \brief Is trajectory running?
|
---|
| 137 | *
|
---|
| 138 | * \return true if trajectory is running
|
---|
| 139 | */
|
---|
| 140 | bool IsRunning(void) const;
|
---|
[7] | 141 |
|
---|
[15] | 142 | private:
|
---|
| 143 | /*!
|
---|
| 144 | * \brief Update using provided datas
|
---|
| 145 | *
|
---|
| 146 | * Reimplemented from IODevice. Nothing to do in this IODevice.
|
---|
| 147 | *
|
---|
| 148 | * \param data data from the parent to process
|
---|
| 149 | */
|
---|
| 150 | void UpdateFrom(const core::io_data *data){};
|
---|
[7] | 151 |
|
---|
[15] | 152 | TrajectoryGenerator2DCircle_impl *pimpl_;
|
---|
| 153 | };
|
---|
[7] | 154 | } // end namespace filter
|
---|
| 155 | } // end namespace flair
|
---|
| 156 | #endif // TRAJECTORYGENERATOR2DCIRCLE_H
|
---|