TrajectoryController.h
Go to the documentation of this file.
1 #ifndef TRAJECTORYCONTROLLER_H
2 #define TRAJECTORYCONTROLLER_H
3 #include "AbstractController.h"
4 #include "../Manager/DesignerTrajectoryHolder.h"
5 #include "../Manager/DesignerTrajectoryManager.h"
6 
7 namespace 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  */
14  class TrajectoryController : public AbstractController
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  */
181  void changeWaypointGui(int index, std::vector<double> values, int cartesianSelection,
182  bool isBreakpoint);
183 
184  /**
185  * @brief Notifies other controllers about changes of an existing transition
186  * @param duration Duration of the transition
187  * @param start Start time of the transition
188  * @param it Index of interpolation of the transition
189  * @param transition Index of the transition
190  */
191  void changeTransitionGui(int transition, double duration, double start, int it);
192 
193  /**
194  * @brief Notifies other controllers about the addition of a waypoint
195  * @param values Array containting x, y, z, coordinates as well as r, p, y
196  * euler angles of the waypoint
197  * @param constraints Constraints of the waypoint: isBreakpoint, ikConstraints
198  * @param waypoint Index of the waypoint
199  */
200  void addWaypointGui(int waypoint, std::vector<double> values, int cartesianSelection, bool isBreakpoint);
201 
202  /**
203  * @brief Notifies other controllers about the deletion of a given waypoint
204  * @param index Index of the waypoitn
205  */
206  void removeWaypointGui(int index);
207 
208  /**
209  * @brief Notifies other controllers about the addition of a transition
210  * @param duration Duration of the transition
211  * @param start Start time of the transition
212  * @param it Index of the interpolation of the transition
213  * @param transition Index of the transition
214  */
215  void addTransitionGui(int transition, double duration, double start, int it);
216 
217  /**
218  * @brief Notifies other controllers about the deletion of a given transtion
219  * @param index Index of the transition
220  */
221  void removeTransitionGui(int index);
222 
223  /**
224  * @brief Notifies WaypointTab and Transition to delete all ListWidgets
225  */
227 
228  /**
229  * @brief Notifies the VisualizationController about a changed RobotNodeSet
230  * @param rns new RobotNodeSet
231  */
232  void rnsChanged(VirtualRobot::RobotNodeSetPtr rns);
233 
234  /**
235  * @brief Notifies the TCPSelcetionController about a new Trajectory
236  * @param trajectory new trajectory
237  */
238  void newTrajectory(QString trajectory);
239 
240  /**
241  * @brief Removes the given trajectory from the TCP selection combo box
242  * @param trajectory String identifier of the trajectory
243  */
244  void removeTrajectory(QString trajectory);
245 
246  /**
247  * @brief Removes all trajectories from the TCP selection combo box
248  */
249  void removeAllTrajectories();
250 
251  /**
252  * @brief Updates the currently displayed trajectory of the corresponding TCP
253  * @param trajectory String identifier of the trajectory
254  */
255  void updateSelectedTCP(QString trajectory);
256 
257  /**
258  * @brief Provides the trajectory for VisualizationController
259  * @param designerTrajectory Trajectory to provide
260  */
261  void showTrajectory(DesignerTrajectoryPtr designerTrajectory);
262 
263  /**
264  * @brief Provides all trajectories for VisualizationController
265  * @param designerTrajectories Trajectories to play
266  */
267  void playTrajectories(std::vector<DesignerTrajectoryPtr> designerTrajectories);
268 
269  /**
270  * @brief Provides the trajectory for ExportController
271  * @param trajectory Trajectory to provide
272  */
273  void exportTrajectory(std::vector<DesignerTrajectoryPtr> trajectories);
274 
275  /**
276  * @brief cartesianSelectionChanged recalculates the configuration of the robot joints to fit the new selection
277  * @param cs the new CartesianSelection
278  */
279 
281  /**
282  * @brief Enables or disables the redo button/shortcut
283  * @param enable Determines whether to enable or disable the redo button/shortcut
284  */
285  void enableRedo(bool enable);
286 
287  /**
288  * @brief Enables or disables the undo button/shortcut
289  * @param enable Determines whether to enable or disable the undo button/shortcut
290  */
291  void enableUndo(bool enable);
292 
293  /**
294  * @brief Enables or disables the new IK solution button
295  * @param enable Determines whether to enable or disable the ik solution button
296  */
297  void enableIKSolutionButton(bool enable);
298 
299  /**
300  * @brief Enables or disables the export buttons
301  * @param enable Determines whether to enable or disable the export buttons
302  */
303  void enableExportButtons(bool enable);
304 
305  /**
306  * @brief Enables or disables the delete and change button/shortcut
307  * @param enable Determines whether to enable or disable the delete and change button/shortcut
308  */
309  void enableDeleteChange(bool enable);
310 
311  /**
312  * @brief Enables or disables the add button/shortcut
313  * @param enable Determines whether to enable or disable the add button/shortcut
314  */
315  void enableAdd(bool enable);
316 
317  /**
318  * @brief Enables or disables the prview button/shortcut
319  * @param enable Determines whether to enable or disable the previes button/shortcut
320  */
321  void enablePreview(bool enable);
322 
323  /**
324  * @brief Enables or disables the prview all button/shortcut
325  * @param enable Determines whether to enable or disable the previes button/shortcut
326  */
327  void enablePreviewAll(bool enable);
328 
329  private:
330  /**
331  * @brief Converts a PoseBase to x, y, z coordinates and r, p, y euler angles
332  * @param pose PoseBase to convert
333  * @return Vector containing the resulting coordinates and angles
334  */
335  std::vector<double>parseToCoordinate(PoseBasePtr pose);
336 
337  PoseBasePtr parseToPoseBasePtr(std::vector<double> values);
338 
339  void helpAddWaypointGui(UserWaypointPtr waypoint, int waypointIndex);
340  void helpAddTransitionGui(TransitionPtr transition, int transitionIndex);
341  void addTransitionWaypointGui(DesignerTrajectoryPtr trajectory);
342 
343  void helpChangeTransitionGui(TransitionPtr transition, int transitionIndex);
344  void helpChangeWaypointGui(UserWaypointPtr waypoint, int waypointIndex);
345  void changeTransitionWaypointGui(DesignerTrajectoryPtr trajectory);
346 
347  void helpImportDesignerTrajectory(DesignerTrajectoryPtr designerTrajectory);
348 
349  void helpCreateDesignerTrajectoryManager();
350 
351  bool helpEnableExportPreviewAll();
352  void helpEnableUndoRedo();
353  void helpEnableButtons();
354 
355  void helpExceptionMessageBox(std::string errorMessage);
356 
357  void helpCollision();
358 
361  VirtualRobot::RobotNodeSetPtr rns;
362  EnvironmentPtr environment;
363  std::string activeColModelName;
364  std::vector<std::string> bodyColModelsNames;
365  };
366 
367  using TrajectoryControllerPtr = std::shared_ptr<TrajectoryController>;
368 }
369 
370 #endif // TRAJECTORYCONTROLLER_H
armarx::TrajectoryController::removeTrajectory
void removeTrajectory(QString trajectory)
Removes the given trajectory from the TCP selection combo box.
armarx::UserWaypointPtr
std::shared_ptr< UserWaypoint > UserWaypointPtr
Definition: UserWaypoint.h:137
armarx::TrajectoryController::updateTransition
void updateTransition(int transition, int it)
Updates all values of a given transition.
Definition: TrajectoryController.cpp:92
armarx::TrajectoryController::enableIKSolutionButton
void enableIKSolutionButton(bool enable)
Enables or disables the new IK solution button.
armarx::DesignerTrajectoryHolderPtr
std::shared_ptr< armarx::DesignerTrajectoryHolder > DesignerTrajectoryHolderPtr
Typedefinitions.
Definition: DesignerTrajectoryHolder.h:158
armarx::TrajectoryController::updateWaypoint
void updateWaypoint(int waypoint, std::vector< double > values)
Updates all values of a given waypoint.
Definition: TrajectoryController.cpp:139
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::TrajectoryController::updateSelectedTCP
void updateSelectedTCP(QString trajectory)
Updates the currently displayed trajectory of the corresponding TCP.
armarx::TrajectoryController::newTrajectory
void newTrajectory(QString trajectory)
Notifies the TCPSelcetionController about a new Trajectory.
armarx::TrajectoryController::enableExportButtons
void enableExportButtons(bool enable)
Enables or disables the export buttons.
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::TrajectoryController::enableUndo
void enableUndo(bool enable)
Enables or disables the undo button/shortcut.
armarx::TrajectoryController::onDisconnectComponent
void onDisconnectComponent() override
Definition: TrajectoryController.cpp:19
armarx::TrajectoryController::TrajectoryController
TrajectoryController()
Creates a new TrajectoryController and assigns a QWidget to handle.
Definition: TrajectoryController.cpp:31
armarx::TrajectoryController::addWaypoint
void addWaypoint(int waypoint, bool insertAfter)
Adds a new waypoint relative to the given waypoint.
Definition: TrajectoryController.cpp:271
armarx::TrajectoryController::changeTransitionGui
void changeTransitionGui(int transition, double duration, double start, int it)
Notifies other controllers about changes of an existing transition.
armarx::TrajectoryController::onExitComponent
void onExitComponent() override
Definition: TrajectoryController.cpp:24
armarx::TrajectoryController::updateTCP
void updateTCP(QString tcp)
Updates the selected TCP.
Definition: TrajectoryController.cpp:37
armarx::EnvironmentPtr
std::shared_ptr< Environment > EnvironmentPtr
Definition: Environment.h:29
armarx::TrajectoryController::redo
void redo()
Redo trajectory.
Definition: TrajectoryController.cpp:506
AbstractController.h
armarx::TrajectoryController::enableAdd
void enableAdd(bool enable)
Enables or disables the add button/shortcut.
armarx::TrajectoryController::enableRedo
void enableRedo(bool enable)
Enables or disables the redo button/shortcut.
armarx::NJointTaskSpaceDMPControllerMode::CartesianSelection
CartesianSelection
Definition: ControllerInterface.ice:34
armarx::TrajectoryController::setBodyColModelsNames
void setBodyColModelsNames(QStringList bodyColModelsNames)
Sets the body collision models names.
Definition: TrajectoryController.cpp:553
armarx::TrajectoryController::addTransitionGui
void addTransitionGui(int transition, double duration, double start, int it)
Notifies other controllers about the addition of a transition.
armarx::TrajectoryController::removeTransitionGui
void removeTransitionGui(int index)
Notifies other controllers about the deletion of a given transtion.
armarx::TrajectoryController::showTrajectory
void showTrajectory(DesignerTrajectoryPtr designerTrajectory)
Provides the trajectory for VisualizationController.
armarx::TrajectoryController::enablePreviewAll
void enablePreviewAll(bool enable)
Enables or disables the prview all button/shortcut.
armarx::TransitionPtr
std::shared_ptr< Transition > TransitionPtr
Definition: Transition.h:141
armarx::TrajectoryController::deleteWaypoint
void deleteWaypoint(int waypoint)
Deletes the given waypoint.
Definition: TrajectoryController.cpp:352
armarx::navigation::core::StackLayer::TrajectoryController
@ TrajectoryController
armarx::TrajectoryControllerPtr
std::shared_ptr< TrajectoryController > TrajectoryControllerPtr
Definition: TrajectoryController.h:61
armarx::TrajectoryController::enableDeleteChange
void enableDeleteChange(bool enable)
Enables or disables the delete and change button/shortcut.
armarx::DesignerTrajectoryManagerPtr
std::shared_ptr< armarx::DesignerTrajectoryManager > DesignerTrajectoryManagerPtr
Typedefinitions.
Definition: DesignerTrajectoryManager.h:399
armarx::TrajectoryController::onInitComponent
void onInitComponent() override
Definition: TrajectoryController.cpp:9
armarx::TrajectoryController::removeAllTrajectories
void removeAllTrajectories()
Removes all trajectories from the TCP selection combo box.
armarx::DesignerTrajectoryPtr
std::shared_ptr< DesignerTrajectory > DesignerTrajectoryPtr
Definition: DesignerTrajectory.h:165
armarx::TrajectoryController::undo
void undo()
Undo trajectroy.
Definition: TrajectoryController.cpp:490
armarx::TrajectoryController::onConnectComponent
void onConnectComponent() override
Definition: TrajectoryController.cpp:14
armarx::TrajectoryController::setActiveColModelName
void setActiveColModelName(QString activeColModelName)
Sets the active collision model name.
Definition: TrajectoryController.cpp:547
armarx::TrajectoryController::rnsChanged
void rnsChanged(VirtualRobot::RobotNodeSetPtr rns)
Notifies the VisualizationController about a changed RobotNodeSet.
armarx::TrajectoryController::changeWaypointGui
void changeWaypointGui(int index, std::vector< double > values, int cartesianSelection, bool isBreakpoint)
Notfies other controllers about changes of an existing waypoint.
armarx::TrajectoryController::cartesianSelectionChanged
void cartesianSelectionChanged(VirtualRobot::IKSolver::CartesianSelection cs)
cartesianSelectionChanged recalculates the configuration of the robot joints to fit the new selection
armarx::TrajectoryController::addWaypointGui
void addWaypointGui(int waypoint, std::vector< double > values, int cartesianSelection, bool isBreakpoint)
Notifies other controllers about the addition of a waypoint.
armarx::TrajectoryController::enablePreview
void enablePreview(bool enable)
Enables or disables the prview button/shortcut.
armarx::TrajectoryController::removeWaypointGui
void removeWaypointGui(int index)
Notifies other controllers about the deletion of a given waypoint.
armarx::TrajectoryController::exportTrajectory
void exportTrajectory()
Stages the given trajectory for export.
Definition: TrajectoryController.cpp:474
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::TrajectoryController::removeTransitionWaypointGui
void removeTransitionWaypointGui()
Notifies WaypointTab and Transition to delete all ListWidgets.
armarx::TrajectoryController::environmentChanged
void environmentChanged(EnvironmentPtr environment)
Set the enviroment.
Definition: TrajectoryController.cpp:535
armarx::TrajectoryController::playTrajectories
void playTrajectories()
Play all trajectories.
Definition: TrajectoryController.cpp:522