hpp-gui  4.15.1
Graphical interface for HPP
hppwidgetsplugin.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) CNRS
3 // Author: Joseph Mirabel and Heidy Dallard
4 //
5 
6 #ifndef HPP_GUI_HPPWIDGETSPLUGIN_HH
7 #define HPP_GUI_HPPWIDGETSPLUGIN_HH
8 
9 #include <gepetto/gui/plugin-interface.hh>
10 #include <gepetto/gui/windows-manager.hh>
11 #include <hpp/corbaserver/client.hh>
12 
13 class QDockWidget;
14 
15 namespace hpp {
16 namespace gui {
17 class SolverWidget;
18 class PathPlayer;
19 class JointTreeWidget;
20 class ConfigurationListWidget;
21 class JointTreeItem;
22 class Roadmap;
23 class ConstraintWidget;
24 
25 inline CORBA::String_var to_corba(const QString& s) {
26  return (const char*)s.toLocal8Bit().data();
27 }
28 
30 class HppWidgetsPlugin : public QObject,
31  public gepetto::gui::PluginInterface,
32  public gepetto::gui::ModelInterface,
33  public gepetto::gui::ConnectionInterface {
34  Q_OBJECT
35  Q_INTERFACES(gepetto::gui::PluginInterface gepetto::gui::ModelInterface
36  gepetto::gui::ConnectionInterface)
37 
38 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
39  Q_PLUGIN_METADATA(IID "hpp-gui.hppwidgetsplugin")
40 #endif
41 
42  public:
43  struct JointElement {
44  std::string name, prefix;
45  // FIXME sort this vector.
46  std::vector<std::string> bodyNames;
47  JointTreeItem* item;
48  std::vector<bool> updateViewer;
49 
50  JointElement() : name(), bodyNames(), item(NULL), updateViewer(0, false) {}
51  JointElement(const std::string& n, const std::string& prefix,
52  const std::vector<std::string>& bns, JointTreeItem* i,
53  bool updateV = true)
54  : name(n),
55  prefix(prefix),
56  bodyNames(bns),
57  item(i),
58  updateViewer(bns.size(), updateV) {}
59  JointElement(const std::string& n, const std::string& prefix,
60  const hpp::Names_t& bns, JointTreeItem* i,
61  bool updateV = true);
62  };
63  typedef QMap<std::string, JointElement> JointMap;
64  typedef hpp::corbaServer::Client HppClient;
65 
66  explicit HppWidgetsPlugin();
67 
68  virtual ~HppWidgetsPlugin();
69 
70  // PluginInterface interface
71  public:
73  void init();
74 
76  QString name() const;
77 
78  // ModelInterface interface
79  public:
82  void loadRobotModel(gepetto::gui::DialogLoadRobot::RobotDefinition rd);
83 
87  gepetto::gui::DialogLoadEnvironment::EnvironmentDefinition ed);
88 
93  std::string getBodyFromJoint(const std::string& jointName) const;
94 
95  const hpp::floatSeq& currentConfig() const { return config_; }
96 
97  hpp::floatSeq& currentConfig() { return config_; }
98 
99  const hpp::floatSeq& currentVelocity() const { return velocity_; }
100 
101  hpp::floatSeq& currentVelocity() { return velocity_; }
102 
103  signals:
104  void configurationValidationStatus(bool valid);
105  void configurationValidationStatus(QStringList collision);
106 
107  // ConnectionInterface interface
108  public:
110  virtual void openConnection();
111 
113  virtual void closeConnection();
114  signals:
116  void logJobFailed(int id, const QString& text) const;
117 
118  public slots:
121 
122  void setCurrentConfig(const hpp::floatSeq& q);
123 
124  hpp::floatSeq const* getCurrentConfig() const;
125 
126  void setCurrentQtConfig(const QVector<double>& q);
127 
128  QVector<double> getCurrentQtConfig() const;
129 
131  void fetchConfiguration();
132 
134  void sendConfiguration();
135 
138 
141  void selectJointFromBodyName(const QString bodyName);
142 
143  void update();
144 
146  QString requestCreateJointGroup(const QString jn);
147 
149  QString requestCreateComGroup(const QString com);
150 
151  QString getHppIIOPurl() const;
152 
153  QString getHppContext() const;
154 
155  public:
157  HppClient* client() const;
158 
160  JointMap& jointMap();
161 
163  PathPlayer* pathPlayer() const;
164 
167 
170  virtual void updateRobotJoints(const QString robotName);
171 
173  std::string getSelectedJoint() const;
174 
177  virtual Roadmap* createRoadmap(const std::string& jointName);
178 
179  signals:
180  void logSuccess(const QString& text);
181  void logFailure(const QString& text);
182 
183  protected slots:
186  virtual void displayRoadmap(const std::string& jointName);
187 
190  void addJointFrame(const std::string& jointName);
191 
192  private:
193  void prepareApplyConfiguration();
194 
195  PathPlayer* pathPlayer_;
196  SolverWidget* solverWidget_;
197  ConfigurationListWidget* configListWidget_;
198 
199  HppClient* hpp_;
200 
201  protected:
204  static std::string escapeJointName(const std::string jn);
205 
208  std::string createJointGroup(const std::string jn);
209 
212  std::string createComGroup(const std::string com);
213 
215  void computeObjectPosition();
216 
217  virtual void loadConstraintWidget();
218 
219  QList<QDockWidget*> dockWidgets_;
222  JointMap jointMap_;
223  hpp::Names_t jointFrames_;
224  std::list<std::string> comFrames_;
225 
226  hpp::floatSeq config_, velocity_;
227 
228  // Cache variables
229  hpp::Names_t linkNames_;
230  std::vector<std::string> bodyNames_;
231  std::vector<gepetto::viewer::Configuration> bodyConfs_;
232  std::vector<std::string> jointGroupNames_;
233 };
234 } // namespace gui
235 } // namespace hpp
236 
237 #endif // HPP_GUI_HPPWIDGETSPLUGIN_HH
Definition: roadmap.hh:16
Definition: pathplayer.hh:27
virtual void closeConnection()
Close connection to corbaserver.
void configurationValidation()
Build a list of bodies in collision.
hpp::Names_t linkNames_
Definition: hppwidgetsplugin.hh:229
hpp::Names_t jointFrames_
Definition: hppwidgetsplugin.hh:223
virtual void loadConstraintWidget()
HppClient * client() const
Get the corbaserver client.
namespace that encapsulate all the softwares of humanoid-path-planner
Definition: __init__.py:1
virtual void updateRobotJoints(const QString robotName)
QList< QDockWidget * > dockWidgets_
Definition: hppwidgetsplugin.hh:219
const hpp::floatSeq & currentConfig() const
Definition: hppwidgetsplugin.hh:95
QString getHppIIOPurl() const
Definition: jointtreewidget.hh:18
hpp::floatSeq & currentVelocity()
Definition: hppwidgetsplugin.hh:101
hpp::floatSeq & currentConfig()
Definition: hppwidgetsplugin.hh:97
std::list< std::string > comFrames_
Definition: hppwidgetsplugin.hh:224
virtual void openConnection()
Open a connection to a corba server.
Definition: joint-tree-item.hh:26
std::vector< std::string > jointGroupNames_
Definition: hppwidgetsplugin.hh:232
Definition: solverwidget.hh:23
void setCurrentQtConfig(const QVector< double > &q)
const hpp::floatSeq & currentVelocity() const
Definition: hppwidgetsplugin.hh:99
void configurationValidationStatus(bool valid)
void init()
Initialize the plugin.
void setCurrentConfig(const hpp::floatSeq &q)
void logJobFailed(int id, const QString &text) const
Log the failure of a job in the MainWindow.
void selectJointFromBodyName(const QString bodyName)
QString getHppContext() const
QString requestCreateJointGroup(const QString jn)
See createJointGroup.
virtual Roadmap * createRoadmap(const std::string &jointName)
QVector< double > getCurrentQtConfig() const
hpp::floatSeq const * getCurrentConfig() const
void loadRobotModel(gepetto::gui::DialogLoadRobot::RobotDefinition rd)
std::vector< std::string > bodyNames_
Definition: hppwidgetsplugin.hh:230
hpp::floatSeq velocity_
Definition: hppwidgetsplugin.hh:226
QString requestCreateComGroup(const QString com)
See createComGroup.
std::string getBodyFromJoint(const std::string &jointName) const
JointMap & jointMap()
Get the jointMap.
static std::string escapeJointName(const std::string jn)
void fetchConfiguration()
Set internal configuration from HPP current config.
void logSuccess(const QString &text)
JointTreeWidget * jointTreeWidget() const
Get the pathPlayer widget.
Widget to define initial and goal configurations of the problem.
Definition: configurationlistwidget.hh:27
hpp::floatSeq config_
Definition: hppwidgetsplugin.hh:226
CORBA::String_var to_corba(const QString &s)
Definition: hppwidgetsplugin.hh:25
virtual void displayRoadmap(const std::string &jointName)
JointMap jointMap_
Definition: hppwidgetsplugin.hh:222
void loadEnvironmentModel(gepetto::gui::DialogLoadEnvironment::EnvironmentDefinition ed)
std::string createComGroup(const std::string com)
void computeObjectPosition()
Replace all the bodies according to their position in hpp.
Widget that allows to create constraints.
Definition: constraintwidget.hh:24
std::vector< gepetto::viewer::Configuration > bodyConfs_
Definition: hppwidgetsplugin.hh:231
JointTreeWidget * jointTreeWidget_
Definition: hppwidgetsplugin.hh:220
std::string getSelectedJoint() const
Get the currently selected joint name.
ConstraintWidget * constraintWidget_
Definition: hppwidgetsplugin.hh:221
QString name() const
Returns the plugin&#39;s name.
PathPlayer * pathPlayer() const
Get the pathPlayer widget.
Plugin that add a lot of features to work with hpp.
Definition: hppwidgetsplugin.hh:30
void sendConfiguration()
Set HPP configuration to internal current configuration.
std::string createJointGroup(const std::string jn)
void logFailure(const QString &text)
void addJointFrame(const std::string &jointName)
void applyCurrentConfiguration()
Apply the current configuration of the robot.