RobotVisuWidget.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  * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
17  * @date 2021
18  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19  * GNU General Public License
20  */
21 
22 #pragma once
23 
24 #include <map>
25 #include <memory>
26 #include <optional>
27 #include <string>
28 
29 #include <QWidget>
30 #include <qobjectdefs.h>
31 #include <qwidget.h>
32 
33 #include <Eigen/Core>
34 
35 #include <VirtualRobot/VirtualRobot.h>
36 
38 
39 
40 class QCheckBox;
41 class QLabel;
42 class QPushButton;
43 
44 namespace VirtualRobot
45 {
46  using RobotPtr = std::shared_ptr<class Robot>;
47 }
48 
49 namespace IceInternal
50 {
51  template <typename T>
52  class ProxyHandle;
53 }
54 
55 namespace IceProxy::armarx
56 {
57  class RobotStateComponentInterface;
58 }
59 
60 namespace armarx
61 {
62  class ManagedIceObject;
65 } // namespace armarx
66 
67 namespace armarx::viz
68 {
69  class Robot;
70 }
71 
73 {
74 
75  class SettingsWidget : public QWidget
76  {
77  Q_OBJECT
78  using This = SettingsWidget;
79 
80  public:
81  SettingsWidget(QWidget* parent = nullptr);
82 
83 
84  bool isEnabled() const;
85  bool useCollisionModel() const;
86 
87 
88  signals:
89 
90  void changed();
91 
92 
93  private:
94  QCheckBox* _enabled = nullptr;
95  QCheckBox* _collisionModel = nullptr;
96  };
97 
98  class Connection
99  {
100  public:
101  Connection(RobotStateComponentInterfacePrx robotStateComponent,
102  robotvisu::SettingsWidget* settings);
103  ~Connection();
104 
105 
107  std::string getConnectedName() const;
108 
109 
110  core::Pose getGlobalPose(bool synchronize = true);
111  std::map<std::string, float> getJointValues(bool synchronize = true);
112 
113  viz::Robot vizRobot(const std::string& id, bool synchronize = true);
114 
115 
116  private:
117  void _synchronize(bool synchronize);
118 
119  std::unique_ptr<RobotStateComponentInterfacePrx> _robotStateComponent;
120  robotvisu::SettingsWidget* _settings = nullptr;
121 
122  std::string _filename;
123  VirtualRobot::RobotPtr _robot;
124  };
125 
126 } // namespace armarx::navigation::qt_plugins::location_graph_editor::robotvisu
127 
129 {
130 
131  class RobotVisuWidget : public QWidget
132  {
133  Q_OBJECT
134  using This = RobotVisuWidget;
135 
136  public:
137  RobotVisuWidget(ManagedIceObject& component, QWidget* parent = nullptr);
138 
139 
140  /// Indicates whether the connection is established and visu is enabled.
141  bool isEnabled() const;
142 
143  bool isConnected() const;
145 
146 
147  signals:
148 
149  void connected();
150  void settingsChanged();
151 
152 
153  public slots:
154 
155  void connectToRobot();
156 
157 
158  private:
159  ManagedIceObject& _component;
160  std::optional<robotvisu::Connection> _connection;
161 
162  QLabel* _statusLabel = nullptr;
163  QPushButton* _connectButton = nullptr;
164  robotvisu::SettingsWidget* _settings = nullptr;
165  };
166 
167 } // namespace armarx::navigation::qt_plugins::location_graph_editor
armarx::navigation::qt_plugins::location_graph_editor::robotvisu::Connection::vizRobot
viz::Robot vizRobot(const std::string &id, bool synchronize=true)
Definition: RobotVisuWidget.cpp:122
armarx::navigation::qt_plugins::location_graph_editor::RobotVisuWidget::settingsChanged
void settingsChanged()
armarx::navigation::qt_plugins::location_graph_editor::RobotVisuWidget::connectToRobot
void connectToRobot()
Definition: RobotVisuWidget.cpp:209
armarx::navigation::qt_plugins::location_graph_editor::RobotVisuWidget::isEnabled
bool isEnabled() const
Indicates whether the connection is established and visu is enabled.
Definition: RobotVisuWidget.cpp:191
IceProxy::armarx
Definition: LogSender.h:38
armarx::navigation::qt_plugins::location_graph_editor::RobotVisuWidget::connection
robotvisu::Connection & connection()
Definition: RobotVisuWidget.cpp:203
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
basic_types.h
armarx::ProxyType::component
@ component
VirtualRobot
Definition: FramedPose.h:42
armarx::navigation::qt_plugins::location_graph_editor::robotvisu::Connection
Definition: RobotVisuWidget.h:98
armarx::navigation::qt_plugins::location_graph_editor::robotvisu::Connection::Connection
Connection(RobotStateComponentInterfacePrx robotStateComponent, robotvisu::SettingsWidget *settings)
Definition: RobotVisuWidget.cpp:90
armarx::navigation::qt_plugins::location_graph_editor::robotvisu::SettingsWidget::SettingsWidget
SettingsWidget(QWidget *parent=nullptr)
Definition: RobotVisuWidget.cpp:57
armarx::navigation::qt_plugins::location_graph_editor::robotvisu::SettingsWidget::useCollisionModel
bool useCollisionModel() const
Definition: RobotVisuWidget.cpp:85
armarx::navigation::qt_plugins::location_graph_editor::robotvisu::Connection::getJointValues
std::map< std::string, float > getJointValues(bool synchronize=true)
Definition: RobotVisuWidget.cpp:115
armarx::navigation::qt_plugins::location_graph_editor::RobotVisuWidget::isConnected
bool isConnected() const
Definition: RobotVisuWidget.cpp:197
armarx::navigation::qt_plugins::location_graph_editor::robotvisu::SettingsWidget::changed
void changed()
armarx::navigation::qt_plugins::location_graph_editor::robotvisu::SettingsWidget
Definition: RobotVisuWidget.h:75
armarx::RobotStateComponentInterfacePrx
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
Definition: RobotVisuWidget.h:64
armarx::armem::human::Robot
@ Robot
Definition: util.h:17
armarx::navigation::qt_plugins::location_graph_editor::RobotVisuWidget::RobotVisuWidget
RobotVisuWidget(ManagedIceObject &component, QWidget *parent=nullptr)
Definition: RobotVisuWidget.cpp:157
armarx::navigation::qt_plugins::location_graph_editor::RobotVisuWidget
Definition: RobotVisuWidget.h:131
armarx::navigation::qt_plugins::location_graph_editor::robotvisu::Connection::~Connection
~Connection()
Definition: RobotVisuWidget.cpp:103
armarx::navigation::qt_plugins::location_graph_editor::robotvisu::Connection::getConnectedName
std::string getConnectedName() const
Definition: RobotVisuWidget.cpp:143
armarx::viz::Robot
Definition: Robot.h:10
armarx::navigation::qt_plugins::location_graph_editor
Definition: GuiGraph.cpp:34
IceInternal
This file is part of ArmarX.
Definition: InstrumentationI.h:16
armarx::navigation::qt_plugins::location_graph_editor::robotvisu::Connection::getGlobalPose
core::Pose getGlobalPose(bool synchronize=true)
Definition: RobotVisuWidget.cpp:108
armarx::ManagedIceObject
The ManagedIceObject is the base class for all ArmarX objects.
Definition: ManagedIceObject.h:162
armarx::navigation::qt_plugins::location_graph_editor::robotvisu::Connection::getRobotStateComponent
RobotStateComponentInterfacePrx getRobotStateComponent() const
Definition: RobotVisuWidget.cpp:136
armarx::navigation::qt_plugins::location_graph_editor::robotvisu::SettingsWidget::isEnabled
bool isEnabled() const
Definition: RobotVisuWidget.cpp:79
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::navigation::qt_plugins::location_graph_editor::RobotVisuWidget::connected
void connected()
armarx::viz
This file is part of ArmarX.
Definition: ArVizStorage.cpp:418
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
armarx::navigation::qt_plugins::location_graph_editor::robotvisu
Definition: RobotVisuWidget.h:72