#include #include "rbdl/rbdl.h" #include #include "PendulumModels.h" using namespace std; using namespace RigidBodyDynamics; using namespace RigidBodyDynamics::Math; const double TEST_PREC = 1.0e-11; // Reduce an angle to the (-pi, pi] range. // static double inRange(double angle) { // while(angle > M_PI) { // angle -= 2. * M_PI; // } // while(angle <= -M_PI) { // angle += 2. * M_PI; // } // return angle; // } TEST(ForwardDynamicsConstraintsWithExternalForcesCorrectnessTest) { DoublePerpendicularPendulumAbsoluteCoordinates dba = DoublePerpendicularPendulumAbsoluteCoordinates(); DoublePerpendicularPendulumJointCoordinates dbj = DoublePerpendicularPendulumJointCoordinates(); //1. Set the pendulum modeled using joint coordinates to a specific // state and then compute the spatial acceleration of the body. dbj.q[0] = M_PI/3.0; //About z0 dbj.q[1] = M_PI/6.0; //About y1 dbj.qd[0] = M_PI; //About z0 dbj.qd[1] = M_PI/2.0; //About y1 dbj.tau[0]= 0.; dbj.tau[1]= 0.; std::vector < SpatialVector > fext_dbj,fext_dba; fext_dbj.resize( dbj.model.mBodies.size() ); fext_dba.resize( dba.model.mBodies.size() ); for(unsigned int i=0; i