TrajectoryController.h
Go to the documentation of this file.
1#ifndef TRAJECTORYCONTROLLER_H
2#define TRAJECTORYCONTROLLER_H
6
7namespace armarx
8{
9 /**
10 * @class TrajectoryController
11 * @brief Subcontroller which handles all program interaction with the modle,
12 * communicates with other controllers via signals and slots
13 */
15 {
16 Q_OBJECT
17
18 public:
19 /**
20 * @brief @see AbstractController
21 */
22 void onInitComponent() override;
23
24 /**
25 * @brief @see AbstractController
26 */
27 void onConnectComponent() override;
28
29 /**
30 * @brief @see AbstractController
31 */
32 void onDisconnectComponent() override;
33
34 /**
35 * @brief @see AbstractController
36 */
37 void onExitComponent() override;
38
39 /**
40 * @brief Creates a new TrajectoryController and assigns a QWidget to handle
41 */
43
44 public slots:
45 /**
46 * @brief Updates the selected TCP
47 * @param index Index of the selected TCP
48 */
49 void updateTCP(QString tcp);
50
51 /**
52 * @brief Updates all values of a given transition
53 * @param transition Index of the transition
54 * @param it Index of the interpolation of the transition
55 */
56 void updateTransition(int transition, int it);
57
58 /**
59 * @brief Updates all values of a given transition
60 * @param transition Index of the transition
61 * @param duration Duration of the transition
62 */
63 void updateTransition(int transition, double duration);
64
65 /**
66 * @brief Updates all values of a given waypoint
67 * @param waypoint Index of the waypoint
68 * @param values Array containing the x, y, z, coordinates of a waypoint as well as the
69 * r, p, y euler angles
70 */
71 void updateWaypoint(int waypoint, std::vector<double> values);
72
73
74 /**
75 * @brief Updates all values of a given waypoint
76 * @param waypoint Index of the waypoint
77 */
78 void updateWaypoint(int waypoint);
79
80 /**
81 * @brief Updates all values of a given waypoint
82 * @param waypoint Index of the waypoint
83 * @param newPoseBase Is the new PoseBase of the waypoint
84 */
85 void updateWaypoint(int waypoint, PoseBasePtr newPoseBase);
86
87 /**
88 * @brief Updates CartesianSelection value of a given waypoint
89 * @param waypoint Index of the waypoint
90 * @param cartesianSelection Integer representing the cartesian selection
91 * or before
92 */
93 void updateWaypoint(int waypoint, int cartesianSelection);
94
95 /**
96 * @brief Updates isBreakpoint value of a given waypoint
97 * @param waypoint Index of the waypoint
98 * @param isBreakpoint Boolean determining whether the waypoint is a breakpoint
99 */
100 void updateWaypoint(int waypoint, bool isBreakpoint);
101
102 /**
103 * @brief Adds a new waypoint relative to the given waypoint
104 * @param constraints Constraints of the new waypoint: isBreakpoint, ikConstraints,
105 * insertBefore/-After
106 * @param waypoint Index of the waypoint
107 * @param cartesianSelection Integer representing the cartesian selection
108 * @param insertAfter Boolean determining whether to insert after the waypoint
109 * or before
110 * @param isBreakpoint Boolean determining whether the waypoint is a breakpoint
111 */
112 void addWaypoint(int waypoint, bool insertAfter);
113
114 /**
115 * @brief Deletes the given waypoint
116 * @param waypoint Index of the waypoint
117 */
118 void deleteWaypoint(int waypoint);
119
120 /**
121 * @brief Imports a given trajectory into the model
122 * @param designerTrajectory Trajectory which is being imported
123 */
124 void import(DesignerTrajectoryPtr designerTrajectory);
125 /*
126 * Changed signature because 'export' is a keyword and thus cannot be user
127 * as method name
128 */
129 /**
130 * @brief Stages the given trajectory for export
131 * @param fps for export to MMM
132 */
133 void exportTrajectory(int fps);
134
135 /**
136 * @brief Stages the given trajectory for export
137 */
138 void exportTrajectory();
139
140 /**
141 * @brief Undo trajectroy
142 */
143 void undo();
144
145 /**
146 * @brief Redo trajectory
147 */
148 void redo();
149
150 /**
151 * @brief Play all trajectories
152 */
153 void playTrajectories();
154
155 /**
156 * @brief Set the enviroment
157 * @param The new enviroment
158 */
159 void environmentChanged(EnvironmentPtr environment);
160
161 /**
162 * @brief Sets the active collision model name
163 * @param activeColModelName Active collision model name
164 */
165 void setActiveColModelName(QString activeColModelName);
166
167 /**
168 * @brief Sets the body collision models names
169 * @param activeColModelName Body collision models names
170 */
171 void setBodyColModelsNames(QStringList bodyColModelsNames);
172
173 signals:
174 /**
175 * @brief Notfies other controllers about changes of an existing waypoint
176 * @param values Array containting x, y, z, coordinates as well as a, b, g
177 * euler angles of the waypoint
178 * @param constraints Constraints of the waypoint: isBreakpoint, ikConstraints
179 * @param waypoint Index of the waypoint
180 */
182 std::vector<double> values,
183 int cartesianSelection,
184 bool isBreakpoint);
185
186 /**
187 * @brief Notifies other controllers about changes of an existing transition
188 * @param duration Duration of the transition
189 * @param start Start time of the transition
190 * @param it Index of interpolation of the transition
191 * @param transition Index of the transition
192 */
193 void changeTransitionGui(int transition, double duration, double start, int it);
194
195 /**
196 * @brief Notifies other controllers about the addition of a waypoint
197 * @param values Array containting x, y, z, coordinates as well as r, p, y
198 * euler angles of the waypoint
199 * @param constraints Constraints of the waypoint: isBreakpoint, ikConstraints
200 * @param waypoint Index of the waypoint
201 */
202 void addWaypointGui(int waypoint,
203 std::vector<double> values,
204 int cartesianSelection,
205 bool isBreakpoint);
206
207 /**
208 * @brief Notifies other controllers about the deletion of a given waypoint
209 * @param index Index of the waypoitn
210 */
212
213 /**
214 * @brief Notifies other controllers about the addition of a transition
215 * @param duration Duration of the transition
216 * @param start Start time of the transition
217 * @param it Index of the interpolation of the transition
218 * @param transition Index of the transition
219 */
220 void addTransitionGui(int transition, double duration, double start, int it);
221
222 /**
223 * @brief Notifies other controllers about the deletion of a given transtion
224 * @param index Index of the transition
225 */
227
228 /**
229 * @brief Notifies WaypointTab and Transition to delete all ListWidgets
230 */
232
233 /**
234 * @brief Notifies the VisualizationController about a changed RobotNodeSet
235 * @param rns new RobotNodeSet
236 */
237 void rnsChanged(VirtualRobot::RobotNodeSetPtr rns);
238
239 /**
240 * @brief Notifies the TCPSelcetionController about a new Trajectory
241 * @param trajectory new trajectory
242 */
244
245 /**
246 * @brief Removes the given trajectory from the TCP selection combo box
247 * @param trajectory String identifier of the trajectory
248 */
250
251 /**
252 * @brief Removes all trajectories from the TCP selection combo box
253 */
255
256 /**
257 * @brief Updates the currently displayed trajectory of the corresponding TCP
258 * @param trajectory String identifier of the trajectory
259 */
261
262 /**
263 * @brief Provides the trajectory for VisualizationController
264 * @param designerTrajectory Trajectory to provide
265 */
266 void showTrajectory(DesignerTrajectoryPtr designerTrajectory);
267
268 /**
269 * @brief Provides all trajectories for VisualizationController
270 * @param designerTrajectories Trajectories to play
271 */
272 void playTrajectories(std::vector<DesignerTrajectoryPtr> designerTrajectories);
273
274 /**
275 * @brief Provides the trajectory for ExportController
276 * @param trajectory Trajectory to provide
277 */
278 void exportTrajectory(std::vector<DesignerTrajectoryPtr> trajectories);
279
280 /**
281 * @brief cartesianSelectionChanged recalculates the configuration of the robot joints to fit the new selection
282 * @param cs the new CartesianSelection
283 */
284
285 void cartesianSelectionChanged(VirtualRobot::IKSolver::CartesianSelection cs);
286 /**
287 * @brief Enables or disables the redo button/shortcut
288 * @param enable Determines whether to enable or disable the redo button/shortcut
289 */
290 void enableRedo(bool enable);
291
292 /**
293 * @brief Enables or disables the undo button/shortcut
294 * @param enable Determines whether to enable or disable the undo button/shortcut
295 */
296 void enableUndo(bool enable);
297
298 /**
299 * @brief Enables or disables the new IK solution button
300 * @param enable Determines whether to enable or disable the ik solution button
301 */
302 void enableIKSolutionButton(bool enable);
303
304 /**
305 * @brief Enables or disables the export buttons
306 * @param enable Determines whether to enable or disable the export buttons
307 */
308 void enableExportButtons(bool enable);
309
310 /**
311 * @brief Enables or disables the delete and change button/shortcut
312 * @param enable Determines whether to enable or disable the delete and change button/shortcut
313 */
314 void enableDeleteChange(bool enable);
315
316 /**
317 * @brief Enables or disables the add button/shortcut
318 * @param enable Determines whether to enable or disable the add button/shortcut
319 */
320 void enableAdd(bool enable);
321
322 /**
323 * @brief Enables or disables the prview button/shortcut
324 * @param enable Determines whether to enable or disable the previes button/shortcut
325 */
326 void enablePreview(bool enable);
327
328 /**
329 * @brief Enables or disables the prview all button/shortcut
330 * @param enable Determines whether to enable or disable the previes button/shortcut
331 */
332 void enablePreviewAll(bool enable);
333
334 private:
335 /**
336 * @brief Converts a PoseBase to x, y, z coordinates and r, p, y euler angles
337 * @param pose PoseBase to convert
338 * @return Vector containing the resulting coordinates and angles
339 */
340 std::vector<double> parseToCoordinate(PoseBasePtr pose);
341
342 PoseBasePtr parseToPoseBasePtr(std::vector<double> values);
343
344 void helpAddWaypointGui(UserWaypointPtr waypoint, int waypointIndex);
345 void helpAddTransitionGui(TransitionPtr transition, int transitionIndex);
346 void addTransitionWaypointGui(DesignerTrajectoryPtr trajectory);
347
348 void helpChangeTransitionGui(TransitionPtr transition, int transitionIndex);
349 void helpChangeWaypointGui(UserWaypointPtr waypoint, int waypointIndex);
350 void changeTransitionWaypointGui(DesignerTrajectoryPtr trajectory);
351
352 void helpImportDesignerTrajectory(DesignerTrajectoryPtr designerTrajectory);
353
354 void helpCreateDesignerTrajectoryManager();
355
356 bool helpEnableExportPreviewAll();
357 void helpEnableUndoRedo();
358 void helpEnableButtons();
359
360 void helpExceptionMessageBox(std::string errorMessage);
361
362 void helpCollision();
363
366 VirtualRobot::RobotNodeSetPtr rns;
367 EnvironmentPtr environment;
368 std::string activeColModelName;
369 std::vector<std::string> bodyColModelsNames;
370 };
371
372 using TrajectoryControllerPtr = std::shared_ptr<TrajectoryController>;
373} // namespace armarx
374
375#endif // TRAJECTORYCONTROLLER_H
uint8_t index
Abstract controller providing a set of methods which must be implemented by every controller.
Subcontroller which handles all program interaction with the modle, communicates with other controlle...
void removeTransitionWaypointGui()
Notifies WaypointTab and Transition to delete all ListWidgets.
void environmentChanged(EnvironmentPtr environment)
Set the enviroment.
void setActiveColModelName(QString activeColModelName)
Sets the active collision model name.
void enableIKSolutionButton(bool enable)
Enables or disables the new IK solution button.
void deleteWaypoint(int waypoint)
Deletes the given waypoint.
TrajectoryController()
Creates a new TrajectoryController and assigns a QWidget to handle.
void updateTransition(int transition, int it)
Updates all values of a given transition.
void enableAdd(bool enable)
Enables or disables the add button/shortcut.
void enablePreviewAll(bool enable)
Enables or disables the prview all button/shortcut.
void addWaypointGui(int waypoint, std::vector< double > values, int cartesianSelection, bool isBreakpoint)
Notifies other controllers about the addition of a waypoint.
void cartesianSelectionChanged(VirtualRobot::IKSolver::CartesianSelection cs)
cartesianSelectionChanged recalculates the configuration of the robot joints to fit the new selection
void updateTCP(QString tcp)
Updates the selected TCP.
void enableExportButtons(bool enable)
Enables or disables the export buttons.
void removeAllTrajectories()
Removes all trajectories from the TCP selection combo box.
void rnsChanged(VirtualRobot::RobotNodeSetPtr rns)
Notifies the VisualizationController about a changed RobotNodeSet.
void addWaypoint(int waypoint, bool insertAfter)
Adds a new waypoint relative to the given waypoint.
void updateSelectedTCP(QString trajectory)
Updates the currently displayed trajectory of the corresponding TCP.
void removeWaypointGui(int index)
Notifies other controllers about the deletion of a given waypoint.
void enableDeleteChange(bool enable)
Enables or disables the delete and change button/shortcut.
void exportTrajectory()
Stages the given trajectory for export.
void changeWaypointGui(int index, std::vector< double > values, int cartesianSelection, bool isBreakpoint)
Notfies other controllers about changes of an existing waypoint.
void changeTransitionGui(int transition, double duration, double start, int it)
Notifies other controllers about changes of an existing transition.
void enableUndo(bool enable)
Enables or disables the undo button/shortcut.
void updateWaypoint(int waypoint, std::vector< double > values)
Updates all values of a given waypoint.
void enablePreview(bool enable)
Enables or disables the prview button/shortcut.
void removeTransitionGui(int index)
Notifies other controllers about the deletion of a given transtion.
void exportTrajectory(std::vector< DesignerTrajectoryPtr > trajectories)
Provides the trajectory for ExportController.
void playTrajectories()
Play all trajectories.
void setBodyColModelsNames(QStringList bodyColModelsNames)
Sets the body collision models names.
void addTransitionGui(int transition, double duration, double start, int it)
Notifies other controllers about the addition of a transition.
void enableRedo(bool enable)
Enables or disables the redo button/shortcut.
void playTrajectories(std::vector< DesignerTrajectoryPtr > designerTrajectories)
Provides all trajectories for VisualizationController.
void removeTrajectory(QString trajectory)
Removes the given trajectory from the TCP selection combo box.
void newTrajectory(QString trajectory)
Notifies the TCPSelcetionController about a new Trajectory.
void showTrajectory(DesignerTrajectoryPtr designerTrajectory)
Provides the trajectory for VisualizationController.
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< armarx::DesignerTrajectoryManager > DesignerTrajectoryManagerPtr
Typedefinitions.
std::shared_ptr< armarx::DesignerTrajectoryHolder > DesignerTrajectoryHolderPtr
Typedefinitions.
std::shared_ptr< Environment > EnvironmentPtr
Definition Environment.h:29
std::shared_ptr< Transition > TransitionPtr
Definition Transition.h:143
std::shared_ptr< TrajectoryController > TrajectoryControllerPtr
std::shared_ptr< DesignerTrajectory > DesignerTrajectoryPtr
std::shared_ptr< UserWaypoint > UserWaypointPtr