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