hpp-manipulation-urdf Documentation

Basic use

The library contains parser for SRDF describing robot grippers, object handles, object and environment contact surfaces.

In order to load HRP2 from a pair of URDF and SRDF files, one can do:

#include <hpp/pinocchio/urdf/util.hh>
int main (int argc, char** argv) {
using hpp::manipulation::srdf::loadRobotModel;
DevicePtr_t robot = Device::create ("hrp2");
pinocchio::urdf::loadUrdfModel (robot, "freeflyer", "hrp2",
"hrp2_14_description", "hrp2_14", "", "");
loadModelFromFile (robot, "hrp2",
"hrp2_14_description", "hrp2_14", "");
}

SRDF syntax

Handle

1 <handle name="name" clearance="value">
2  <!-- Exactly 1 -->
3  <!-- One of the following position tag. Attributes are optional and read only if the tag has no text. -->
4  <position>0 0 0 1 0 0 0</position>
5  <position xyz="0 0 0" rpy="0 0 0"/>
6  <position xyz="0 0 0" wxyz="1 0 0 0"/>
7  <position xyz="0 0 0" xyzw="0 0 0 1"/>
8  <!-- the position represents the position of the handle relatively to the following link -->
9  <link name="link_name" />
10 </handle>

Gripper

1 <gripper name="name" clearance="value">
2  <!-- Exactly 1 -->
3  <!-- A position tag. See handle tag for more details. -->
4  <position xyz="0 0 0" rpy="0 0 0"/>
5  <!-- the position represents the position of the gripper relatively to the following link -->
6  <link name="link_name" />
7 </gripper>

Contact

1 <contact name="name">
2  <!-- Exactly 1 of -->
3  <!-- Set the link used to build the reference frame
4  In the first case, the position of the points below are expressed in the
5  link frame.
6 
7  In the second case, the position of the points below are expressed in the
8  frame of the "index_collision_object"th collision body in the link. If
9  you have only one body, then set it to zero. This is a convenient way of
10  of defining surfaces on a particular body.
11  -->
12  <link name="link_name" />
13  <link name="link_name" index="index_collision_object" />
14 
15  <!-- Exactly 1 -->
16  <!-- Sequence of 3D points expressed in the frame defined above -->
17  <point>-0.025 -0.025 -0.025 -0.025 0.025 -0.025 -0.025 -0.025 0.025 -0.025 0.025 0.025 </point>
18 
19  <!-- Sequence of planar shape.
20  Shapes are defined by a sequence of points to be connected (consecutively).
21  For a shape defined by N points, N+1 values must be provided in this tag:
22  N iPoint_1 ... iPoint_N
23 
24  WARNING: Shapes 3 0 1 2 and 3 0 2 1 are different because their respective orientations are opposites.
25  firstSegment ^ secondSegment must points outside the object -->
26  <shape> 3 0 2 1 3 2 1 3</shape>
27 
28  <!-- DEPRECATED -->
29  <!-- Sequence of triangles, where a triangle is 3 point indexes in the above list of points
30  WARNING: Triangle 0 1 2 and 0 2 1 are different because their respective orientations are opposites
31  01 ^ 02 points outside the object -->
32  <triangle> 0 2 1 2 1 3</triangle>
33 </contact>

Extend the parser

To extend the parser, you must write a class that inherits from parser::ObjectFactory. Some factories such as parser::SequenceFactory might be useful. You also have to declare the new factory to the parser:

// See ObjectFactory documentation for more details.
// This factory parses something like:
// <tagname>
// <position>0 0 0 1 0 0 0</position>
// <link name="linkname"/>
// </tagname>
class YourFactory : public hpp::manipulation::parser::ObjectFactory {
public:
YourFactory (ObjectFactory* parent, const XMLElement* element) :
ObjectFactory (parent, element)
{}
void YourFactory::finishTags ()
{
ObjectFactory* o (NULL);
if (!getChildOfType ("position", o)) {
// There is more than one tag <position>
// o is a pointer to the first one.
}
PositionFactory* pf = o->as <PositionFactory> ();
Transform3f position = pf->position ();
if (!getChildOfType ("link", o)) {
// There is more than one tag <link>
// o is a pointer to the first one.
}
std::string linkName = root ()->prependPrefix (o->name ());
if (!root ()->device ()) {
hppDout (error, "Device not found");
return;
}
root ()->device ()->yourfunction (linkName, position);
}
};
int main (int argc, char** argv) {
// Parameter false tells the constructor not to include default factories.
p.addObjectFactory ("tagname", hpp::manipulation::parser::create <YourFactory>);
}
See also
parser::ObjectFactory