cuikurdf2world.cpp File Reference

Detailed Description

dot_inline_dotgraph_51.png

Main body of the cuikurdf2world application. This application reads URDFs (universal robot description files) and generates a world file from them. In this way we can take advantage of all the URDF defined by the ROS community.

Note that to keed the number of dependencies low, we do not use the ROS utilities to parse the URDF files but we directly pase them using a XML parsing tool (the tinyxml2 library). This means that future modifications/extensions on the URDF format might not be captured by this tool (altough it can be easily adapted).

Only the links and joints in the URDFs are considered (no dynamical parameters, etc).

This is coded in cpp to use the tinyxml library.

Todo:
Integrate the urdf2world into ROS to use all the ROS tools. However, this means that the application would require a full ROS installation.

Definition in file cuikurdf2world.cpp.

Functions

double correctAngle (double a)
 Correct the angles given in the URDF. More...
 
XMLElement * FindFirstElement (char *label, XMLNode **child, XMLNode *node)
 Finds the first element with a particular label in the list of child nodes. More...
 
XMLElement * FindNextElement (char *label, XMLNode **child)
 Continues a search over the set of child nodes. More...
 
int main (int argc, char **arg)
 Main body of the cuikurdf2world application. More...
 

Function Documentation

double correctAngle ( double  a)

Angles in the URDF are typically given with low precision. This function tries to correct these angles (basically set the angle to PI when the given angle is very close to PI and similar corrections).

Parameters
aThe input angle.
Returns
The corrected angle.

Definition at line 77 of file cuikurdf2world.cpp.

References M_PI, M_PI_2, and PI2PI.

Referenced by main().

XMLElement * FindFirstElement ( char *  label,
XMLNode **  child,
XMLNode *  node 
)

Finds the first element with a particular label in the list of child nodes. We loop over the children of the node searching for an element with the given label.

Parameters
labelThe label of the element to search.
childThe node for the element. This is used for subsequent searches (see FindNextElement).
nodeThe parent node.
Returns
A pointer to the element or NULL if the element is not found.

Definition at line 131 of file cuikurdf2world.cpp.

Referenced by main().

XMLElement * FindNextElement ( char *  label,
XMLNode **  child 
)

Continues the search started with FindFirstElement or with a previous call to FindNextElement.

Parameters
labelThe label from the element to search.
childThe child node where the start the search.
Returns
A pointer to the element or NULL if the element is not found.

Definition at line 150 of file cuikurdf2world.cpp.

Referenced by main().

int main ( int  argc,
char **  arg 
)

Main body of the cuikurdf2world application.

Use:

  • cuikurdf2world package_path problem_name.urdf [output.world]

where

  • package_path path to the root of the ROS package.
  • problem_name.urdf the URDF file to read (relative to the package path).
  • output.world is the name of the world file to create. This parameter is optional.

The .urdf extension is optional.

Parameters
argcNumber of elements in the command line that starts the application (i.e., the cuikurdf2world command itself and its arguments).
argStrings with the arguments.
Returns
EXIT_SUCCESS (0) if the execution worked out fine and EXIT_FAILURE if not.

Definition at line 190 of file cuikurdf2world.cpp.

References AddBody2Link(), AddJoint2World(), AddLink2World(), correctAngle(), CreateFileName(), DECOR_SHAPE, DefineNormalVector(), DeleteFileName(), DeleteInterval(), DeleteJoint(), DeleteLink(), DeletePolyhedron(), DeleteWorld(), Error(), FALSE, FindFirstElement(), FindNextElement(), GetFileFullName(), GetWorldLink(), GetWorldLinkID(), GetWorldNJoints(), HIDDEN_SHAPE, HTransformApply(), HTransformIdentity(), HTransformProduct(), HTransformSetElement(), HTransformTxyz(), HTransformYawPitchRoll(), INF, InitLink(), InitPolyhedronFromFile(), InitWorld(), NEW, NewBox(), NewColor(), NewCylinder(), NewFixJoint(), NewFreeJoint(), NewInterval(), NewPrismaticJoint(), NewRevoluteJoint(), NewSphere(), NO_UINT, NoCheckAllCollisions(), PrintWorld(), REP_JOINTS, TransformPolyhedron(), TRUE, and URDF_EXT.