RobotVisualizationController.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarXGuiPlugins::RobotTrajectoryDesigner::Controllers
17 * @author Timo Birr
18 * @date 2018
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22#ifndef ROBOTVIEWERCONTROLLER_H
23#define ROBOTVIEWERCONTROLLER_H
24
25#include <Eigen/Eigen>
26
27#include "RobotAPI/interface/core/PoseBase.h"
29
30#include "../Environment.h"
36#include "AbstractController.h"
37#include "VirtualRobot/IK/IKSolver.h"
39#include <Inventor/sensors/SoTimerSensor.h>
40
41namespace armarx
42{
43
44 /**
45 * @brief The RobotVisualizationController
46 * A Controller to control the visualization of the robot. Hides the concrete visualization Method(Coin,OSG) from the rest of the application.
47 * Provides Methods for adding Visualization of one Robot at a time, waypoints and transitions between waypoints. Supports up to four parallel views.
48 * Informs other Controllers about the Position of the Manipulator, the TCP and the selected waypoint.
49 */
51 {
52 Q_OBJECT
53 friend class RobotVisualization;
54
55 public:
56 /**
57 * @brief RobotVisualizationController creates a new RobotVisualizationController
58 * @param parent the widget in which th viewer should be placed in
59 */
60 RobotVisualizationController(QWidget* parent);
62
63 //inherited by abstract controller
64 void onInitComponent() override;
65 void onConnectComponent() override;
66 void onDisconnectComponent() override;
67 void onExitComponent() override;
68
69 //inherited by VisualizationObserver
70 void refresh() override;
71 void addConnection(std::shared_ptr<RobotVisualizationController> ctr);
72
73 public slots:
74
75 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
76 /// PARALLEL VIEWS
77 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
78 /**
79 * @brief addView adds new RobotViewer
80 */
81 void addView();
82 /**
83 * @brief removeView removes RobotViewer with index
84 * @param index the index of the view to remove
85 */
86 void removeView();
87
88 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
89 /// UPDATING OF VISUALIZATION
90 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
91 /**
92 * @brief updateViews Removes the current visualization of all Waypoints and Transitions and replaces them with the visualization of the new Trajectory
93 * @param trajectory the trajectory to display next
94 */
96
97 /**
98 * @brief robotChanged updates the robot model that is currently visualized
99 * Removes the robot that is visualized prior to this one
100 * @param robot the new Robot to visualize
101 */
103
104 /**
105 * @brief environmentChanged updates the environment that is currently visualized
106 * @param environment the new environment
107 */
108 void environmentChanged(EnvironmentPtr environment);
109
110 /**
111 * @brief displayAllWayPoints Enables Visualization and threfore selection of all waypoints of the current Trajectory and not only userWaypoints
112 * @param display
113 */
114 void displayAllWayPoints(bool display);
115
116 /**
117 * @brief selectedWayPointChanged highlights the waypoint with index and moves the manipulator to its Pose
118 * @param index the index of the waypoint to select next
119 */
121
122 /**
123 * @brief selectedTransitionChanged highlights the Transition with index
124 * @param index the index of the transition that should be highlighted
125 */
127
128 void clearView();
129 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
130 /// IK CALLBACK METHODS
131 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
132 /**
133 * @brief cartesianSelectionChanged recalculates the configuration of the robot joints to fit the new selection
134 * @param cs the new CartesianSelection
135 */
136 void cartesianSelectionChanged(VirtualRobot::IKSolver::CartesianSelection cs);
137
138 /**
139 * @brief kinematicChainChanged removes all visualization from the previously selected Trajectory and changes the Visualization of the
140 * Manipulator to look like the endeffector of the kinematic chain
141 * @param selectedChain
142 */
143 void kinematicChainChanged(VirtualRobot::RobotNodeSetPtr rns);
144
145 /**
146 * @brief setIKCallbackEnabled sets whther the robot Model tries to reach the Pose determined by the Manipulator
147 * @param enabled if true the robot follows the manipulator
148 */
149 void setIKCallbackEnabled(bool enabled);
150
151
152 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
153 /// CAMERA UPDATING METHODS
154 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
155 /**
156 * @brief setCamera Sets the camera of all views to standard Position
157 * sets camera to standard perspective
158 */
159 void setCamera();
160
161 /**
162 * @brief setCamera sets camera to the Perspective with index perspective in the corresponding enum
163 * @param perspective the selected perspective
164 * 0 - High Angle
165 * 1 - Top
166 * 2 - Front
167 * 3 - Back
168 * 4 - Left
169 * 5 - Right
170 */
171 void setCamera(int perspective);
172 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
173 /// PLAY TRAJECTORY
174 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
175
176 /**
177 * @brief playTrajectories plays the currently selected trajectory and disables all other visualization features
178 */
179 void playTrajectory();
180 /**
181 * @brief playTrajectories plays all trajectories at the same time
182 * @param trajectories the trajectories to play - no duplicates of selected robot node sets allowed!
183 */
184 void playTrajectories(std::vector<DesignerTrajectoryPtr> trajectories);
185 /**
186 * @brief trajectoryPlayerStopped restarts the visualization of the whole scene after the debug drawer does not longer visualize the trajectory
187 */
189
190
191 signals:
192 /**
193 * @brief wayPointSelected informs all relevant controllers that the currently selected Waypoit has been changed via click on the waypoint in the RobotViewer
194 * @param index
195 */
197 /**
198 * @brief manipulatorChanged informs all relevant controllers that the pose of the manipulator has changed and therefore the currently selected Waypoint is also changed
199 */
200 void manipulatorChanged(Eigen::Matrix4f globalPose);
201 /**
202 * @brief tcpPoseChanged informs all releveant controllers about the new global pose of the manipulator
203 * @param globalPose the pose of the manipulator relative to the global frame
204 */
205 void tcpPoseChanged(Eigen::Matrix4f globalPose);
206 /**
207 * @brief poseReachable informs all relevant controllers whether the pose of the manipulator is reachable
208 * @param reachable true when there is an IK-solution for the manipulator could be found
209 */
210 void poseReachable(bool reachable);
211 /**
212 * @brief trajectoryPlayerNotPlaying
213 * @param playing
214 */
215 void trajectoryPlayerNotPlaying(bool playing);
216
217 void trajectoryPlayerPlaying(bool playing);
218
219 private:
221 QWidget* parent;
222 RobotVisualizationWidget* viewSplitter;
223 bool iKCallback;
224 DesignerTrajectoryPtr currentTrajectory;
226 int selectedWayPoint;
227 int selectedTransition;
228 VirtualRobot::IKSolver::CartesianSelection cs;
229 VirtualRobot::RobotNodeSetPtr selectedKinematicChain;
230 EnvironmentPtr environment;
231
232 bool playerRunning;
234 void playerStarter();
235 };
236
237 using RobotVisualizationControllerPtr = std::shared_ptr<RobotVisualizationController>;
238} // namespace armarx
239
240#endif
uint8_t index
Abstract controller providing a set of methods which must be implemented by every controller.
void environmentChanged(EnvironmentPtr environment)
environmentChanged updates the environment that is currently visualized
void onInitComponent() override
Initializes the controller.
void tcpPoseChanged(Eigen::Matrix4f globalPose)
tcpPoseChanged informs all releveant controllers about the new global pose of the manipulator
void addConnection(std::shared_ptr< RobotVisualizationController > ctr)
void wayPointSelected(int index)
wayPointSelected informs all relevant controllers that the currently selected Waypoit has been change...
void removeView()
removeView removes RobotViewer with index
void cartesianSelectionChanged(VirtualRobot::IKSolver::CartesianSelection cs)
IK CALLBACK METHODS.
void onDisconnectComponent() override
Called whenever a component is disconnected.
void selectedTransitionChanged(int index)
selectedTransitionChanged highlights the Transition with index
void displayAllWayPoints(bool display)
displayAllWayPoints Enables Visualization and threfore selection of all waypoints of the current Traj...
void refresh() override
refresh gets all relevant data from subject an updates itself accoringly should be called by subject ...
void poseReachable(bool reachable)
poseReachable informs all relevant controllers whether the pose of the manipulator is reachable
void kinematicChainChanged(VirtualRobot::RobotNodeSetPtr rns)
kinematicChainChanged removes all visualization from the previously selected Trajectory and changes t...
void manipulatorChanged(Eigen::Matrix4f globalPose)
manipulatorChanged informs all relevant controllers that the pose of the manipulator has changed and ...
void trajectoryPlayerPlaying(bool playing)
void updateViews(DesignerTrajectoryPtr trajectory)
UPDATING OF VISUALIZATION.
void setIKCallbackEnabled(bool enabled)
setIKCallbackEnabled sets whther the robot Model tries to reach the Pose determined by the Manipulato...
RobotVisualizationController(QWidget *parent)
RobotVisualizationController creates a new RobotVisualizationController.
void playTrajectories(std::vector< DesignerTrajectoryPtr > trajectories)
playTrajectories plays all trajectories at the same time
void selectedWayPointChanged(int index)
selectedWayPointChanged highlights the waypoint with index and moves the manipulator to its Pose
void onConnectComponent() override
Connects all signals and slots of the controller.
void trajectoryPlayerNotPlaying(bool playing)
trajectoryPlayerNotPlaying
void robotChanged(VirtualRobot::RobotPtr robot)
robotChanged updates the robot model that is currently visualized Removes the robot that is visualize...
void onExitComponent() override
Called on exit, cleans.
void trajectoryPlayerStopped()
trajectoryPlayerStopped restarts the visualization of the whole scene after the debug drawer does not...
The RobotVisualizationWidget class Holds the original viewer and reproduces it tosupport parallel vie...
The AdvancedVisualizationFactory class is the abstract decorator of the Decorator-Pattern and decorat...
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< DesignerTrajectoryPlayer > DesignerTrajectoryPlayerPtr
std::shared_ptr< Environment > EnvironmentPtr
Definition Environment.h:29
std::shared_ptr< RobotVisualizationController > RobotVisualizationControllerPtr
std::shared_ptr< DesignerTrajectory > DesignerTrajectoryPtr
std::shared_ptr< RobotVisualization > RobotVisualizationPtr