Skip to content

Commit

Permalink
Add gravity vector setter and getter in DynamicRobot.
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio El Khoury committed Oct 16, 2012
1 parent fa65bef commit aee1218
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 7 additions & 0 deletions include/ard/rbdl/model/dynamic-robot.hh
Expand Up @@ -75,6 +75,13 @@ namespace ard
/// \brief Get underlying rbdl model. /// \brief Get underlying rbdl model.
virtual rbdlModel_t rbdlModel () const; virtual rbdlModel_t rbdlModel () const;


/// \brief Get gravity vector. It is set to a default value on
/// initialization.
virtual vector3d gravity () const;

/// \brief Set gravity vector.
virtual void gravity (const vector3d& gravity);

/// \brief Get the chain of joints between two joints /// \brief Get the chain of joints between two joints
/// \param inStartJoint First joint. /// \param inStartJoint First joint.
/// \param inEndJoint Second joint. /// \param inEndJoint Second joint.
Expand Down
2 changes: 1 addition & 1 deletion include/ard/rbdl/tools/types.hh
Expand Up @@ -48,7 +48,7 @@ namespace ard
namespace rbdl namespace rbdl
{ {
// Define gravity vector. // Define gravity vector.
static const vector3d gravity (0, 0, -9.81); static const vector3d defaultGravity (0, 0, -9.81);


// RBDL typedefs. // RBDL typedefs.
ARD_RBDL_DEFINE_TYPES (RigidBodyDynamics::Joint, rbdlJoint); ARD_RBDL_DEFINE_TYPES (RigidBodyDynamics::Joint, rbdlJoint);
Expand Down
12 changes: 11 additions & 1 deletion src/dynamic-robot.cc
Expand Up @@ -113,7 +113,7 @@ namespace ard
// Initialize rbdl model. This method is called before building // Initialize rbdl model. This method is called before building
// the model. // the model.
rbdlModel_.Init (); rbdlModel_.Init ();
toRbdlFromMal (rbdlModel_.gravity, gravity); toRbdlFromMal (rbdlModel_.gravity, defaultGravity);


// Build rbdl model. // Build rbdl model.
if (!buildRbdlModel ()) if (!buildRbdlModel ())
Expand Down Expand Up @@ -150,6 +150,16 @@ namespace ard
return rbdlModel_; return rbdlModel_;
} }


vector3d DynamicRobot::gravity () const
{
return toMalFromRbdl (rbdlModel_.gravity);
}

void DynamicRobot::gravity (const vector3d& gravity)
{
rbdlModel_.gravity = toRbdlFromMal (gravity);
}

std::vector<to_pointer<CjrlJoint>::type > std::vector<to_pointer<CjrlJoint>::type >
DynamicRobot::jointsBetween (const CjrlJoint& startJoint, DynamicRobot::jointsBetween (const CjrlJoint& startJoint,
const CjrlJoint& endJoint) const const CjrlJoint& endJoint) const
Expand Down

0 comments on commit aee1218

Please sign in to comment.