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