From b4221ea868dbbb28b098ea6a9ce050de34aa10ec Mon Sep 17 00:00:00 2001 From: florent <florent@laas.fr> Date: Fri, 17 Dec 2010 14:54:37 +0100 Subject: [PATCH] bind classes WaistPoseFromSensorAndContact and WaistAttitudeFromSensor. * include/sot-dynamic/waist-attitude-from-sensor.h, * src/waist-attitude-from-sensor.cpp. --- .../sot-dynamic/waist-attitude-from-sensor.h | 9 ++++- src/waist-attitude-from-sensor.cpp | 35 ++++++++++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/include/sot-dynamic/waist-attitude-from-sensor.h b/include/sot-dynamic/waist-attitude-from-sensor.h index 0d7a2fb..adeb658 100644 --- a/include/sot-dynamic/waist-attitude-from-sensor.h +++ b/include/sot-dynamic/waist-attitude-from-sensor.h @@ -98,7 +98,14 @@ class SOTWAISTATTITUDEFROMSENSOR_EXPORT WaistPoseFromSensorAndContact static const std::string CLASS_NAME; protected: - bool fromSensor; + void fromSensor(const bool& inFromSensor) { + fromSensor_ = inFromSensor; + } + bool fromSensor() const { + return fromSensor_; + } + private: + bool fromSensor_; public: /* --- CONSTRUCTION --- */ diff --git a/src/waist-attitude-from-sensor.cpp b/src/waist-attitude-from-sensor.cpp index 783d906..239a672 100644 --- a/src/waist-attitude-from-sensor.cpp +++ b/src/waist-attitude-from-sensor.cpp @@ -22,6 +22,10 @@ #include <sot-core/debug.h> #include <dynamic-graph/factory.h> +#include <dynamic-graph/command.h> +#include <dynamic-graph/command-setter.h> +#include <dynamic-graph/command-getter.h> + using namespace sot; using namespace dynamicgraph; DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(WaistAttitudeFromSensor,"WaistAttitudeFromSensor"); @@ -105,7 +109,7 @@ DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(WaistPoseFromSensorAndContact, WaistPoseFromSensorAndContact:: WaistPoseFromSensorAndContact( const std::string & name ) :WaistAttitudeFromSensor(name) - ,fromSensor(false) + ,fromSensor_(false) ,positionContactSIN(NULL,"sotWaistPoseFromSensorAndContact("+name+")::input(matrixHomo)::contact") ,positionWaistSOUT( boost::bind(&WaistPoseFromSensorAndContact::computePositionWaist,this,_1,_2), attitudeWaistSOUT<<positionContactSIN, @@ -115,6 +119,29 @@ WaistPoseFromSensorAndContact( const std::string & name ) signalRegistration( positionContactSIN<<positionWaistSOUT ); + // Commands + std::string docstring; + docstring = " \n" + " Set flag specifying whether angles are measured from sensors or simulated.\n" + " \n" + " Input:\n" + " - a boolean value.\n" + " \n"; + addCommand("setFromSensor", + new ::dynamicgraph::command::Setter + <WaistPoseFromSensorAndContact, bool> + (*this, &WaistPoseFromSensorAndContact::fromSensor, docstring)); + + " Get flag specifying whether angles are measured from sensors or simulated.\n" + " \n" + " No input,\n" + " return a boolean value.\n" + " \n"; + addCommand("getFromSensor", + new ::dynamicgraph::command::Getter + <WaistPoseFromSensorAndContact, bool> + (*this, &WaistPoseFromSensorAndContact::fromSensor, docstring)); + sotDEBUGOUT(5); } @@ -144,7 +171,7 @@ computePositionWaist( ml::Vector& res, for( unsigned int i=0;i<3;++i ) { res(i)=contactMwaist(i,3); } - if(fromSensor) + if(fromSensor_) { const VectorRollPitchYaw & worldrwaist = attitudeWaistSOUT( time ); for( unsigned int i=0;i<3;++i ) @@ -191,9 +218,9 @@ commandLine( const std::string& cmdLine, std::string val; cmdArgs>>val; if( ("true"==val)||("false"==val) ) { - fromSensor = ( val=="true" ); + fromSensor_ = ( val=="true" ); } else { - os << "fromSensor = " << (fromSensor?"true":"false") << std::endl; + os << "fromSensor = " << (fromSensor_?"true":"false") << std::endl; } } else { WaistAttitudeFromSensor::commandLine( cmdLine,cmdArgs,os); } -- GitLab