hpp-gui  4.12.0
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 
29  class HppWidgetsPlugin : public QObject, public gepetto::gui::PluginInterface,
30  public gepetto::gui::ModelInterface, public gepetto::gui::ConnectionInterface
31  {
32  Q_OBJECT
33  Q_INTERFACES (gepetto::gui::PluginInterface
34  gepetto::gui::ModelInterface
35  gepetto::gui::ConnectionInterface)
36 
37 #if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
38  Q_PLUGIN_METADATA (IID "hpp-gui.hppwidgetsplugin")
39 #endif
40 
41  public:
42  struct JointElement {
43  std::string name, prefix;
44  // FIXME sort this vector.
45  std::vector<std::string> bodyNames;
46  JointTreeItem* item;
47  std::vector<bool> updateViewer;
48 
49  JointElement ()
50  : name (), bodyNames (), item (NULL), updateViewer (0, false) {}
51  JointElement (const std::string& n,
52  const std::string& prefix,
53  const std::vector<std::string>& bns,
54  JointTreeItem* i,
55  bool updateV = true)
56  : name (n), prefix (prefix), bodyNames (bns), item (i),
57  updateViewer (bns.size(), updateV) {}
58  JointElement (const std::string& n, const std::string& prefix,
59  const hpp::Names_t& bns, JointTreeItem* i, bool updateV = true);
60  };
61  typedef QMap <std::string, JointElement> JointMap;
62  typedef hpp::corbaServer::Client HppClient;
63 
64  explicit HppWidgetsPlugin ();
65 
66  virtual ~HppWidgetsPlugin ();
67 
68  // PluginInterface interface
69  public:
71  void init();
72 
74  QString name() const;
75 
76  // ModelInterface interface
77  public:
80  void loadRobotModel (gepetto::gui::DialogLoadRobot::RobotDefinition rd);
81 
84  void loadEnvironmentModel (gepetto::gui::DialogLoadEnvironment::EnvironmentDefinition ed);
85 
90  std::string getBodyFromJoint (const std::string& jointName) const;
91 
92  const hpp::floatSeq& currentConfig () const
93  {
94  return config_;
95  }
96 
97  hpp::floatSeq& currentConfig ()
98  {
99  return config_;
100  }
101 
102  const hpp::floatSeq& currentVelocity () const
103  {
104  return velocity_;
105  }
106 
107  hpp::floatSeq& currentVelocity ()
108  {
109  return velocity_;
110  }
111 
112 signals:
113  void configurationValidationStatus (bool valid);
114  void configurationValidationStatus (QStringList collision);
115 
116  // ConnectionInterface interface
117  public:
119  virtual void openConnection ();
120 
122  virtual void closeConnection ();
123 signals:
125  void logJobFailed (int id, const QString& text) const;
126 
127  public slots:
130 
131  void setCurrentConfig (const hpp::floatSeq& q);
132 
133  hpp::floatSeq const* getCurrentConfig () const;
134 
135  void setCurrentQtConfig (const QVector<double>& q);
136 
137  QVector<double> getCurrentQtConfig () const;
138 
140  void fetchConfiguration ();
141 
143  void sendConfiguration ();
144 
146  void configurationValidation ();
147 
150  void selectJointFromBodyName (const QString bodyName);
151 
152  void update();
153 
155  QString requestCreateJointGroup(const QString jn);
156 
158  QString requestCreateComGroup(const QString com);
159 
160  QString getHppIIOPurl () const;
161 
162  QString getHppContext () const;
163 
164  public:
166  HppClient* client () const;
167 
169  JointMap& jointMap ();
170 
172  PathPlayer* pathPlayer() const;
173 
176 
179  virtual void updateRobotJoints (const QString robotName);
180 
182  std::string getSelectedJoint () const;
183 
186  virtual Roadmap* createRoadmap (const std::string& jointName);
187 
188  signals:
189  void logSuccess (const QString& text);
190  void logFailure (const QString& text);
191 
192  protected slots:
195  virtual void displayRoadmap (const std::string& jointName);
196 
199  void addJointFrame (const std::string& jointName);
200 
201  private:
202  void prepareApplyConfiguration ();
203 
204  PathPlayer* pathPlayer_;
205  SolverWidget* solverWidget_;
206  ConfigurationListWidget* configListWidget_;
207 
208  HppClient* hpp_;
209 
210  protected:
213  static std::string escapeJointName (const std::string jn);
214 
217  std::string createJointGroup (const std::string jn);
218 
221  std::string createComGroup (const std::string com);
222 
224  void computeObjectPosition();
225 
226  virtual void loadConstraintWidget();
227 
228  QList <QDockWidget*> dockWidgets_;
231  JointMap jointMap_;
232  hpp::Names_t jointFrames_;
233  std::list <std::string> comFrames_;
234 
235  hpp::floatSeq config_, velocity_;
236 
237  // Cache variables
238  hpp::Names_t linkNames_;
239  std::vector<std::string> bodyNames_;
240  std::vector<gepetto::viewer::Configuration> bodyConfs_;
241  std::vector<std::string> jointGroupNames_;
242  };
243  } // namespace gui
244 } // namespace hpp
245 
246 #endif // HPP_GUI_HPPWIDGETSPLUGIN_HH
Definition: roadmap.hh:16
Definition: pathplayer.hh:28
virtual void closeConnection()
Close connection to corbaserver.
void configurationValidation()
Build a list of bodies in collision.
hpp::Names_t linkNames_
Definition: hppwidgetsplugin.hh:238
hpp::Names_t jointFrames_
Definition: hppwidgetsplugin.hh:232
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:228
const hpp::floatSeq & currentConfig() const
Definition: hppwidgetsplugin.hh:92
QString getHppIIOPurl() const
Definition: jointtreewidget.hh:19
hpp::floatSeq & currentVelocity()
Definition: hppwidgetsplugin.hh:107
hpp::floatSeq & currentConfig()
Definition: hppwidgetsplugin.hh:97
std::list< std::string > comFrames_
Definition: hppwidgetsplugin.hh:233
virtual void openConnection()
Open a connection to a corba server.
Definition: joint-tree-item.hh:25
std::vector< std::string > jointGroupNames_
Definition: hppwidgetsplugin.hh:241
Definition: solverwidget.hh:23
void setCurrentQtConfig(const QVector< double > &q)
const hpp::floatSeq & currentVelocity() const
Definition: hppwidgetsplugin.hh:102
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:239
hpp::floatSeq velocity_
Definition: hppwidgetsplugin.hh:235
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:29
hpp::floatSeq config_
Definition: hppwidgetsplugin.hh:235
CORBA::String_var to_corba(const QString &s)
Definition: hppwidgetsplugin.hh:25
virtual void displayRoadmap(const std::string &jointName)
JointMap jointMap_
Definition: hppwidgetsplugin.hh:231
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:240
JointTreeWidget * jointTreeWidget_
Definition: hppwidgetsplugin.hh:229
std::string getSelectedJoint() const
Get the currently selected joint name.
ConstraintWidget * constraintWidget_
Definition: hppwidgetsplugin.hh:230
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:29
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.