Commit ec2802e3 authored by Joseph Mirabel's avatar Joseph Mirabel

Expose current configuration of the interface in PythonQt.

parent 8537039e
......@@ -235,6 +235,20 @@ namespace hpp {
return &config_;
}
void HppWidgetsPlugin::setCurrentQtConfig (const QVector<double>& q)
{
config_ .length (q.size());
for (ULong i = 0; i < config_.length(); ++i) config_[i] = q[i];
MainWindow::instance()->requestApplyCurrentConfiguration();
}
QVector<double> HppWidgetsPlugin::getCurrentQtConfig () const
{
QVector<double> c (config_.length());
for (ULong i = 0; i < config_.length(); ++i) c[i] = config_[i];
return c;
}
bool HppWidgetsPlugin::corbaException(int jobId, const CORBA::Exception &excep) const
{
try {
......
......@@ -134,6 +134,10 @@ signals:
hpp::floatSeq const* getCurrentConfig () const;
void setCurrentQtConfig (const QVector<double>& q);
QVector<double> getCurrentQtConfig () const;
/// Set internal configuration from HPP current config.
void fetchConfiguration ();
......
......@@ -267,11 +267,8 @@ namespace hpp {
switch (type) {
case JointTreeItem::SkipType:
return;
case JointTreeItem::IntegratorType:{
hpp::floatSeq_var q = plugin_->client()->robot()->getJointConfig (ji->name().c_str());
ji->updateConfig(q.in());
return;
}
case JointTreeItem::IntegratorType:
return;
case JointTreeItem::BoundedValueType: {
SliderBoundedJoint* slider = static_cast <SliderBoundedJoint*> (editor);
q = slider->getValue();
......@@ -288,11 +285,12 @@ namespace hpp {
}
model->setData(index, q, Qt::EditRole);
assert (ji);
ULong idxCfg = (ULong)index.data(JointTreeItem::IndexRole).toInt();
switch (type) {
case JointTreeItem::BoundedValueType:
return;
case JointTreeItem::UnboundedValueType:
plugin_->client()->robot()->setJointConfig (ji->name().c_str(), ji->config());
plugin_->currentConfig()[ji->rankInConfig()+idxCfg] = q;
break;
case JointTreeItem::BoundType:
plugin_->client()->robot()->setJointBounds (ji->name().c_str(), ji->bounds());
......
......@@ -17,14 +17,13 @@ class DirectPathBox(QtGui.QGroupBox):
def shootRandom(self):
q = self.plugin.client.robot.shootRandomConfig()
self.plugin.client.robot.setCurrentConfig(q)
self.plugin.main.requestApplyCurrentConfiguration()
self.plugin.hppPlugin.setCurrentQtConfig(q)
def getFrom (self):
self.fromCfg = self.plugin.client.robot.getCurrentConfig()
self.fromCfg = self.plugin.hppPlugin.getCurrentQtConfig()
def getTo (self):
self.toCfg = self.plugin.client.robot.getCurrentConfig()
self.toCfg = self.plugin.hppPlugin.getCurrentQtConfig()
def makePath (self):
n = self.plugin.client.robot.getConfigSize()
......
......@@ -204,7 +204,7 @@ class _GraspMode(QWidget):
def graspCurrent(self):
if (len(self.handles) > 0 and len(self.grippers) > 0):
self.grasp(self.parentInstance.plugin.client.basic.robot.getCurrentConfig())
self.grasp(self.parentInstance.plugin.hppPlugin.getCurrentQtConfig())
def graspRandom(self):
if (len(self.handles) > 0 and len(self.grippers) > 0):
......@@ -224,12 +224,11 @@ class _GraspMode(QWidget):
self.parentInstance.plugin.client.basic.problem.addNumericalConstraints("constraints", [name,], [0,])
res = self.parentInstance.plugin.client.basic.problem.applyConstraints(config)
if res[0] == True:
self.parentInstance.plugin.client.basic.robot.setCurrentConfig(res[1])
self.mainWindow.requestApplyCurrentConfiguration()
self.parentInstance.plugin.hppPlugin.setCurrentQtConfig(res[1])
def pregraspCurrent(self):
if (len(self.handles) > 0 and len(self.grippers) > 0):
self.pregrasp(self.parentInstance.plugin.client.basic.robot.getCurrentConfig())
self.pregrasp(self.parentInstance.plugin.hppPlugin.getCurrentQtConfig())
def pregraspRandom(self):
if (len(self.handles) > 0 and len(self.grippers) > 0):
......@@ -242,10 +241,9 @@ class _GraspMode(QWidget):
name = self.grippers[self.currentGripper] + " pregrasps " + self.handles[self.currentHandle]
self.parentInstance.plugin.client.manipulation.problem.createGrasp(name, self.grippers[self.currentGripper], self.handles[self.currentHandle])
self.parentInstance.plugin.client.basic.problem.addNumericalConstraints("constraints", [name], [True])
res = self.parentInstance.plugin.client.basic.problem.applyConstraints(self.parentInstance.plugin.client.basic.robot.getCurrentConfig())
res = self.parentInstance.plugin.client.basic.problem.applyConstraints(self.parentInstance.plugin.hppPlugin.getCurrentQtConfig())
if (res[0] == True):
self.parentInstance.plugin.client.basic.robot.setCurrentConfig(res[1])
self.mainWindow.requestApplyCurrentConfiguration()
self.parentInstance.plugin.hppPlugin.setCurrentQtConfig(res[1])
def lock(self):
if (self.selected != ""):
......@@ -314,10 +312,9 @@ class _PlacementMode(QWidget):
[self.surfaceName], [self.carryName])
self.parent().plugin.client.basic.problem.addNumericalConstraints("numerical", ["placement"], [True])
res = self.parent().plugin.client.basic.problem.applyConstraints(self.parent().plugin.client.basic.robot.getCurrentConfig())
res = self.parent().plugin.client.basic.problem.applyConstraints(self.parent().plugin.hppPlugin.getCurrentQtConfig())
if res[0]:
self.parent().plugin.client.basic.robot.setCurrentConfig(res[1])
self.parent().mainWindow.requestApplyCurrentConfiguration()
self.parent().plugin.hppPlugin.setCurrentQtConfig(res[1])
def createWidget(self):
box = QVBoxLayout(self)
......@@ -379,6 +376,7 @@ class Plugin(QDockWidget):
self.setObjectName ("hpp.gui.dynamicbuild")
self.osg = None
self.mainWindow = mainWindow
self.hppPlugin = mainWindow.getFromSlot("getHppIIOPurl")
self.resetConnection()
mainWindow.registerShortcut("Dynamic builder", "Toggle view", self.toggleViewAction())
self.dynamicBuilder = _DynamicBuilder(mainWindow, self)
......
Markdown is supported
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