hpp-gui  4.11.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
hpp.gui::HppWidgetsPlugin::client
HppClient * client() const
Get the corbaserver client.
hpp.gui::HppWidgetsPlugin::jointMap_
JointMap jointMap_
Definition: hppwidgetsplugin.hh:231
hpp.gui::HppWidgetsPlugin::pathPlayer
PathPlayer * pathPlayer() const
Get the pathPlayer widget.
hpp.gui::HppWidgetsPlugin::openConnection
virtual void openConnection()
Open a connection to a corba server.
hpp.gui::HppWidgetsPlugin::setCurrentQtConfig
void setCurrentQtConfig(const QVector< double > &q)
hpp.gui::HppWidgetsPlugin::name
QString name() const
Returns the plugin's name.
hpp.gui::HppWidgetsPlugin::configurationValidation
void configurationValidation()
Build a list of bodies in collision.
hpp.gui::to_corba
CORBA::String_var to_corba(const QString &s)
Definition: hppwidgetsplugin.hh:25
hpp.gui::HppWidgetsPlugin::currentVelocity
const hpp::floatSeq & currentVelocity() const
Definition: hppwidgetsplugin.hh:102
hpp.gui::HppWidgetsPlugin::getCurrentQtConfig
QVector< double > getCurrentQtConfig() const
hpp.gui::HppWidgetsPlugin::bodyNames_
std::vector< std::string > bodyNames_
Definition: hppwidgetsplugin.hh:239
hpp.gui::HppWidgetsPlugin::velocity_
hpp::floatSeq velocity_
Definition: hppwidgetsplugin.hh:235
hpp.gui::HppWidgetsPlugin::setCurrentConfig
void setCurrentConfig(const hpp::floatSeq &q)
hpp.gui::HppWidgetsPlugin::dockWidgets_
QList< QDockWidget * > dockWidgets_
Definition: hppwidgetsplugin.hh:228
hpp.gui::HppWidgetsPlugin::currentConfig
const hpp::floatSeq & currentConfig() const
Definition: hppwidgetsplugin.hh:92
hpp.gui::HppWidgetsPlugin::getHppIIOPurl
QString getHppIIOPurl() const
hpp.gui::HppWidgetsPlugin::requestCreateJointGroup
QString requestCreateJointGroup(const QString jn)
See createJointGroup.
hpp.gui::JointTreeItem
Definition: joint-tree-item.hh:25
hpp.gui::HppWidgetsPlugin::currentConfig
hpp::floatSeq & currentConfig()
Definition: hppwidgetsplugin.hh:97
hpp.gui::HppWidgetsPlugin::getCurrentConfig
hpp::floatSeq const * getCurrentConfig() const
hpp.gui::ConfigurationListWidget
Widget to define initial and goal configurations of the problem.
Definition: configurationlistwidget.hh:29
hpp.gui::HppWidgetsPlugin::currentVelocity
hpp::floatSeq & currentVelocity()
Definition: hppwidgetsplugin.hh:107
hpp.gui::HppWidgetsPlugin::jointGroupNames_
std::vector< std::string > jointGroupNames_
Definition: hppwidgetsplugin.hh:241
hpp.gui::HppWidgetsPlugin::requestCreateComGroup
QString requestCreateComGroup(const QString com)
See createComGroup.
hpp.gui::HppWidgetsPlugin::fetchConfiguration
void fetchConfiguration()
Set internal configuration from HPP current config.
hpp.gui::HppWidgetsPlugin::displayRoadmap
virtual void displayRoadmap(const std::string &jointName)
hpp.gui::HppWidgetsPlugin::logSuccess
void logSuccess(const QString &text)
hpp
namespace that encapsulate all the softwares of humanoid-path-planner
Definition: __init__.py:1
hpp.gui::HppWidgetsPlugin::config_
hpp::floatSeq config_
Definition: hppwidgetsplugin.hh:235
hpp.gui::HppWidgetsPlugin::logJobFailed
void logJobFailed(int id, const QString &text) const
Log the failure of a job in the MainWindow.
hpp.gui::HppWidgetsPlugin::comFrames_
std::list< std::string > comFrames_
Definition: hppwidgetsplugin.hh:233
hpp.gui::HppWidgetsPlugin::init
void init()
Initialize the plugin.
hpp.gui::HppWidgetsPlugin::jointTreeWidget
JointTreeWidget * jointTreeWidget() const
Get the pathPlayer widget.
hpp.gui::HppWidgetsPlugin::computeObjectPosition
void computeObjectPosition()
Replace all the bodies according to their position in hpp.
hpp.gui::HppWidgetsPlugin::getSelectedJoint
std::string getSelectedJoint() const
Get the currently selected joint name.
hpp.gui::HppWidgetsPlugin::configurationValidationStatus
void configurationValidationStatus(bool valid)
hpp.gui::HppWidgetsPlugin::createRoadmap
virtual Roadmap * createRoadmap(const std::string &jointName)
hpp.gui::JointTreeWidget
Definition: jointtreewidget.hh:19
hpp.gui::HppWidgetsPlugin::bodyConfs_
std::vector< gepetto::viewer::Configuration > bodyConfs_
Definition: hppwidgetsplugin.hh:240
hpp.gui::HppWidgetsPlugin::jointTreeWidget_
JointTreeWidget * jointTreeWidget_
Definition: hppwidgetsplugin.hh:229
hpp.gui::HppWidgetsPlugin::getBodyFromJoint
std::string getBodyFromJoint(const std::string &jointName) const
hpp.gui::HppWidgetsPlugin::createJointGroup
std::string createJointGroup(const std::string jn)
hpp.gui::HppWidgetsPlugin::jointMap
JointMap & jointMap()
Get the jointMap.
hpp.gui::HppWidgetsPlugin::selectJointFromBodyName
void selectJointFromBodyName(const QString bodyName)
hpp.gui::HppWidgetsPlugin::getHppContext
QString getHppContext() const
hpp.gui::HppWidgetsPlugin::addJointFrame
void addJointFrame(const std::string &jointName)
hpp.gui::HppWidgetsPlugin::constraintWidget_
ConstraintWidget * constraintWidget_
Definition: hppwidgetsplugin.hh:230
hpp.gui::HppWidgetsPlugin::applyCurrentConfiguration
void applyCurrentConfiguration()
Apply the current configuration of the robot.
hpp.gui::HppWidgetsPlugin::loadRobotModel
void loadRobotModel(gepetto::gui::DialogLoadRobot::RobotDefinition rd)
hpp.gui::HppWidgetsPlugin::update
void update()
hpp.gui::HppWidgetsPlugin::jointFrames_
hpp::Names_t jointFrames_
Definition: hppwidgetsplugin.hh:232
hpp.gui::HppWidgetsPlugin::closeConnection
virtual void closeConnection()
Close connection to corbaserver.
hpp.gui::PathPlayer
Definition: pathplayer.hh:28
hpp.gui::HppWidgetsPlugin::sendConfiguration
void sendConfiguration()
Set HPP configuration to internal current configuration.
hpp.gui::HppWidgetsPlugin::loadConstraintWidget
virtual void loadConstraintWidget()
hpp.gui::HppWidgetsPlugin
Plugin that add a lot of features to work with hpp.
Definition: hppwidgetsplugin.hh:29
hpp.gui::HppWidgetsPlugin::logFailure
void logFailure(const QString &text)
hpp.gui::ConstraintWidget
Widget that allows to create constraints.
Definition: constraintwidget.hh:24
hpp.gui::HppWidgetsPlugin::escapeJointName
static std::string escapeJointName(const std::string jn)
hpp.gui::HppWidgetsPlugin::updateRobotJoints
virtual void updateRobotJoints(const QString robotName)
hpp.gui::SolverWidget
Definition: solverwidget.hh:23
hpp.gui::HppWidgetsPlugin::linkNames_
hpp::Names_t linkNames_
Definition: hppwidgetsplugin.hh:238
hpp.gui::Roadmap
Definition: roadmap.hh:16
hpp.gui::HppWidgetsPlugin::loadEnvironmentModel
void loadEnvironmentModel(gepetto::gui::DialogLoadEnvironment::EnvironmentDefinition ed)
hpp.gui::HppWidgetsPlugin::createComGroup
std::string createComGroup(const std::string com)