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 */
28 
32 
34 #include <RobotAPI/gui-plugins/RobotViewerPlugin/ui_RobotViewerGuiPlugin.h>
36 
37 /* Qt headers */
38 #include <QMainWindow>
39 
40 #include <VirtualRobot/VirtualRobot.h>
41 
42 #include <Inventor/sensors/SoTimerSensor.h>
43 
44 namespace armarx
45 {
46  class RobotViewerConfigDialog;
47 
48  /**
49  \class RobotViewerGuiPlugin
50  \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.
51  Further, DebugDrawer methods are available.
52  \see RobotViewerWidget
53  */
55  {
56  Q_OBJECT
57  Q_INTERFACES(ArmarXGuiInterface)
58  Q_PLUGIN_METADATA(IID "ArmarXGuiInterface/1.00")
59  public:
61 
62  QString
63  getPluginName() override
64  {
65  return "RobotViewerGuiPlugin";
66  }
67  };
68 
69  /**
70  \page RobotAPI-GuiPlugins-RobotViewerPlugin RobotViewerPlugin
71 
72  \brief This widget shows a 3D model of the robot. The robot is articulated and moved according to the corresponding RemoteRobot.
73  Further, DebugDrawer methods are available.
74  \image html RobotViewerGUI.png
75  When you add the widget to the Gui, you need to specify the following parameters:
76 
77  Parameter Name | Example Value | Required? | Description
78  :---------------- | :-------------: | :-------------- |:--------------------
79  Proxy | RobotStateComponent | Yes | The name of the robot state component.
80  */
82  public ArmarXComponentWidgetControllerTemplate<RobotViewerWidgetController>,
83  public RobotStateListenerInterface
84  {
85  Q_OBJECT
86  public:
88 
90  {
91  }
92 
93  // inherited from Component
94  void onInitComponent() override;
95  void onConnectComponent() override;
96  void onDisconnectComponent() override;
97  void onExitComponent() override;
98 
99  // inherited from ArmarXWidget
100  static QString
102  {
103  return "Visualization.RobotViewerGUI";
104  }
105 
106  QPointer<QDialog> getConfigDialog(QWidget* parent = 0) override;
107  void loadSettings(QSettings* settings) override;
108  void saveSettings(QSettings* settings) override;
109  void configured() override;
110 
111  SoNode* getScene() override;
112 
113  // overwrite setMutex, so that we can inform the debugdrawer
114  void setMutex3D(RecursiveMutexPtr const& mutex3D) override;
115 
116  signals:
117  void robotStatusUpdated();
118  void configurationChanged();
119 
120  public slots:
121  void updateRobotVisu();
122  void inflateCollisionModel(int inflationValueMM);
123 
124  protected:
125  void connectSlots();
126 
127 
128  Ui::RobotViewerGuiPlugin ui;
129 
130  bool verbose;
131 
132 
135 
137  NameList robotNodeNames;
138 
140 
141  SoSeparator* rootVisu;
142  SoSeparator* robotVisu;
143 
144  SoTimerSensor* timerSensor;
145 
146  SoSeparator* debugLayerVisu;
148 
149  static void timerCB(void* data, SoSensor* sensor);
150  void setRobotVisu(bool colModel);
151 
152  protected slots:
153  void showVisuLayers(bool show);
154  void showRoot(bool show);
155  void showRobot(bool show);
156  void colModel(bool c);
157 
158  void updateStateSettings(int);
159  void copyToClipboard();
160  void updateState();
161  void onConfigurationChanged();
162 
163  private:
164  // init stuff
165  VirtualRobot::RobotPtr loadRobotFile(std::string fileName);
166 
168 
169  QPointer<QWidget> __widget;
170  QPointer<SimpleConfigDialog> dialog;
171 
172  // ArmarXWidgetController interface
173  public:
174  static QIcon
176  {
177  return QIcon(":icons/armarx-gui.png");
178  }
179 
180  // RobotStateListenerInterface interface
181  public:
182  void reportGlobalRobotRootPose(const FramedPoseBasePtr& pose,
184  bool poseChanged,
185  const Ice::Current&) override;
188  bool aValueChanged,
189  const Ice::Current&) override;
190  };
191 
192  using RobotViewerGuiPluginPtr = std::shared_ptr<RobotViewerWidgetController>;
193 } // namespace armarx
DebugDrawerComponent.h
armarx::ArmarXWidgetController::mutex3D
std::shared_ptr< std::recursive_mutex > mutex3D
Definition: ArmarXWidgetController.h:309
armarx::RobotViewerWidgetController
Definition: RobotViewerGuiPlugin.h:81
armarx::RobotViewerWidgetController::robotStateComponentName
std::string robotStateComponentName
Definition: RobotViewerGuiPlugin.h:139
RemoteRobot.h
armarx::RobotViewerWidgetController::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: RobotViewerGuiPlugin.cpp:304
armarx::RobotViewerWidgetController::RobotViewerWidgetController
RobotViewerWidgetController()
Definition: RobotViewerGuiPlugin.cpp:96
armarx::RobotViewerGuiPlugin
This plugin provides a generic widget showing a 3D model of the robot. The robot is articulated and m...
Definition: RobotViewerGuiPlugin.h:54
armarx::RobotViewerWidgetController::reportGlobalRobotRootPose
void reportGlobalRobotRootPose(const FramedPoseBasePtr &pose, Ice::Long timestamp, bool poseChanged, const Ice::Current &) override
Definition: RobotViewerGuiPlugin.cpp:797
armarx::RobotViewerWidgetController::showVisuLayers
void showVisuLayers(bool show)
Definition: RobotViewerGuiPlugin.cpp:416
armarx::RobotViewerWidgetController::updateState
void updateState()
Definition: RobotViewerGuiPlugin.cpp:650
armarx::RobotViewerWidgetController::GetWidgetName
static QString GetWidgetName()
Definition: RobotViewerGuiPlugin.h:101
armarx::ArmarXGuiPlugin
Definition: ArmarXGuiPlugin.h:46
armarx::RobotViewerGuiPlugin::getPluginName
QString getPluginName() override
Definition: RobotViewerGuiPlugin.h:63
armarx::RobotViewerWidgetController::inflateCollisionModel
void inflateCollisionModel(int inflationValueMM)
Definition: RobotViewerGuiPlugin.cpp:772
armarx::RobotViewerGuiPluginPtr
std::shared_ptr< RobotViewerWidgetController > RobotViewerGuiPluginPtr
Definition: RobotViewerGuiPlugin.h:192
armarx::RobotViewerWidgetController::robotStateComponentPrx
RobotStateComponentInterfacePrx robotStateComponentPrx
Definition: RobotViewerGuiPlugin.h:133
armarx::RobotViewerWidgetController::GetWidgetIcon
static QIcon GetWidgetIcon()
Definition: RobotViewerGuiPlugin.h:175
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::RobotViewerWidgetController::verbose
bool verbose
Definition: RobotViewerGuiPlugin.h:130
armarx::RobotViewerWidgetController::robotNodeNames
NameList robotNodeNames
Definition: RobotViewerGuiPlugin.h:137
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
SimpleConfigDialog.h
armarx::RobotViewerWidgetController::debugLayerVisu
SoSeparator * debugLayerVisu
Definition: RobotViewerGuiPlugin.h:146
armarx::RobotViewerWidgetController::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: RobotViewerGuiPlugin.cpp:377
armarx::RobotViewerWidgetController::robotVisu
SoSeparator * robotVisu
Definition: RobotViewerGuiPlugin.h:142
ArmarXGuiInterface
The main gui interface.
Definition: ArmarXGuiInterface.h:80
armarx::RobotViewerWidgetController::debugDrawer
armarx::DebugDrawerComponentPtr debugDrawer
Definition: RobotViewerGuiPlugin.h:147
IceInternal::Handle< DebugDrawerComponent >
ArmarXGuiPlugin.h
armarx::ArmarXWidgetController::RecursiveMutexPtr
std::shared_ptr< RecursiveMutex > RecursiveMutexPtr
Definition: ArmarXWidgetController.h:262
armarx::RobotViewerWidgetController::rootVisu
SoSeparator * rootVisu
Definition: RobotViewerGuiPlugin.h:141
ArmarXComponentWidgetController.h
armarx::RobotViewerWidgetController::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: RobotViewerGuiPlugin.cpp:112
armarx::RobotViewerWidgetController::~RobotViewerWidgetController
~RobotViewerWidgetController() override
Definition: RobotViewerGuiPlugin.h:89
armarx::RobotViewerWidgetController::showRobot
void showRobot(bool show)
Definition: RobotViewerGuiPlugin.cpp:454
CoinVisualizationPtr
boost::shared_ptr< VirtualRobot::CoinVisualization > CoinVisualizationPtr
Definition: ManipulatorVisualization.h:56
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::RobotViewerWidgetController::configurationChanged
void configurationChanged()
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:918
armarx::RobotViewerWidgetController::timerCB
static void timerCB(void *data, SoSensor *sensor)
Definition: RobotViewerGuiPlugin.cpp:480
timestamp
std::string timestamp()
Definition: CartographerAdapter.cpp:85
armarx::RobotViewerWidgetController::timerSensor
SoTimerSensor * timerSensor
Definition: RobotViewerGuiPlugin.h:144
armarx::RobotViewerWidgetController::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: RobotViewerGuiPlugin.cpp:273
armarx::RobotViewerWidgetController::updateRobotVisu
void updateRobotVisu()
Definition: RobotViewerGuiPlugin.cpp:732
armarx::RobotViewerWidgetController::configured
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
Definition: RobotViewerGuiPlugin.cpp:356
armarx::RobotViewerWidgetController::onConfigurationChanged
void onConfigurationChanged()
Definition: RobotViewerGuiPlugin.cpp:723
armarx::RobotViewerWidgetController::updateStateSettings
void updateStateSettings(int)
Definition: RobotViewerGuiPlugin.cpp:572
Component.h
armarx::RobotViewerWidgetController::robotNodeSetNames
NameList robotNodeSetNames
Definition: RobotViewerGuiPlugin.h:136
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:88
armarx::channels::KinematicUnitObserver::jointAngles
const KinematicUnitDatafieldCreator jointAngles("jointAngles")
armarx::RobotViewerGuiPlugin::RobotViewerGuiPlugin
RobotViewerGuiPlugin()
Definition: RobotViewerGuiPlugin.cpp:91
armarx::RobotViewerWidgetController::robotStatusUpdated
void robotStatusUpdated()
armarx::RobotViewerWidgetController::setRobotVisu
void setRobotVisu(bool colModel)
Definition: RobotViewerGuiPlugin.cpp:385
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:344
armarx::RobotViewerWidgetController::robot
VirtualRobot::RobotPtr robot
Definition: RobotViewerGuiPlugin.h:134
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::RobotViewerWidgetController::copyToClipboard
void copyToClipboard()
Definition: RobotViewerGuiPlugin.cpp:578
armarx::RobotViewerWidgetController::showRoot
void showRoot(bool show)
Definition: RobotViewerGuiPlugin.cpp:432
armarx::RobotViewerWidgetController::getScene
SoNode * getScene() override
Reimplementing this function and returning a SoNode* will show this SoNode in the 3DViewerWidget,...
Definition: RobotViewerGuiPlugin.cpp:474
armarx::RobotViewerWidgetController::connectSlots
void connectSlots()
Definition: RobotViewerGuiPlugin.cpp:493
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:785
armarx::RobotViewerWidgetController::colModel
void colModel(bool c)
Definition: RobotViewerGuiPlugin.cpp:558
armarx::RobotViewerWidgetController::ui
Ui::RobotViewerGuiPlugin ui
Definition: RobotViewerGuiPlugin.h:128
armarx::RobotViewerWidgetController::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: RobotViewerGuiPlugin.cpp:362
armarx::RobotViewerWidgetController::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: RobotViewerGuiPlugin.cpp:160
armarx::RobotViewerWidgetController::reportJointValues
void reportJointValues(const NameValueMap &jointAngles, Ice::Long timestamp, bool aValueChanged, const Ice::Current &) override
Definition: RobotViewerGuiPlugin.cpp:816
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19