Skip to content
Snippets Groups Projects
Commit e93f5906 authored by Nicolas Mansard's avatar Nicolas Mansard
Browse files

Remove trailing white spaces, and make a few relook.

parent 56a93b82
No related branches found
No related tags found
1 merge request!1[major][cpp] starting point to integrate pinocchio
...@@ -24,12 +24,12 @@ ...@@ -24,12 +24,12 @@
/* --- API ------------------------------------------------------------- */ /* --- API ------------------------------------------------------------- */
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
#if defined (WIN32) #if defined (WIN32)
# if defined (angle_estimator_EXPORTS) # if defined (angle_estimator_EXPORTS)
# define SOTANGLEESTIMATOR_EXPORT __declspec(dllexport) # define SOTANGLEESTIMATOR_EXPORT __declspec(dllexport)
# else # else
# define SOTANGLEESTIMATOR_EXPORT __declspec(dllimport) # define SOTANGLEESTIMATOR_EXPORT __declspec(dllimport)
# endif # endif
#else #else
# define SOTANGLEESTIMATOR_EXPORT # define SOTANGLEESTIMATOR_EXPORT
#endif #endif
...@@ -94,28 +94,23 @@ class SOTANGLEESTIMATOR_EXPORT AngleEstimator ...@@ -94,28 +94,23 @@ class SOTANGLEESTIMATOR_EXPORT AngleEstimator
MatrixRotation& computeDriftFromAngles( MatrixRotation& res, MatrixRotation& computeDriftFromAngles( MatrixRotation& res,
const int& time ); const int& time );
MatrixRotation& computeSensorWorldRotation( MatrixRotation& res, MatrixRotation& computeSensorWorldRotation( MatrixRotation& res,
const int& time ); const int& time );
MatrixRotation& computeWaistWorldRotation( MatrixRotation& res, MatrixRotation& computeWaistWorldRotation( MatrixRotation& res,
const int& time ); const int& time );
MatrixHomogeneous& computeWaistWorldPosition( MatrixHomogeneous& res, MatrixHomogeneous& computeWaistWorldPosition( MatrixHomogeneous& res,
const int& time ); const int& time );
ml::Vector& computeWaistWorldPoseRPY( ml::Vector& res, ml::Vector& computeWaistWorldPoseRPY( ml::Vector& res,
const int& time ); const int& time );
public: /* --- PARAMS --- */
void fromSensor(const bool& inFromSensor) {
fromSensor_ = inFromSensor;
}
bool fromSensor() const {
return fromSensor_;
}
private:
bool fromSensor_;
public: /* --- PARAMS --- */
void fromSensor(const bool& fs) { fromSensor_ = fs; }
bool fromSensor() const { return fromSensor_; }
virtual void commandLine( const std::string& cmdLine, virtual void commandLine( const std::string& cmdLine,
std::istringstream& cmdArgs, std::istringstream& cmdArgs,
std::ostream& os ); std::ostream& os );
private:
bool fromSensor_;
}; };
......
...@@ -33,7 +33,7 @@ using namespace dynamicgraph; ...@@ -33,7 +33,7 @@ using namespace dynamicgraph;
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(AngleEstimator,"AngleEstimator"); DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(AngleEstimator,"AngleEstimator");
AngleEstimator:: AngleEstimator::
AngleEstimator( const std::string & name ) AngleEstimator( const std::string & name )
:Entity(name) :Entity(name)
,sensorWorldRotationSIN(NULL,"sotAngleEstimator("+name ,sensorWorldRotationSIN(NULL,"sotAngleEstimator("+name
+")::input(MatrixRotation)::sensorWorldRotation") +")::input(MatrixRotation)::sensorWorldRotation")
...@@ -43,7 +43,7 @@ AngleEstimator( const std::string & name ) ...@@ -43,7 +43,7 @@ AngleEstimator( const std::string & name )
+")::input(MatrixHomo)::contactWorldPosition") +")::input(MatrixHomo)::contactWorldPosition")
,contactEmbeddedPositionSIN(NULL,"sotAngleEstimator("+name ,contactEmbeddedPositionSIN(NULL,"sotAngleEstimator("+name
+")::input(MatrixHomo)::contactEmbeddedPosition") +")::input(MatrixHomo)::contactEmbeddedPosition")
,anglesSOUT( boost::bind(&AngleEstimator::computeAngles,this,_1,_2), ,anglesSOUT( boost::bind(&AngleEstimator::computeAngles,this,_1,_2),
sensorWorldRotationSIN<<sensorEmbeddedPositionSIN sensorWorldRotationSIN<<sensorEmbeddedPositionSIN
<<contactWorldPositionSIN<<contactEmbeddedPositionSIN, <<contactWorldPositionSIN<<contactEmbeddedPositionSIN,
...@@ -79,35 +79,36 @@ AngleEstimator( const std::string & name ) ...@@ -79,35 +79,36 @@ AngleEstimator( const std::string & name )
,fromSensor_(true) ,fromSensor_(true)
{ {
sotDEBUGIN(5); sotDEBUGIN(5);
signalRegistration( sensorWorldRotationSIN << sensorEmbeddedPositionSIN
signalRegistration( sensorWorldRotationSIN << sensorEmbeddedPositionSIN << contactWorldPositionSIN << contactEmbeddedPositionSIN
<< contactWorldPositionSIN << contactEmbeddedPositionSIN << anglesSOUT << flexibilitySOUT
<< anglesSOUT << flexibilitySOUT << driftSOUT << sensorWorldRotationSOUT
<< driftSOUT << sensorWorldRotationSOUT << waistWorldRotationSOUT
<< waistWorldRotationSOUT
<< waistWorldPositionSOUT << waistWorldPoseRPYSOUT ); << waistWorldPositionSOUT << waistWorldPoseRPYSOUT );
// Commands /* Commands. */
std::string docstring; {
docstring = " \n" std::string docstring;
" Set flag specifying whether angle is measured from sensors or simulated.\n" docstring = " \n"
" \n" " Set flag specifying whether angle is measured from sensors or simulated.\n"
" Input:\n" " \n"
" - a boolean value.\n" " Input:\n"
" \n"; " - a boolean value.\n"
addCommand("setFromSensor", " \n";
new ::dynamicgraph::command::Setter<AngleEstimator, bool> addCommand("setFromSensor",
(*this, &AngleEstimator::fromSensor, docstring)); new ::dynamicgraph::command::Setter<AngleEstimator, bool>
(*this, &AngleEstimator::fromSensor, docstring));
" Get flag specifying whether angle is measured from sensors or simulated.\n" " Get flag specifying whether angle is measured from sensors or simulated.\n"
" \n" " \n"
" No input,\n" " No input,\n"
" return a boolean value.\n" " return a boolean value.\n"
" \n"; " \n";
addCommand("getFromSensor", addCommand("getFromSensor",
new ::dynamicgraph::command::Getter<AngleEstimator, bool> new ::dynamicgraph::command::Getter<AngleEstimator, bool>
(*this, &AngleEstimator::fromSensor, docstring)); (*this, &AngleEstimator::fromSensor, docstring));
}
sotDEBUGOUT(5); sotDEBUGOUT(5);
} }
...@@ -150,10 +151,10 @@ computeAngles( ml::Vector& res, ...@@ -150,10 +151,10 @@ computeAngles( ml::Vector& res,
const double TOLERANCE_TH = 1e-6; const double TOLERANCE_TH = 1e-6;
const MatrixRotation &R = worldestRleg; const MatrixRotation &R = worldestRleg;
if( (fabs(R(0,1))<TOLERANCE_TH)&&(fabs(R(1,1))<TOLERANCE_TH) ) if( (fabs(R(0,1))<TOLERANCE_TH)&&(fabs(R(1,1))<TOLERANCE_TH) )
{ {
/* This means that cos(X) is very low, ie flex1 is close to 90deg. /* This means that cos(X) is very low, ie flex1 is close to 90deg.
* I take the case into account, but it is bloody never going * I take the case into account, but it is bloody never going
* to happens. */ * to happens. */
if( R(2,1)>0 ) res(0)=M_PI/2; else res(0) = -M_PI/2; if( R(2,1)>0 ) res(0)=M_PI/2; else res(0) = -M_PI/2;
res(2) = atan2( -R(0,2),R(0,0) ); res(2) = atan2( -R(0,2),R(0,0) );
...@@ -174,19 +175,18 @@ computeAngles( ml::Vector& res, ...@@ -174,19 +175,18 @@ computeAngles( ml::Vector& res,
Z = atan2( R(0,1),R(1,1) ); Z = atan2( R(0,1),R(1,1) );
if( fabs(R(2,0))>fabs(R(2,2)) ) if( fabs(R(2,0))>fabs(R(2,2)) )
{ X=atan2( R(2,1)*sin(Y),R(2,0) ); } { X=atan2( R(2,1)*sin(Y),R(2,0) ); }
else else
{ X=atan2( R(2,1)*cos(Y),R(2,2) ); } { X=atan2( R(2,1)*cos(Y),R(2,2) ); }
} }
sotDEBUG(35) << "angles = " << res;
sotDEBUG(35) << "angles = " << res;
sotDEBUGOUT(15); sotDEBUGOUT(15);
return res; return res;
} }
/* compute the transformation matrix of the flexibility, ie /* compute the transformation matrix of the flexibility, ie
* feetRleg. * feetRleg.
*/ */
MatrixRotation& AngleEstimator:: MatrixRotation& AngleEstimator::
computeFlexibilityFromAngles( MatrixRotation& res, computeFlexibilityFromAngles( MatrixRotation& res,
...@@ -199,7 +199,7 @@ computeFlexibilityFromAngles( MatrixRotation& res, ...@@ -199,7 +199,7 @@ computeFlexibilityFromAngles( MatrixRotation& res,
double sx= sin( angles(0) ); double sx= sin( angles(0) );
double cy= cos( angles(1) ); double cy= cos( angles(1) );
double sy= sin( angles(1) ); double sy= sin( angles(1) );
res(0,0) = cy; res(0,0) = cy;
res(0,1) = 0; res(0,1) = 0;
res(0,2) = -sy; res(0,2) = -sy;
...@@ -225,18 +225,18 @@ computeDriftFromAngles( MatrixRotation& res, ...@@ -225,18 +225,18 @@ computeDriftFromAngles( MatrixRotation& res,
const int& time ) const int& time )
{ {
sotDEBUGIN(15); sotDEBUGIN(15);
const ml::Vector & angles = anglesSOUT( time ); const ml::Vector & angles = anglesSOUT( time );
double cz = cos( angles(2) ); double cz = cos( angles(2) );
double sz = sin( angles(2) ); double sz = sin( angles(2) );
res(0,0) = cz; res(0,0) = cz;
res(0,1) = -sz; res(0,1) = -sz;
res(0,2) = 0; res(0,2) = 0;
// z is the positive angle (R_{-z} has been computed /* z is the positive angle (R_{-z} has been computed
// in the <angles> function). Thus, the /-/sin(z) is in 0,1 *in the <angles> function). Thus, the /-/sin(z) is in 0,1. */
res(1,0) = sz; res(1,0) = sz;
res(1,1) = cz; res(1,1) = cz;
res(1,2) = 0; res(1,2) = 0;
...@@ -253,27 +253,27 @@ computeSensorWorldRotation( MatrixRotation& res, ...@@ -253,27 +253,27 @@ computeSensorWorldRotation( MatrixRotation& res,
const int& time ) const int& time )
{ {
sotDEBUGIN(15); sotDEBUGIN(15);
const MatrixRotation & worldRworldest = driftSOUT( time ); const MatrixRotation & worldRworldest = driftSOUT( time );
const MatrixRotation & worldestRsensor = sensorWorldRotationSIN( time ); const MatrixRotation & worldestRsensor = sensorWorldRotationSIN( time );
worldRworldest.multiply( worldestRsensor,res ); worldRworldest.multiply( worldestRsensor,res );
sotDEBUGOUT(15); sotDEBUGOUT(15);
return res; return res;
} }
MatrixRotation& AngleEstimator:: MatrixRotation& AngleEstimator::
computeWaistWorldRotation( MatrixRotation& res, computeWaistWorldRotation( MatrixRotation& res,
const int& time ) const int& time )
{ {
sotDEBUGIN(15); sotDEBUGIN(15);
// chest = sensor // chest = sensor
const MatrixRotation & worldRsensor = sensorWorldRotationSOUT( time ); const MatrixRotation & worldRsensor = sensorWorldRotationSOUT( time );
const MatrixHomogeneous & waistMchest = sensorEmbeddedPositionSIN( time ); const MatrixHomogeneous & waistMchest = sensorEmbeddedPositionSIN( time );
MatrixRotation waistRchest; waistMchest.extract( waistRchest ); MatrixRotation waistRchest; waistMchest.extract( waistRchest );
worldRsensor .multiply( waistRchest.transpose(),res ); worldRsensor .multiply( waistRchest.transpose(),res );
sotDEBUGOUT(15); sotDEBUGOUT(15);
...@@ -287,17 +287,17 @@ computeWaistWorldPosition( MatrixHomogeneous& res, ...@@ -287,17 +287,17 @@ computeWaistWorldPosition( MatrixHomogeneous& res,
const int& time ) const int& time )
{ {
sotDEBUGIN(15); sotDEBUGIN(15);
const MatrixHomogeneous & waistMleg = contactEmbeddedPositionSIN( time ); const MatrixHomogeneous & waistMleg = contactEmbeddedPositionSIN( time );
const MatrixHomogeneous& contactPos = contactWorldPositionSIN( time ); const MatrixHomogeneous& contactPos = contactWorldPositionSIN( time );
MatrixHomogeneous legMwaist; waistMleg.inverse( legMwaist ); MatrixHomogeneous legMwaist; waistMleg.inverse( legMwaist );
MatrixHomogeneous tmpRes; MatrixHomogeneous tmpRes;
if( fromSensor_ ) if( fromSensor_ )
{ {
const MatrixRotation & Rflex = flexibilitySOUT( time ); // footRleg const MatrixRotation & Rflex = flexibilitySOUT( time ); // footRleg
ml::Vector zero(3); zero.fill(0.); ml::Vector zero(3); zero.fill(0.);
MatrixHomogeneous footMleg; footMleg.buildFrom( Rflex,zero ); MatrixHomogeneous footMleg; footMleg.buildFrom( Rflex,zero );
footMleg.multiply( legMwaist,tmpRes ); footMleg.multiply( legMwaist,tmpRes );
} }
else { tmpRes = legMwaist; } else { tmpRes = legMwaist; }
...@@ -339,7 +339,7 @@ commandLine( const std::string& cmdLine, ...@@ -339,7 +339,7 @@ commandLine( const std::string& cmdLine,
} }
else if( cmdLine == "fromSensor" ) else if( cmdLine == "fromSensor" )
{ {
std::string val; cmdArgs>>val; std::string val; cmdArgs>>val;
if( ("true"==val)||("false"==val) ) if( ("true"==val)||("false"==val) )
{ {
fromSensor_ = ( val=="true" ); fromSensor_ = ( val=="true" );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment