38 ostringstream dof_stream(ostringstream::out);
39 dof_stream <<
"custom (" << joint_dof.transpose() <<
")";
40 return dof_stream.str();
44 if (model.
mBodies[body_id].mIsVirtual) {
46 if (model.
mu[body_id].size() != 1)
56 stringstream result (
"");
58 unsigned int q_index = 0;
59 for (
unsigned int i = 1; i < model.
mBodies.size(); i++) {
60 if (model.
mJoints[i].mDoFCount == 1) {
64 for (
unsigned int j = 0; j < model.
mJoints[i].mDoFCount; j++) {
75 stringstream result (
"");
77 for (
int j = 0; j < indent; j++)
85 while (model.
mBodies[body_index].mIsVirtual) {
86 if (model.
mu[body_index].size() == 0) {
89 }
else if (model.
mu[body_index].size() > 1) {
90 cerr << endl <<
"Error: Cannot determine multi-dof joint as massless body with id " << body_index <<
" (name: " << model.
GetBodyName(body_index) <<
") has more than one child:" << endl;
91 for (
unsigned int ci = 0; ci < model.
mu[body_index].size(); ci++) {
92 cerr <<
" id: " << model.
mu[body_index][ci] <<
" name: " << model.
GetBodyName(model.
mu[body_index][ci]) << endl;
99 body_index = model.
mu[body_index][0];
106 unsigned int child_index = 0;
107 for (child_index = 0; child_index < model.
mu[body_index].size(); child_index++) {
108 result <<
print_hierarchy (model, model.
mu[body_index][child_index], indent + 1);
112 for (
unsigned int fbody_index = 0; fbody_index < model.
mFixedBodies.size(); fbody_index++) {
113 if (model.
mFixedBodies[fbody_index].mMovableParent == body_index) {
114 for (
int j = 0; j < indent + 1; j++)
126 stringstream result (
"");
134 stringstream result (
"");
139 for (
unsigned int body_id = 0; body_id < model.
mBodies.size(); body_id++) {
140 std::string body_name = model.
GetBodyName (body_id);
142 if (body_name.size() == 0)
147 result << body_name <<
": " << position.transpose() << endl;
161 bool update_kinematics) {
162 if (update_kinematics)
165 for (
size_t i = 1; i < model.
mBodies.size(); i++) {
166 model.
Ic[i] = model.
I[i];
167 model.
hc[i] = model.
Ic[i].toMatrix() * model.
v[i];
173 for (
size_t i = model.
mBodies.size() - 1; i > 0; i--) {
174 unsigned int lambda = model.
lambda[i];
177 model.
Ic[lambda] = model.
Ic[lambda] + model.
X_lambda[i].applyTranspose (model.
Ic[i]);
178 model.
hc[lambda] = model.
hc[lambda] + model.
X_lambda[i].applyTranspose (model.
hc[i]);
180 Itot = Itot + model.
X_lambda[i].applyTranspose (model.
Ic[i]);
181 htot = htot + model.
X_lambda[i].applyTranspose (model.
hc[i]);
187 LOG <<
"mass = " << mass <<
" com = " << com.transpose() <<
" htot = " << htot.transpose() << std::endl;
190 *com_velocity =
Vector3d (htot[3] / mass, htot[4] / mass, htot[5] / mass);
192 if (angular_momentum) {
194 angular_momentum->
set (htot[0], htot[1], htot[2]);
201 bool update_kinematics) {
207 LOG <<
"pot_energy: " <<
" mass = " << mass <<
" com = " << com.transpose() << std::endl;
209 return mass * com.dot(g);
216 bool update_kinematics) {
217 if (update_kinematics)
222 for (
size_t i = 1; i < model.
mBodies.size(); i++) {
223 result += 0.5 * model.
v[i].transpose() * (model.
I[i] * model.
v[i]);
std::vector< Math::SpatialVector > hc
string get_dof_name(const SpatialVector &joint_dof)
std::vector< unsigned int > lambda
The id of the parents body.
RBDL_DLLAPI void UpdateKinematicsCustom(Model &model, const VectorNd *Q, const VectorNd *QDot, const VectorNd *QDDot)
Selectively updates model internal states of body positions, velocities and/or accelerations.
Compact representation for Spatial Inertia.
SpatialVector applyAdjoint(const SpatialVector &f_sp)
RBDL_DLLAPI double CalcKineticEnergy(Model &model, const Math::VectorNd &q, const Math::VectorNd &qdot, bool update_kinematics)
Computes the kinetic energy of the full model.
std::string GetBodyName(unsigned int body_id) const
Returns the name of a body for a given body id.
RBDL_DLLAPI std::string GetModelHierarchy(const Model &model)
Creates a human readable overview of the model.
RBDL_DLLAPI double CalcPotentialEnergy(Model &model, const Math::VectorNd &q, bool update_kinematics)
Computes the potential energy of the full model.
Contains all information about the rigid body model.
std::vector< Math::SpatialVector > v
The spatial velocity of the bodies.
std::vector< Body > mBodies
All bodies 0 ... N_B, including the base.
RBDL_DLLAPI Vector3d CalcBodyToBaseCoordinates(Model &model, const VectorNd &Q, unsigned int body_id, const Vector3d &point_body_coordinates, bool update_kinematics)
Returns the base coordinates of a point given in body coordinates.
std::vector< Math::SpatialRigidBodyInertia > Ic
RBDL_DLLAPI void CalcCenterOfMass(Model &model, const Math::VectorNd &q, const Math::VectorNd &qdot, double &mass, Math::Vector3d &com, Math::Vector3d *com_velocity, Vector3d *angular_momentum, bool update_kinematics)
Computes the Center of Mass (COM) and optionally its linear velocity.
Namespace for all structures of the RigidBodyDynamics library.
Math::Vector3d gravity
the cartesian vector of the gravity
std::vector< Math::SpatialRigidBodyInertia > I
The spatial inertia of body i (used only in CompositeRigidBodyAlgorithm())
std::vector< Math::SpatialTransform > X_lambda
Transformation from the parent body to the current body .
SpatialTransform Xtrans(const Vector3d &r)
std::vector< FixedBody > mFixedBodies
All bodies that are attached to a body via a fixed joint.
RBDL_DLLAPI std::string GetModelDOFOverview(const Model &model)
Creates a human readable overview of the Degrees of Freedom.
unsigned int qdot_size
The size of the.
RBDL_DLLAPI std::string GetNamedBodyOriginsOverview(Model &model)
Creates a human readable overview of the locations of all bodies that have names. ...
std::vector< std::vector< unsigned int > > mu
Contains the ids of all the children of a given body.
unsigned int fixed_body_discriminator
Value that is used to discriminate between fixed and movable bodies.
std::string print_hierarchy(const RigidBodyDynamics::Model &model, unsigned int body_index=0, int indent=0)
unsigned int dof_count
number of degrees of freedoms of the model
std::vector< Math::SpatialVector > S
The joint axis for joint i.
string get_body_name(const RigidBodyDynamics::Model &model, unsigned int body_id)
std::vector< Joint > mJoints
All joints.
void set(const double &v0, const double &v1, const double &v2)
Vector3d h
Coordinates of the center of mass.