RobotViewerGuiPlugin.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 ArmarX::Component::RobotViewerGuiPlugin
17 * @author Nikolaus Vahrenkamp
18 * @copyright 2015 KIT
19 * @license http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 
22 */
23 
24 #pragma once
25 
26 /* ArmarX headers */
27 #include <RobotAPI/gui-plugins/RobotViewerPlugin/ui_RobotViewerGuiPlugin.h>
30 
34 
36 
37 /* Qt headers */
38 #include <QMainWindow>
39 
40 
41 #include <VirtualRobot/Robot.h>
42 #include <VirtualRobot/Nodes/RobotNode.h>
43 #include <VirtualRobot/RobotNodeSet.h>
44 #include <VirtualRobot/Visualization/VisualizationFactory.h>
45 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualization.h>
46 
47 #include <Inventor/sensors/SoTimerSensor.h>
48 
49 namespace armarx
50 {
51  class RobotViewerConfigDialog;
52 
53  /**
54  \class RobotViewerGuiPlugin
55  \brief This plugin provides a generic widget showing a 3D model of the robot. The robot is articulated and moved according to the corresponding RemoteRobot.
56  Further, DebugDrawer methods are available.
57  \see RobotViewerWidget
58  */
60  public ArmarXGuiPlugin
61  {
62  Q_OBJECT
63  Q_INTERFACES(ArmarXGuiInterface)
64  Q_PLUGIN_METADATA(IID "ArmarXGuiInterface/1.00")
65  public:
67 
68  QString getPluginName() override
69  {
70  return "RobotViewerGuiPlugin";
71  }
72  };
73 
74  /**
75  \page RobotAPI-GuiPlugins-RobotViewerPlugin RobotViewerPlugin
76 
77  \brief This widget shows a 3D model of the robot. The robot is articulated and moved according to the corresponding RemoteRobot.
78  Further, DebugDrawer methods are available.
79  \image html RobotViewerGUI.png
80  When you add the widget to the Gui, you need to specify the following parameters:
81 
82  Parameter Name | Example Value | Required? | Description
83  :---------------- | :-------------: | :-------------- |:--------------------
84  Proxy | RobotStateComponent | Yes | The name of the robot state component.
85  */
87  public ArmarXComponentWidgetControllerTemplate<RobotViewerWidgetController>,
88  public RobotStateListenerInterface
89  {
90  Q_OBJECT
91  public:
92 
95 
96  // inherited from Component
97  void onInitComponent() override;
98  void onConnectComponent() override;
99  void onDisconnectComponent() override;
100  void onExitComponent() override;
101 
102  // inherited from ArmarXWidget
103  static QString GetWidgetName()
104  {
105  return "Visualization.RobotViewerGUI";
106  }
107 
108  QPointer<QDialog> getConfigDialog(QWidget* parent = 0) override;
109  void loadSettings(QSettings* settings) override;
110  void saveSettings(QSettings* settings) override;
111  void configured() override;
112 
113  SoNode* getScene() override;
114 
115  // overwrite setMutex, so that we can inform the debugdrawer
116  void setMutex3D(RecursiveMutexPtr const& mutex3D) override;
117 
118  signals:
119  void robotStatusUpdated();
120  void configurationChanged();
121 
122  public slots:
123  void updateRobotVisu();
124  void inflateCollisionModel(int inflationValueMM);
125 
126  protected:
127  void connectSlots();
128 
129 
130  Ui::RobotViewerGuiPlugin ui;
131 
132  bool verbose;
133 
134 
137 
139  NameList robotNodeNames;
140 
142 
143  SoSeparator* rootVisu;
144  SoSeparator* robotVisu;
145 
146  SoTimerSensor* timerSensor;
147 
148  SoSeparator* debugLayerVisu;
150 
151  static void timerCB(void* data, SoSensor* sensor);
152  void setRobotVisu(bool colModel);
153 
154  protected slots:
155  void showVisuLayers(bool show);
156  void showRoot(bool show);
157  void showRobot(bool show);
158  void colModel(bool c);
159 
160  void updateStateSettings(int);
161  void copyToClipboard();
162  void updateState();
163  void onConfigurationChanged();
164 
165  private:
166 
167  // init stuff
168  VirtualRobot::RobotPtr loadRobotFile(std::string fileName);
169 
171 
172  QPointer<QWidget> __widget;
173  QPointer<SimpleConfigDialog> dialog;
174 
175  // ArmarXWidgetController interface
176  public:
177  static QIcon GetWidgetIcon()
178  {
179  return QIcon(":icons/armarx-gui.png");
180  }
181 
182  // RobotStateListenerInterface interface
183  public:
184  void reportGlobalRobotRootPose(const FramedPoseBasePtr& pose, Ice::Long timestamp, bool poseChanged, const Ice::Current&) override;
185  void reportJointValues(const NameValueMap& jointAngles, Ice::Long timestamp, bool aValueChanged, const Ice::Current&) override;
186  };
187  using RobotViewerGuiPluginPtr = std::shared_ptr<RobotViewerWidgetController>;
188 }
189 
DebugDrawerComponent.h
armarx::ArmarXWidgetController::mutex3D
std::shared_ptr< std::recursive_mutex > mutex3D
Definition: ArmarXWidgetController.h:301
armarx::RobotViewerWidgetController
Definition: RobotViewerGuiPlugin.h:86
armarx::RobotViewerWidgetController::robotStateComponentName
std::string robotStateComponentName
Definition: RobotViewerGuiPlugin.h:141
RemoteRobot.h
armarx::RobotViewerWidgetController::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: RobotViewerGuiPlugin.cpp:299
armarx::RobotViewerWidgetController::RobotViewerWidgetController
RobotViewerWidgetController()
Definition: RobotViewerGuiPlugin.cpp:92
armarx::RobotViewerGuiPlugin
This plugin provides a generic widget showing a 3D model of the robot. The robot is articulated and m...
Definition: RobotViewerGuiPlugin.h:59
armarx::RobotViewerWidgetController::reportGlobalRobotRootPose
void reportGlobalRobotRootPose(const FramedPoseBasePtr &pose, Ice::Long timestamp, bool poseChanged, const Ice::Current &) override
Definition: RobotViewerGuiPlugin.cpp:742
armarx::RobotViewerWidgetController::showVisuLayers
void showVisuLayers(bool show)
Definition: RobotViewerGuiPlugin.cpp:404
armarx::RobotViewerWidgetController::updateState
void updateState()
Definition: RobotViewerGuiPlugin.cpp:601
armarx::RobotViewerWidgetController::GetWidgetName
static QString GetWidgetName()
Definition: RobotViewerGuiPlugin.h:103
armarx::ArmarXGuiPlugin
Definition: ArmarXGuiPlugin.h:46
armarx::RobotViewerGuiPlugin::getPluginName
QString getPluginName() override
Definition: RobotViewerGuiPlugin.h:68
armarx::RobotViewerWidgetController::inflateCollisionModel
void inflateCollisionModel(int inflationValueMM)
Definition: RobotViewerGuiPlugin.cpp:719
armarx::RobotViewerGuiPluginPtr
std::shared_ptr< RobotViewerWidgetController > RobotViewerGuiPluginPtr
Definition: RobotViewerGuiPlugin.h:187
armarx::RobotViewerWidgetController::robotStateComponentPrx
RobotStateComponentInterfacePrx robotStateComponentPrx
Definition: RobotViewerGuiPlugin.h:135
armarx::RobotViewerWidgetController::GetWidgetIcon
static QIcon GetWidgetIcon()
Definition: RobotViewerGuiPlugin.h:177
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::RobotViewerWidgetController::verbose
bool verbose
Definition: RobotViewerGuiPlugin.h:132
armarx::RobotViewerWidgetController::robotNodeNames
NameList robotNodeNames
Definition: RobotViewerGuiPlugin.h:139
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
SimpleConfigDialog.h
armarx::RobotViewerWidgetController::debugLayerVisu
SoSeparator * debugLayerVisu
Definition: RobotViewerGuiPlugin.h:148
armarx::RobotViewerWidgetController::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: RobotViewerGuiPlugin.cpp:367
armarx::RobotViewerWidgetController::robotVisu
SoSeparator * robotVisu
Definition: RobotViewerGuiPlugin.h:144
ArmarXGuiInterface
The main gui interface.
Definition: ArmarXGuiInterface.h:74
armarx::RobotViewerWidgetController::debugDrawer
armarx::DebugDrawerComponentPtr debugDrawer
Definition: RobotViewerGuiPlugin.h:149
IceInternal::Handle< DebugDrawerComponent >
ArmarXGuiPlugin.h
armarx::ArmarXWidgetController::RecursiveMutexPtr
std::shared_ptr< RecursiveMutex > RecursiveMutexPtr
Definition: ArmarXWidgetController.h:256
armarx::RobotViewerWidgetController::rootVisu
SoSeparator * rootVisu
Definition: RobotViewerGuiPlugin.h:143
ArmarXComponentWidgetController.h
armarx::RobotViewerWidgetController::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: RobotViewerGuiPlugin.cpp:111
armarx::RobotViewerWidgetController::~RobotViewerWidgetController
~RobotViewerWidgetController() override
Definition: RobotViewerGuiPlugin.h:94
armarx::RobotViewerWidgetController::showRobot
void showRobot(bool show)
Definition: RobotViewerGuiPlugin.cpp:440
CoinVisualizationPtr
boost::shared_ptr< VirtualRobot::CoinVisualization > CoinVisualizationPtr
Definition: ManipulatorVisualization.h:52
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::RobotViewerWidgetController::configurationChanged
void configurationChanged()
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:917
armarx::RobotViewerWidgetController::timerCB
static void timerCB(void *data, SoSensor *sensor)
Definition: RobotViewerGuiPlugin.cpp:463
armarx::RobotViewerWidgetController::timerSensor
SoTimerSensor * timerSensor
Definition: RobotViewerGuiPlugin.h:146
armarx::RobotViewerWidgetController::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: RobotViewerGuiPlugin.cpp:268
armarx::RobotViewerWidgetController::updateRobotVisu
void updateRobotVisu()
Definition: RobotViewerGuiPlugin.cpp:680
armarx::RobotViewerWidgetController::configured
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
Definition: RobotViewerGuiPlugin.cpp:350
armarx::RobotViewerWidgetController::onConfigurationChanged
void onConfigurationChanged()
Definition: RobotViewerGuiPlugin.cpp:672
armarx::RobotViewerWidgetController::updateStateSettings
void updateStateSettings(int)
Definition: RobotViewerGuiPlugin.cpp:531
Component.h
armarx::RobotViewerWidgetController::robotNodeSetNames
NameList robotNodeSetNames
Definition: RobotViewerGuiPlugin.h:138
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:91
armarx::channels::KinematicUnitObserver::jointAngles
const KinematicUnitDatafieldCreator jointAngles("jointAngles")
armarx::RobotViewerGuiPlugin::RobotViewerGuiPlugin
RobotViewerGuiPlugin()
Definition: RobotViewerGuiPlugin.cpp:86
armarx::RobotViewerWidgetController::robotStatusUpdated
void robotStatusUpdated()
armarx::RobotViewerWidgetController::setRobotVisu
void setRobotVisu(bool colModel)
Definition: RobotViewerGuiPlugin.cpp:374
armarx::RobotViewerWidgetController::getConfigDialog
QPointer< QDialog > getConfigDialog(QWidget *parent=0) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
Definition: RobotViewerGuiPlugin.cpp:338
armarx::RobotViewerWidgetController::robot
VirtualRobot::RobotPtr robot
Definition: RobotViewerGuiPlugin.h:136
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::RobotViewerWidgetController::copyToClipboard
void copyToClipboard()
Definition: RobotViewerGuiPlugin.cpp:536
armarx::RobotViewerWidgetController::showRoot
void showRoot(bool show)
Definition: RobotViewerGuiPlugin.cpp:419
armarx::RobotViewerWidgetController::getScene
SoNode * getScene() override
Reimplementing this function and returning a SoNode* will show this SoNode in the 3DViewerWidget,...
Definition: RobotViewerGuiPlugin.cpp:458
armarx::RobotViewerWidgetController::connectSlots
void connectSlots()
Definition: RobotViewerGuiPlugin.cpp:476
armarx::RobotViewerWidgetController::setMutex3D
void setMutex3D(RecursiveMutexPtr const &mutex3D) override
This mutex is used to protect 3d scene updates. Usually called by the ArmarXGui main window on creati...
Definition: RobotViewerGuiPlugin.cpp:731
armarx::RobotViewerWidgetController::colModel
void colModel(bool c)
Definition: RobotViewerGuiPlugin.cpp:518
armarx::RobotViewerWidgetController::ui
Ui::RobotViewerGuiPlugin ui
Definition: RobotViewerGuiPlugin.h:130
armarx::RobotViewerWidgetController::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: RobotViewerGuiPlugin.cpp:356
armarx::RobotViewerWidgetController::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: RobotViewerGuiPlugin.cpp:157
armarx::RobotViewerWidgetController::reportJointValues
void reportJointValues(const NameValueMap &jointAngles, Ice::Long timestamp, bool aValueChanged, const Ice::Current &) override
Definition: RobotViewerGuiPlugin.cpp:757
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18