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;
pinocchio::urdf::loadUrdfModel (robot, "freeflyer", "hrp2",
"hrp2_14_description", "hrp2_14", "", "");
"hrp2_14_description", "hrp2_14", "");
}
SRDF syntax
Handle
1 <
handle name=
"name" clearance=
"value">
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"/>
9 <
link name=
"link_name" />
Gripper
1 <
gripper name=
"name" clearance=
"value">
4 <
position xyz=
"0 0 0" rpy=
"0 0 0"/>
6 <
link name=
"link_name" />
Contact
12 <
link name=
"link_name" />
13 <
link name=
"link_name" index=
"index_collision_object" />
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>
26 <
shape> 3 0 2 1 3 2 1 3</
shape>
32 <
triangle> 0 2 1 2 1 3</
triangle>
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:
public:
YourFactory (ObjectFactory* parent,
const XMLElement* element) :
ObjectFactory (parent, element)
{}
void YourFactory::finishTags ()
{
ObjectFactory* o (NULL);
if (!getChildOfType ("position", o)) {
}
PositionFactory* pf = o->as <PositionFactory> ();
if (!getChildOfType ("link", o)) {
}
if (!root ()->device ()) {
hppDout (error,
"Device not found");
return;
}
root ()->
device ()->yourfunction (linkName, position);
}
};
int main (int argc, char** argv) {
p.addObjectFactory ("tagname", hpp::manipulation::parser::create <YourFactory>);
}
- See also
- parser::ObjectFactory