Commit f6cdf00a authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

Add COM in HppWidgetsPlugin

parent d59ee805
...@@ -135,6 +135,7 @@ namespace hpp { ...@@ -135,6 +135,7 @@ namespace hpp {
main->osg()->refresh(); main->osg()->refresh();
main->registerSlot("requestCreateJointGroup", this); main->registerSlot("requestCreateJointGroup", this);
main->registerSlot("requestCreateComGroup", this);
main->registerSlot("getHppIIOPurl", this); main->registerSlot("getHppIIOPurl", this);
main->registerSlot("getSelectedJoint", jointTreeWidget_); main->registerSlot("getSelectedJoint", jointTreeWidget_);
main->registerSignal(SIGNAL(appliedConfigAtParam(int,double)), pathPlayer_); main->registerSignal(SIGNAL(appliedConfigAtParam(int,double)), pathPlayer_);
...@@ -269,6 +270,14 @@ namespace hpp { ...@@ -269,6 +270,14 @@ namespace hpp {
fromHPP(t, T); fromHPP(t, T);
main->osg()->applyConfiguration (n, T); main->osg()->applyConfiguration (n, T);
} }
T.quat.set(0,0,0,1);
for (std::list<std::string>::const_iterator it = comFrames_.begin ();
it != comFrames_.end (); ++it) {
std::string n = "com_" + escapeJointName(*it);
hpp::floatSeq_var t = client()->robot()->getPartialCom(it->c_str());
fromHPP (t, T.position);
main->osg()->applyConfiguration (n, T);
}
main->osg()->refresh(); main->osg()->refresh();
} }
...@@ -386,6 +395,11 @@ namespace hpp { ...@@ -386,6 +395,11 @@ namespace hpp {
return createJointGroup(jn.toStdString()).c_str(); return createJointGroup(jn.toStdString()).c_str();
} }
QString HppWidgetsPlugin::requestCreateComGroup(const QString com)
{
return QString::fromStdString(createComGroup(com.toStdString()));
}
HppWidgetsPlugin::HppClient *HppWidgetsPlugin::client() const HppWidgetsPlugin::HppClient *HppWidgetsPlugin::client() const
{ {
return hpp_; return hpp_;
...@@ -510,6 +524,27 @@ namespace hpp { ...@@ -510,6 +524,27 @@ namespace hpp {
return target; return target;
} }
std::string HppWidgetsPlugin::createComGroup(const std::string com)
{
gepetto::gui::MainWindow* main = gepetto::gui::MainWindow::instance ();
std::string target = "com_" + escapeJointName(com);
graphics::GroupNodePtr_t group = main->osg()->getGroup (target.c_str(), false);
if (group) return target;
if (!main->osg()->getGroup(target)) {
main->osg()->createGroup(target);
main->osg()->addToGroup(target, "joints");
hpp::floatSeq_var p = client()->robot()->getPartialCom (com.c_str());
OsgConfiguration_t t;
t.quat.set(0,0,0,1);
fromHPP (p, t.position);
comFrames_.push_back(com);
main->osg()->applyConfiguration (target, t);
main->osg()->refresh();
}
return target;
}
Q_EXPORT_PLUGIN2 (hppwidgetsplugin, HppWidgetsPlugin) Q_EXPORT_PLUGIN2 (hppwidgetsplugin, HppWidgetsPlugin)
} // namespace gui } // namespace gui
} // namespace hpp } // namespace hpp
...@@ -106,6 +106,9 @@ signals: ...@@ -106,6 +106,9 @@ signals:
/// See createJointGroup /// See createJointGroup
QString requestCreateJointGroup(const QString jn); QString requestCreateJointGroup(const QString jn);
/// See createComGroup
QString requestCreateComGroup(const QString com);
QString getHppIIOPurl () const; QString getHppIIOPurl () const;
public: public:
...@@ -162,6 +165,10 @@ signals: ...@@ -162,6 +165,10 @@ signals:
/// \param jn joint name /// \param jn joint name
std::string createJointGroup (const std::string jn); std::string createJointGroup (const std::string jn);
/// Create a group from the given COM.
/// \param com COM name
std::string createComGroup (const std::string com);
/// Replace all the bodies according to their position in hpp. /// Replace all the bodies according to their position in hpp.
void computeObjectPosition(); void computeObjectPosition();
...@@ -172,6 +179,7 @@ signals: ...@@ -172,6 +179,7 @@ signals:
ConstraintWidget* constraintWidget_; ConstraintWidget* constraintWidget_;
JointMap jointMap_; JointMap jointMap_;
std::list <std::string> jointFrames_; std::list <std::string> jointFrames_;
std::list <std::string> comFrames_;
}; };
} // namespace gui } // namespace gui
} // namespace hpp } // namespace hpp
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment