Robot Dynamics Library
Classes | Functions | Variables
Urdf Reader

Classes

struct  RobotDynamics::Urdf::hydro::BodyHydroData
 Data struct for holding the hydro parameters for each body as they are parsed out of the URDF. More...
 

Functions

 RobotDynamics::Urdf::hydro::BodyHydroData::BodyHydroData ()
 
bool RobotDynamics::Urdf::hydro::parseHydrodynamicsParameters (const char *model_xml_string, std::map< std::string, hydro::BodyHydroData > &data, bool verbose=false)
 Parses an urdf and stores hydrodynamic data for each body in the data argument. More...
 
bool RobotDynamics::Urdf::urdfReadFromFile (const std::string &filename, ModelPtr model, JointType floating_base_rotation_joint_type=JointTypeSpherical, bool verbose=false)
 Read urdf from file path. More...
 
bool RobotDynamics::Urdf::urdfReadFromString (const std::string &model_xml_string, ModelPtr model, JointType floating_base_rotation_joint_type=JointTypeSpherical, bool verbose=false)
 Read urdf from string contents. More...
 
bool RobotDynamics::Urdf::parseJointBodyNameMapFromString (const std::string &model_xml_string, std::map< std::string, std::string > &jointBodyMap)
 This will build a map of joint name to body name. More...
 
bool RobotDynamics::Urdf::parseJointAndBodyNamesFromString (const std::string &model_xml_string, std::vector< std::string > &joint_names, std::vector< std::string > &body_names)
 This will build vectors of joint name and body name pairs. More...
 
bool RobotDynamics::Urdf::parseJointBodyNameMapFromFile (const std::string &filename, std::map< std::string, std::string > &jointBodyMap)
 This will build a map of joint name to body name. More...
 
bool RobotDynamics::Urdf::parseJointAndQIndex (const RobotDynamics::Model &model, const std::vector< std::string > &body_names, std::vector< unsigned int > &q_indices)
 This will build a vector of joint indices in the same order as the list of joints. More...
 
bool RobotDynamics::Urdf::parseJointAndQIndex (const std::string &model_xml_string, std::vector< unsigned int > &q_indices)
 This will build a vector of joint indices in the same order as the list of joints. More...
 

Variables

bool RobotDynamics::Urdf::hydro::BodyHydroData::hasHydro
 
double RobotDynamics::Urdf::hydro::BodyHydroData::volume
 
Math::Vector3d RobotDynamics::Urdf::hydro::BodyHydroData::centerOfBuoyancy
 
RobotDynamics::Math::SpatialMatrix RobotDynamics::Urdf::hydro::BodyHydroData::addedMassMatrix
 
std::vector< double > RobotDynamics::Urdf::hydro::BodyHydroData::linearDrag
 
std::vector< double > RobotDynamics::Urdf::hydro::BodyHydroData::quadraticDrag
 
Math::Vector3d RobotDynamics::Urdf::hydro::BodyHydroData::ellipsoidMajorAxisDirection
 
double RobotDynamics::Urdf::hydro::BodyHydroData::dragCoefficient
 

Detailed Description

The urdfreader has been updated to include parsing of hydrodynamics parameters from an urdf to produce a model with the appropriate hydrodynamic parameters for calculating the dynamics equations including hydrodynamic effects.

For each body that you want to have hydrodynamic effects, you will need to place the following block in the links <link> block,

<hydro>
<drag>
<linear_damping>-1. -2. -3. -4. -5. -6.</linear_damping>
<quadratic_damping>-1. -2. -3. -4. -5. -6.</quadratic_damping>
</drag>
<buoyancy>
<volume>0.1</volume>
<origin xyz= "0.1101 0.121 -0.013"/>
</buoyancy>
<added_mass>
1. 0 0 0 0 0
0 183. 0 0 0 0
0 0 184. 0 0 0
0 0 0 2. 0 0
0 0 0 0 44. 0
0 0 0 0 0 45.
</added_mass>
</hydro>

There are essentially 3 blocks inside the hydro tags where all of the information is gathered. Drag is an effect that is assumed to be quadratic in the spatial velocity of each body, i.e. of the form a*v + b*v^2. To model this we require 6 coefficients for the linear term and 6 coefficients for the quadratic term for each body, contained within the <linear_damping> and <quadratic_damping> tags.

For modelling the effects of added_mass, you will need to include each body's added mass matrix in the <added_mass></added_mass> tag. Note that the added mass matrix is a 6x6 inertia type matrix that should be positive definite.

Buoyancy is the simplest of the three hydro effects modelled and simply requires a volume(in cubic meters) and the x, y, and z coordinates of the center of buoyancy for the body.

Note
The drag coefficients need to be negative!
Any of these effects can be ignored by removing the respective block from the hydro block.

Function Documentation

◆ BodyHydroData()

RobotDynamics::Urdf::hydro::BodyHydroData::BodyHydroData ( )
inline

◆ parseHydrodynamicsParameters()

bool RobotDynamics::Urdf::hydro::parseHydrodynamicsParameters ( const char *  model_xml_string,
std::map< std::string, hydro::BodyHydroData > &  data,
bool  verbose = false 
)

Parses an urdf and stores hydrodynamic data for each body in the data argument.

Parameters
model_xml_stringUrdf contents
dataMap of structs to hold the hydro data for each body
verboseTrue for a whole bunch of debug data to be printed to console
Returns
True if success, false otherwise

Flip the order bc in RDL everything is angular part first

RDL does everything with angular first, so these have to be flipped assuming they're put in the urdf in the order x y z r p y

RDL does everything with angular first, so these have to be flipped assuming they're put in the urdf in the order x y z r p y

◆ parseJointAndBodyNamesFromString()

bool RobotDynamics::Urdf::parseJointAndBodyNamesFromString ( const std::string &  model_xml_string,
std::vector< std::string > &  joint_names,
std::vector< std::string > &  body_names 
)

This will build vectors of joint name and body name pairs.

Parameters
model_xml_stringUrdf file contents
joint_namesModified
body_namesModified
Returns
True if succuss, false otherwise
Warning
This will NOT give any information about a floating body/joint. The floating body will be ignored since it's not moved by a joint called out in the urdf. Only joints/bodies in 'joint'/'link' tags will be used to populate the map. Non fixed joint/body pairs will be ignored

◆ parseJointAndQIndex() [1/2]

bool RobotDynamics::Urdf::parseJointAndQIndex ( const RobotDynamics::Model model,
const std::vector< std::string > &  body_names,
std::vector< unsigned int > &  q_indices 
)

This will build a vector of joint indices in the same order as the list of joints.

Parameters
modelRDL Model
body_namesvector of body names. Order is important here. Recommended this comes from one of the parse joint and body names functions to ensure correct ordering
q_indicesModified. Vector of q indices populated
Returns
true on success, false otherwise
Warning
This will NOT give any information about a floating body/joint

◆ parseJointAndQIndex() [2/2]

bool RobotDynamics::Urdf::parseJointAndQIndex ( const std::string &  model_xml_string,
std::vector< unsigned int > &  q_indices 
)

This will build a vector of joint indices in the same order as the list of joints.

Parameters
model_xml_stringUrdf string
q_indicesModified. Vector of q indices populated
Returns
true on success, false otherwise
Warning
This will NOT give any information about a floating body/joint

◆ parseJointBodyNameMapFromFile()

bool RobotDynamics::Urdf::parseJointBodyNameMapFromFile ( const std::string &  filename,
std::map< std::string, std::string > &  jointBodyMap 
)

This will build a map of joint name to body name.

Parameters
filenameFilepath
jointBodyMapModified
Returns
Warning
This will NOT give any information about a floating body/joint. The floating body will be ignored since it's not moved by a joint called out in the urdf. Only joints/bodies in 'joint'/'link' tags will be used to populate the map.

◆ parseJointBodyNameMapFromString()

bool RobotDynamics::Urdf::parseJointBodyNameMapFromString ( const std::string &  model_xml_string,
std::map< std::string, std::string > &  jointBodyMap 
)

This will build a map of joint name to body name.

Parameters
model_xml_stringUrdf file contents
jointBodyMapModified
Returns
Warning
This will NOT give any information about a floating body/joint. The floating body will be ignored since it's not moved by a joint called out in the urdf. Only joints/bodies in 'joint'/'link' tags will be used to populate the map.

◆ urdfReadFromFile()

bool RobotDynamics::Urdf::urdfReadFromFile ( const std::string &  filename,
ModelPtr  model,
JointType  floating_base_rotation_joint_type = JointTypeSpherical,
bool  verbose = false 
)

Read urdf from file path.

Parameters
filename
model
verboseif true will print model information
Returns
True on success, false otherwise
Note
This function will deduce whether or not the robot has a floating base by checking the name of the root link. If the name of the root link is "world", then it will have a floating base.

◆ urdfReadFromString()

bool RobotDynamics::Urdf::urdfReadFromString ( const std::string &  model_xml_string,
ModelPtr  model,
JointType  floating_base_rotation_joint_type = JointTypeSpherical,
bool  verbose = false 
)

Read urdf from string contents.

Parameters
model_xml_string
model
verboseif true will print model information
Returns
True on success, false otherwise
Note
This function will deduce whether or not the robot has a floating base by checking the name of the root link. If the name of the root link is "world", then it will have a floating base.

Variable Documentation

◆ addedMassMatrix

RobotDynamics::Math::SpatialMatrix RobotDynamics::Urdf::hydro::BodyHydroData::addedMassMatrix

For added mass inertial effects

◆ centerOfBuoyancy

Math::Vector3d RobotDynamics::Urdf::hydro::BodyHydroData::centerOfBuoyancy

Coordinates of the center of buoyancy in body frame

◆ dragCoefficient

double RobotDynamics::Urdf::hydro::BodyHydroData::dragCoefficient

Coefficient of drag for the body

◆ ellipsoidMajorAxisDirection

Math::Vector3d RobotDynamics::Urdf::hydro::BodyHydroData::ellipsoidMajorAxisDirection

◆ hasHydro

bool RobotDynamics::Urdf::hydro::BodyHydroData::hasHydro

True if the hydro block exists in a body's link block

◆ linearDrag

std::vector<double> RobotDynamics::Urdf::hydro::BodyHydroData::linearDrag

6 directional elements for the linear drag term

◆ quadraticDrag

std::vector<double> RobotDynamics::Urdf::hydro::BodyHydroData::quadraticDrag

6 directional elements for the quadratic drag term

◆ volume

double RobotDynamics::Urdf::hydro::BodyHydroData::volume

Body volume in cubic meters