TrajectoryController.h
Go to the documentation of this file.
1 #ifndef TRAJECTORYCONTROLLER_H
2 #define TRAJECTORYCONTROLLER_H
3 #include "../Manager/DesignerTrajectoryHolder.h"
4 #include "../Manager/DesignerTrajectoryManager.h"
5 #include "AbstractController.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,
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  */
211  void removeWaypointGui(int index);
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  */
226  void removeTransitionGui(int index);
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  */
243  void newTrajectory(QString trajectory);
244 
245  /**
246  * @brief Removes the given trajectory from the TCP selection combo box
247  * @param trajectory String identifier of the trajectory
248  */
249  void removeTrajectory(QString trajectory);
250 
251  /**
252  * @brief Removes all trajectories from the TCP selection combo box
253  */
254  void removeAllTrajectories();
255 
256  /**
257  * @brief Updates the currently displayed trajectory of the corresponding TCP
258  * @param trajectory String identifier of the trajectory
259  */
260  void updateSelectedTCP(QString trajectory);
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 
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
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:142
armarx::TrajectoryController::updateTransition
void updateTransition(int transition, int it)
Updates all values of a given transition.
Definition: TrajectoryController.cpp:103
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:156
armarx::TrajectoryController::updateWaypoint
void updateWaypoint(int waypoint, std::vector< double > values)
Updates all values of a given waypoint.
Definition: TrajectoryController.cpp:155
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:25
armarx::TrajectoryController::TrajectoryController
TrajectoryController()
Creates a new TrajectoryController and assigns a QWidget to handle.
Definition: TrajectoryController.cpp:38
armarx::TrajectoryController::addWaypoint
void addWaypoint(int waypoint, bool insertAfter)
Adds a new waypoint relative to the given waypoint.
Definition: TrajectoryController.cpp:304
armarx::navigation::core::StackLayer::TrajectoryController
@ TrajectoryController
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:31
armarx::TrajectoryController::updateTCP
void updateTCP(QString tcp)
Updates the selected TCP.
Definition: TrajectoryController.cpp:45
armarx::EnvironmentPtr
std::shared_ptr< Environment > EnvironmentPtr
Definition: Environment.h:29
armarx::TrajectoryController::redo
void redo()
Redo trajectory.
Definition: TrajectoryController.cpp:575
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:627
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:143
armarx::TrajectoryController::deleteWaypoint
void deleteWaypoint(int waypoint)
Deletes the given waypoint.
Definition: TrajectoryController.cpp:406
armarx::TrajectoryControllerPtr
std::shared_ptr< TrajectoryController > TrajectoryControllerPtr
Definition: TrajectoryController.h:66
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:402
armarx::TrajectoryController::onInitComponent
void onInitComponent() override
Definition: TrajectoryController.cpp:13
armarx::TrajectoryController::removeAllTrajectories
void removeAllTrajectories()
Removes all trajectories from the TCP selection combo box.
armarx::DesignerTrajectoryPtr
std::shared_ptr< DesignerTrajectory > DesignerTrajectoryPtr
Definition: DesignerTrajectory.h:163
armarx::TrajectoryController::undo
void undo()
Undo trajectroy.
Definition: TrajectoryController.cpp:558
armarx::TrajectoryController::onConnectComponent
void onConnectComponent() override
Definition: TrajectoryController.cpp:19
armarx::TrajectoryController::setActiveColModelName
void setActiveColModelName(QString activeColModelName)
Sets the active collision model name.
Definition: TrajectoryController.cpp:620
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:539
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
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:607
armarx::TrajectoryController::playTrajectories
void playTrajectories()
Play all trajectories.
Definition: TrajectoryController.cpp:592