From 76ef67fcec4d6c67fa732ceedb0781a16f7377e2 Mon Sep 17 00:00:00 2001
From: pFernbach <pierre.fernbach@gmail.com>
Date: Mon, 15 Apr 2019 17:55:08 +0200
Subject: [PATCH] [API] add python API to access fullBody.postureWeights

---
 idl/hpp/corbaserver/rbprm/rbprmbuilder.idl | 4 ++++
 src/hpp/corbaserver/rbprm/rbprmfullbody.py | 5 +++++
 src/rbprmbuilder.impl.cc                   | 7 +++++++
 src/rbprmbuilder.impl.hh                   | 1 +
 4 files changed, 17 insertions(+)

diff --git a/idl/hpp/corbaserver/rbprm/rbprmbuilder.idl b/idl/hpp/corbaserver/rbprm/rbprmbuilder.idl
index 8582d7b3..82210bf7 100644
--- a/idl/hpp/corbaserver/rbprm/rbprmbuilder.idl
+++ b/idl/hpp/corbaserver/rbprm/rbprmbuilder.idl
@@ -106,6 +106,10 @@ module hpp
     void setReferenceConfig(in floatSeq referenceConfig)
       raises (Error);
 
+    /// set the weights used when computing a postural task
+    void setPostureWeights(in floatSeq postureWeights)
+      raises (Error);
+
     /// set a reference position of the end effector for the given ROM
     void setReferenceEndEffector(in string romName, in floatSeq ref)
       raises (Error);
diff --git a/src/hpp/corbaserver/rbprm/rbprmfullbody.py b/src/hpp/corbaserver/rbprm/rbprmfullbody.py
index 2382c2b9..10b07a87 100755
--- a/src/hpp/corbaserver/rbprm/rbprmfullbody.py
+++ b/src/hpp/corbaserver/rbprm/rbprmfullbody.py
@@ -843,6 +843,11 @@ class FullBody (Robot):
      def setReferenceConfig(self,referenceConfig):
           return self.clientRbprm.rbprm.setReferenceConfig(referenceConfig)
 
+     ## set the weights used when computing a postural task
+     # \param postureWeights dofArray, must be of same size as device->numberDof
+     def setPostureWeights(self,postureWeights):
+          return self.clientRbprm.rbprm.setPostureWeights(postureWeights)
+
       ## return the time at the given state index (in the path computed during the first phase)
       # \param stateId : index of the state
      def getTimeAtState(self,stateId):
diff --git a/src/rbprmbuilder.impl.cc b/src/rbprmbuilder.impl.cc
index cb25f6ef..ef409dc6 100644
--- a/src/rbprmbuilder.impl.cc
+++ b/src/rbprmbuilder.impl.cc
@@ -633,6 +633,13 @@ namespace hpp {
       fullBody()->referenceConfig(config);
     }
 
+    void RbprmBuilder::setPostureWeights(const hpp::floatSeq& postureWeights) throw (hpp::Error){
+      if(!fullBodyLoaded_)
+        throw Error ("No full body robot was loaded");
+      Configuration_t config(dofArrayToConfig (fullBody()->device_->numberDof(), postureWeights));
+      fullBody()->postureWeights(config);
+    }
+
     void RbprmBuilder::setReferenceEndEffector(const char* romName, const hpp::floatSeq &ref) throw(hpp::Error){
       std::string name (romName);
       hpp::pinocchio::RbPrmDevicePtr_t device = boost::dynamic_pointer_cast<hpp::pinocchio::RbPrmDevice>(problemSolver()->robot ());
diff --git a/src/rbprmbuilder.impl.hh b/src/rbprmbuilder.impl.hh
index 4abbbb68..25d2ca5b 100644
--- a/src/rbprmbuilder.impl.hh
+++ b/src/rbprmbuilder.impl.hh
@@ -196,6 +196,7 @@ namespace hpp {
         void setStaticStability(const bool staticStability) throw (hpp::Error);
 
         void setReferenceConfig(const hpp::floatSeq &referenceConfig) throw (hpp::Error);
+        void setPostureWeights(const hpp::floatSeq &postureWeights) throw (hpp::Error);
         void setReferenceEndEffector(const char* romName, const hpp::floatSeq &ref) throw(hpp::Error);
 
         virtual void setFilter(const hpp::Names_t& roms) throw (hpp::Error);
-- 
GitLab