CoinRobotViewerAdapter.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::Visualization
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 COINROBOTVIEWERADAPTER_H
23 #define COINROBOTVIEWERADAPTER_H
24 
25 #include "RobotVisualization.h"
27 #include "RobotViewer.h"
29 
30 ///COIN3D-INCLUDES
31 #include "Inventor/draggers/SoDragger.h"
32 #include "Inventor/SoPath.h"
33 #include "Inventor/nodes/SoSelection.h"
34 #include "Inventor/SoPickedPoint.h"
35 
36 namespace armarx
37 {
38  /**
39  * @brief The CoinRobotViewerAdapter class
40  */
42  {
43  public:
44 
45  /**
46  * @brief CoinRobotViewerAdapter
47  * @param widget the parent widget on the gui
48  */
49  CoinRobotViewerAdapter(QWidget* widget);
51  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
52  /// METHODS FOR VISUALIZATION SETUP
53  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
54  void addRobotVisualization(VirtualRobot::RobotPtr robot, QString selectedChain) override;
56  void setCamera(const Eigen::VectorXf position, const Eigen::VectorXf pointAtA, const Eigen::VectorXf pointAtB) override;
57  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
58  /// METHODS FOR TRANSITIONS
59  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60  void addTransitionVisualization(int index, std::vector<PoseBasePtr> transition) override;
61  void highlightTransitionVisualization(int index, std::vector<PoseBasePtr> transition) override;
62  void removeTransitionVisualization(int index) override;
63  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
64  /// METHODS FOR WAYPOINTS
65  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
66  void addWaypointVisualization(int index, PoseBasePtr waypoint, VirtualRobot::EndEffectorPtr tcp) override;
67  void removeWaypointVisualization(int index) override;
68  void removeAllWaypointVisualizations() override;
69  void setSelectedWaypoint(int index) override;
70 
71  void clearTrajectory() override;
72 
73  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
74  /// SETTING MANIPULATOR
75  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
76  void setManipulator(VirtualRobot::RobotNodeSetPtr kc, std::vector<float>jointAngles) override;
77  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
78  /// UPDATING OF VISUALIZATION
79  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
80  RobotVisualizationPtr reproduce(QWidget* parent) override;
81 
82  void updateRobotVisualization() override;
83  void enableVisualization() override;
84  void disableVisualization() override;
85 
86 
87  //inherited by VisualizationSubject
89  int getSelectedWaypoint() override;
90 
91  protected:
93 
94  private:
95 
96  AdvancedCoinVisualizationFactoryPtr factory; //produces Visualizations
97  std::shared_ptr<RobotViewer> viewer; //adaptedClass
98  SoDragger* dragger;//muss vor manipCallback initialisiert werden
99  void refreshSelectedPoint();
100  SoNodeList transitions;
101  SoNodeList wayPoints;
102  int selectedWaypoint;
103  int wayPointCounter;
104 
105  //Manipulator Utils
106  static void manipFinishCallback(void* data, SoDragger* dragger);
107  static void manipMovedCallback(void* data, SoDragger* dragger);
108  static void autoFollowSensorTimerCB(void* data, SoSensor* sensor);
109  ManipulatorVisualization* manipulator;
110  SoTimerSensor* autoFollowSensor;
111  bool manipulatorMoved;
112 
113 
114  //Visualization Update
115  SoTimerSensor* robotUpdateSensor;
116  static void robotUpdateTimerCB(void* data, SoSensor* sensor);
117  bool startUpCameraPositioningFlag = true;
118  SoCamera* camera;//pointer to camera of viewer to change perspective easyly
119 
120  //Selection utils
121  SoSelection* selected;
122  static void made_selection(void* data, SoPath* path);
123  static void unmade_selection(void* data, SoPath* path);
124  static SoPath* pickFilterCB(void* data, const SoPickedPoint* pick);
125  };
126 }
127 
128 
129 #endif
armarx::CoinRobotViewerAdapter::setManipulator
void setManipulator(VirtualRobot::RobotNodeSetPtr kc, std::vector< float >jointAngles) override
SETTING MANIPULATOR.
Definition: CoinRobotViewerAdapter.cpp:311
armarx::CoinRobotViewerAdapter::enableVisualization
void enableVisualization() override
enableVisualization shows the viewer
Definition: CoinRobotViewerAdapter.cpp:332
armarx::CoinRobotViewerAdapter
The CoinRobotViewerAdapter class.
Definition: CoinRobotViewerAdapter.h:41
AdvancedCoinVisualizationFactory.h
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::CoinRobotViewerAdapter::removeWaypointVisualization
void removeWaypointVisualization(int index) override
removeWaypointVisualization removes the Waypoint with index so that it is no longer visualized
Definition: CoinRobotViewerAdapter.cpp:285
armarx::CoinRobotViewerAdapter::disableVisualization
void disableVisualization() override
disableVisualization hides the viewer
Definition: CoinRobotViewerAdapter.cpp:337
armarx::CoinRobotViewerAdapter::addWaypointVisualization
void addWaypointVisualization(int index, PoseBasePtr waypoint, VirtualRobot::EndEffectorPtr tcp) override
METHODS FOR WAYPOINTS.
Definition: CoinRobotViewerAdapter.cpp:247
scene3D::ScenePtr
std::shared_ptr< Scene > ScenePtr
Definition: PointerDefinitions.h:36
armarx::RobotVisualization::scene
VirtualRobot::ScenePtr scene
Definition: RobotVisualization.h:155
armarx::CoinRobotViewerAdapter::removeTransitionVisualization
void removeTransitionVisualization(int index) override
removeTransitionVisualization removes visualization of a certain transition
Definition: CoinRobotViewerAdapter.cpp:203
armarx::CoinRobotViewerAdapter::removeAllWaypointVisualizations
void removeAllWaypointVisualizations() override
removeAllWaypointVisualizations removes all waypoints that are currently visualized
Definition: CoinRobotViewerAdapter.cpp:293
armarx::CoinRobotViewerAdapter::setSelectedWaypoint
void setSelectedWaypoint(int index) override
removeWaypointVisualization removes the Waypoint with index so that it is no longer visualized
Definition: CoinRobotViewerAdapter.cpp:302
armarx::CoinRobotViewerAdapter::highlightTransitionVisualization
void highlightTransitionVisualization(int index, std::vector< PoseBasePtr > transition) override
highlightTransitionVisualization highlights the transition with index i by changing the color of all ...
Definition: CoinRobotViewerAdapter.cpp:210
armarx::RobotVisualization
Definition: RobotVisualization.h:39
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::RobotVisualization::robot
VirtualRobot::RobotPtr robot
Definition: RobotVisualization.h:156
ManipulatorVisualization.h
armarx::AdvancedVisualizationFactoryPtr
std::shared_ptr< AdvancedVisualizationFactory > AdvancedVisualizationFactoryPtr
Definition: AdvancedVisualizationFactory.h:191
armarx::CoinRobotViewerAdapter::addSceneVisualization
void addSceneVisualization(VirtualRobot::ScenePtr scene) override
addSceneVisualization visualizes the whole scene where the robot is placed in
Definition: CoinRobotViewerAdapter.cpp:178
armarx::CoinRobotViewerAdapter::createAdvancedVisualizationFactory
AdvancedVisualizationFactoryPtr createAdvancedVisualizationFactory() override
Definition: CoinRobotViewerAdapter.cpp:242
armarx::CoinRobotViewerAdapter::clearTrajectory
void clearTrajectory() override
clearTrajectory removes all visualization of waypoints and transitions but keeps the robot and the ma...
Definition: CoinRobotViewerAdapter.cpp:342
armarx::channels::KinematicUnitObserver::jointAngles
const KinematicUnitDatafieldCreator jointAngles("jointAngles")
armarx::RobotVisualizationPtr
std::shared_ptr< RobotVisualization > RobotVisualizationPtr
Definition: RobotVisualization.h:161
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::CoinRobotViewerAdapter::updateRobotVisualization
void updateRobotVisualization() override
UPDATING OF VISUALIZATION.
Definition: CoinRobotViewerAdapter.cpp:327
armarx::CoinRobotViewerAdapter::CoinRobotViewerAdapter
CoinRobotViewerAdapter(QWidget *widget)
CoinRobotViewerAdapter.
Definition: CoinRobotViewerAdapter.cpp:68
RobotVisualization.h
armarx::ManipulatorVisualization
Definition: ManipulatorVisualization.h:51
armarx::CoinRobotViewerAdapter::getManipulatorPose
Eigen::Matrix4f getManipulatorPose() override
INHERITED BY OBSERVER.
Definition: CoinRobotViewerAdapter.cpp:231
armarx::CoinRobotViewerAdapter::setCamera
void setCamera(const Eigen::VectorXf position, const Eigen::VectorXf pointAtA, const Eigen::VectorXf pointAtB) override
setCamera sets the camera at a certain position
Definition: CoinRobotViewerAdapter.cpp:184
RobotViewer.h
armarx::CoinRobotViewerAdapter::reproduce
RobotVisualizationPtr reproduce(QWidget *parent) override
UPDATING OF VISUALIZATION.
Definition: CoinRobotViewerAdapter.cpp:355
armarx::CoinRobotViewerAdapter::addTransitionVisualization
void addTransitionVisualization(int index, std::vector< PoseBasePtr > transition) override
METHODS FOR TRANSITIONS.
Definition: CoinRobotViewerAdapter.cpp:194
armarx::CoinRobotViewerAdapter::~CoinRobotViewerAdapter
~CoinRobotViewerAdapter()
Definition: CoinRobotViewerAdapter.cpp:106
armarx::CoinRobotViewerAdapter::addRobotVisualization
void addRobotVisualization(VirtualRobot::RobotPtr robot, QString selectedChain) override
METHODS FOR VISUALIZATION SETUP.
Definition: CoinRobotViewerAdapter.cpp:140
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::AdvancedCoinVisualizationFactoryPtr
std::shared_ptr< AdvancedCoinVisualizationFactory > AdvancedCoinVisualizationFactoryPtr
Definition: AdvancedCoinVisualizationFactory.h:49
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::CoinRobotViewerAdapter::getSelectedWaypoint
int getSelectedWaypoint() override
getSelectedWaypoint
Definition: CoinRobotViewerAdapter.cpp:236