Commit ec2802e3 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Expose current configuration of the interface in PythonQt.

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