cuikworld2sdf.cpp File Reference

Introduction

dot_inline_dotgraph_57.png

Main body of the cuikworld2sdf application. This application reads the information in a world file and generates an equivalent SDF file.

SDF files are the input files for Gazebo. See the SDF format specification for more details.

This application is our first attempt to interface the CuikPackages with Gazebo. The idea is to obtain nicer mechanisms simulations, including dynamical aspects. Beside the generation of SDF files, we would also need to implement a cuikgazeboplayer (i.e., a way to command gazefo robots from the cuik outputs).

Note that we implement a world2sdf and not a world2urdf. This is because the urdf is a severily liminted format which can not handle kinematic loops, the fundamental construction in the CuikSuite. Here you have a very nice argument about why to use the SDF format instead of the URDF one.

CAUTION: This application is in development and not tested at all yet (we need to install Gazebo to test it properly). Up to now, links seems to be correctly exported but conversion of joints is still to be tested.

Todo:
Test the generation of sdf joints from cuik joints.
Todo:
Implement the generation of sdf sph-sph and sph-prs-sph joints.
Todo:
Implement the cuikgazeboplayer. Probably as a trivial ROS node moving different degrees of freedom.

Definition in file cuikworld2sdf.cpp.

Functions

void body2SDF (char *path, char *folder, char *linkName, XMLDocument *sdf, XMLElement *link, unsigned int j, Tpolyhedron *b)
 Generates the sdf code for a given body. More...
 
XMLElement * jointHeader2SDF (unsigned int id, char *pName, char *cName, XMLElement *model, XMLDocument *sdf)
 Defines the header of a joint in sdf. More...
 
void axis2SDF (char *label, double *p1, double *p2, boolean parentFrame, THTransform *tp, THTransform *tc, THTransform *tj, double ve, double ef, double fr, double da, boolean limited, Tinterval *range, XMLDocument *sdf, XMLElement *joint)
 Generates the sdf code for a given joint axis. More...
 
int main (int argc, char **arg)
 Main body of the cuikworld2sdf application. More...
 

Function Documentation

◆ body2SDF()

void body2SDF ( char *  path,
char *  folder,
char *  linkName,
XMLDocument *  sdf,
XMLElement *  link,
unsigned int  j,
Tpolyhedron b 
)

Generates the sdf code for a given body in a link (might be a static link, i.e., the world).

Parameters
pathPath of the sdf file being generated.
folderFolder where files are stored (typically, the last part of the path).
linkNameName of the link being generated (might be world).
sdfThe sdf document being generated.
linkThe link element being generated.
jThe identifier of the body in the link.
bThe body to be processed.

Definition at line 139 of file cuikworld2sdf.cpp.

References CreateFileName(), CYLINDER, DeleteFileName(), DifferenceVector(), EMPTY_BODY, Error(), GetBlue(), GetFileFullName(), GetGreen(), GetPolyhedronCenter(), GetPolyhedronColor(), GetPolyhedronDefiningPoint(), GetPolyhedronRadius(), GetPolyhedronStatus(), GetPolyhedronType(), GetRed(), GetYawPitchRoll(), HIDDEN_SHAPE, HTransformGetElement(), HTransformProduct(), HTransformRy(), HTransformTz(), HTransformX2Vect(), LINE, M_PI_2, Norm(), Normalize(), OFF, SEGMENTS, SPHERE, SumVector(), and WriteDAEMesh().

Referenced by main().

◆ jointHeader2SDF()

XMLElement * jointHeader2SDF ( unsigned int  id,
char *  pName,
char *  cName,
XMLElement *  model,
XMLDocument *  sdf 
)

Adds the header of a joint definition in sdf.

Parameters
idThe identifier of the joint.
pNameName of the parent link.
cNameName of the child link.
modelThe sdf model being defined.
sdfThe sdf document being defined.
Returns
The joint defined.

Definition at line 279 of file cuikworld2sdf.cpp.

Referenced by main().

◆ axis2SDF()

void axis2SDF ( char *  label,
double *  p1,
double *  p2,
boolean  parentFrame,
THTransform tp,
THTransform tc,
THTransform tj,
double  ve,
double  ef,
double  fr,
double  da,
boolean  limited,
Tinterval range,
XMLDocument *  sdf,
XMLElement *  joint 
)

Generates the sdf code for a given joint axis (used in revolute, prismatic, universal joints)

Parameters
labelName of the axis: axis or axis2.
p1First point defining the axis.
p2Second point defining the axis.
parentFrameTRUE if the axis is defined in the paren frame.
tpTransform giving the pose of the parent link.
tcTransform giving the pose of the child link.
tjTransform giving the joint location.
veMaximum velocity of the joint.
efMaximum effort of the joint.
frFriction of the joint.
daDamping of the joint.
limitedTrue for joints with limits.
rangeIf the joint is limited, the corresponding range.
sdfThe sdf document bein generated.
jointThe joint element being generated.

Definition at line 301 of file cuikworld2sdf.cpp.

References DifferenceVector(), GetYawPitchRoll(), HTransformGetElement(), HTransformInverse(), HTransformProduct(), INF, LowerLimit(), Normalize(), and UpperLimit().

Referenced by main().

◆ main()

int main ( int  argc,
char **  arg 
)

Main body of the cuikworld2sdf application.

Use:

  • cuikworld2sdf world_filename.world folder [sdf_filename.sdf]

where

  • world_filename Name of the world file to translate.
  • folder Folder where to store the generated sdf and related files.
  • sdf_filename.sdf Name of the SDF file to generate. If not given, the world filename with extension .sdf is used.

The .world and .sdf extensions are optional.

The idea is to generate all the files in a given folder that can be moved/linked to/from the gazebo model directory (typically .gazebo/models).

Example of use:

  • bin/cuikworld2sdf examples/Jaco/jaco sdf

Then open the sdf/jaco.sdf in gazebo.

Parameters
argcNumber of elements in the command line that starts the application (i.e., the cuikworld2sdf 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 430 of file cuikworld2sdf.cpp.

References axis2SDF(), body2SDF(), CreateFileName(), DeleteFileName(), DeleteLinkTransforms(), DeleteParameters(), DeleteWorld(), Error(), FALSE, FIX_JOINT, FREE_JOINT, GetFileFullName(), GetFileName(), GetFilePath(), GetJointDamping(), GetJointEffort(), GetJointFrame(), GetJointFriction(), GetJointPoint(), GetJointRange(), GetJointSecondRange(), GetJointType(), GetJointVelocity(), GetLinkBody(), GetLinkConfExtension(), GetLinkInertialFrame(), GetLinkInertiaMatrix(), GetLinkMass(), GetLinkName(), GetLinkTransformsFromSolutionPoint(), GetLinkType(), GetWorldJoint(), GetWorldLink(), GetWorldNJoints(), GetWorldNLinks(), GetWorldNObstacles(), GetWorldNumSystemVariables(), GetWorldObstacle(), GetWorldObstacleName(), GetYawPitchRoll(), HTransformAcumTrans(), HTransformApplyRot(), HTransformCopy(), HTransformGetElement(), InitParametersFromFile(), InitWorldFromFile(), JointFrom(), JointFromID(), jointHeader2SDF(), JointTo(), JointToID(), LimitedJoint(), LINK_DeformX, LINK_NoRot, LINK_PrismaticX, LinkNBodies(), NEW, PARAM_EXT, PRS_JOINT, ReadOneSample(), REV_JOINT, SDF_EXT, SPH_JOINT, SPH_SPH_LOW_JOINT, SPH_SPH_UP_JOINT, SumVector(), TRUE, and UNV_JOINT.