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 TrajectoryGenerator1D.h |
---|
7 | * \brief Class generating a trajectory in 1D |
---|
8 | * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253 |
---|
9 | * \date 2011/05/01 |
---|
10 | * \version 4.0 |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef TRAJECTORYGENERATOR1D_H |
---|
14 | #define TRAJECTORYGENERATOR1D_H |
---|
15 | |
---|
16 | #include <IODevice.h> |
---|
17 | |
---|
18 | namespace flair { |
---|
19 | namespace core { |
---|
20 | class Matrix; |
---|
21 | } |
---|
22 | namespace gui { |
---|
23 | class LayoutPosition; |
---|
24 | } |
---|
25 | } |
---|
26 | |
---|
27 | class TrajectoryGenerator1D_impl; |
---|
28 | |
---|
29 | namespace flair { |
---|
30 | namespace filter { |
---|
31 | /*! \class TrajectoryGenerator1D |
---|
32 | * |
---|
33 | * \brief Class generating a trajectory in 1D |
---|
34 | * |
---|
35 | * This class generates position and velocity references, given |
---|
36 | * an absolute maximum velocity and an absolute acceleration. \n |
---|
37 | * When trajectory is started (see StartTraj()), position and velocity will |
---|
38 | *increase |
---|
39 | * at the given acceleration. If the maximum velocity is reached, |
---|
40 | * velocity will not increase anymore. Then, velocity will decrease according |
---|
41 | * to the given acceleration until velocity is null and final position is |
---|
42 | *reached. \n |
---|
43 | * Manual inputs can be introduced using SetPositionOffset() and |
---|
44 | *SetSpeedOffset(). |
---|
45 | * |
---|
46 | */ |
---|
47 | class TrajectoryGenerator1D : public core::IODevice { |
---|
48 | public: |
---|
49 | /*! |
---|
50 | * \brief Constructor |
---|
51 | * |
---|
52 | * Construct a TrajectoryGenerator1D at given position. \n |
---|
53 | * The TrajectoryGenerator1D will automatically be child of |
---|
54 | *position->getLayout() Layout. After calling this function, |
---|
55 | * position will be deleted as it is no longer usefull. \n |
---|
56 | * |
---|
57 | * \param position position to display settings |
---|
58 | * \param name name |
---|
59 | * \param unit unit of the position (for exemple m, deg, etc). Its only used |
---|
60 | *for display on ground station. |
---|
61 | */ |
---|
62 | TrajectoryGenerator1D(const gui::LayoutPosition *position, std::string name, |
---|
63 | std::string unit = ""); |
---|
64 | |
---|
65 | /*! |
---|
66 | * \brief Destructor |
---|
67 | * |
---|
68 | */ |
---|
69 | ~TrajectoryGenerator1D(); |
---|
70 | |
---|
71 | /*! |
---|
72 | * \brief Start trajectory |
---|
73 | * |
---|
74 | * \param startPosition start position |
---|
75 | * \param endPosition end position |
---|
76 | * \param startVelocity start velocity, should be actual velocity. This value will be saturated |
---|
77 | * max velocity defined in GCS. |
---|
78 | */ |
---|
79 | void StartTraj(float startPosition, float endPosition,float startVelocity=0); |
---|
80 | |
---|
81 | /*! |
---|
82 | * \brief Stop trajectory |
---|
83 | * |
---|
84 | */ |
---|
85 | void StopTraj(void); |
---|
86 | |
---|
87 | /*! |
---|
88 | * \brief Reset |
---|
89 | * |
---|
90 | * Reset all outputs to 0. This can be done only when IsRunning()==false. |
---|
91 | * |
---|
92 | */ |
---|
93 | void Reset(void); |
---|
94 | |
---|
95 | /*! |
---|
96 | * \brief Is trajectory running? |
---|
97 | * |
---|
98 | * \return true if trajectory is running |
---|
99 | */ |
---|
100 | bool IsRunning(void) const; |
---|
101 | |
---|
102 | /*! |
---|
103 | * \brief Set position offset |
---|
104 | * |
---|
105 | * \param value position offset |
---|
106 | */ |
---|
107 | void SetPositionOffset(float value); |
---|
108 | |
---|
109 | /*! |
---|
110 | * \brief Set speed offset |
---|
111 | * |
---|
112 | * \param value speed offset |
---|
113 | */ |
---|
114 | void SetSpeedOffset(float value); |
---|
115 | |
---|
116 | /*! |
---|
117 | * \brief Update using provided datas |
---|
118 | * |
---|
119 | * Uses values specified by StartTraj(), |
---|
120 | * SetPositionOffset() and SetSpeedOffset(). |
---|
121 | * |
---|
122 | * \param time time of the update |
---|
123 | */ |
---|
124 | void Update(core::Time time); |
---|
125 | |
---|
126 | /*! |
---|
127 | * \brief Position |
---|
128 | * |
---|
129 | * \return the actual position |
---|
130 | */ |
---|
131 | float Position(void) const; |
---|
132 | |
---|
133 | /*! |
---|
134 | * \brief Speed |
---|
135 | * |
---|
136 | * \return the actual speed |
---|
137 | */ |
---|
138 | float Speed(void) const; |
---|
139 | |
---|
140 | /*! |
---|
141 | * \brief Get percentage of completion |
---|
142 | * |
---|
143 | * Value is between 0 and 100. |
---|
144 | * |
---|
145 | * \return the percentage of completion (in position) |
---|
146 | */ |
---|
147 | float GetPercentageOfCompletion(void) const; |
---|
148 | |
---|
149 | /*! |
---|
150 | * \brief Output matrix |
---|
151 | * |
---|
152 | * \return matrix |
---|
153 | */ |
---|
154 | core::Matrix *GetMatrix(void) const; |
---|
155 | |
---|
156 | private: |
---|
157 | /*! |
---|
158 | * \brief Update using provided datas |
---|
159 | * |
---|
160 | * Reimplemented from IODevice. Nothing to do in this IODevice. |
---|
161 | * |
---|
162 | * \param data data from the parent to process |
---|
163 | */ |
---|
164 | void UpdateFrom(const core::io_data *data){}; |
---|
165 | |
---|
166 | TrajectoryGenerator1D_impl *pimpl_; |
---|
167 | }; |
---|
168 | } // end namespace filter |
---|
169 | } // end namespace flair |
---|
170 | #endif // TRAJECTORYGENERATOR1D_H |
---|