hpp-manipulation-urdf  6.0.0
Implementation of a parser for hpp-manipulation.
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/manipulation/device.hh>
#include <hpp/pinocchio/urdf/util.hh>
int main (int argc, char** argv) {
using hpp::manipulation::DevicePtr_t;
using hpp::manipulation::Device;
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", "");
}
ObjectFactory * create(ObjectFactory *parent=NULL, const XMLElement *element=NULL)
Definition: parser.hh:238
void loadModelFromFile(const DevicePtr_t &robot, const std::string &prefix, const std::string &package, const std::string &modelName, const std::string &srdfSuffix)

SRDF syntax

Handle

<handle name="name" clearance="value">
<!-- Exactly 1 -->
<!-- One of the following position tag. Attributes are optional and read only if the tag has no text. -->
<position>0 0 0 1 0 0 0</position>
<position xyz="0 0 0" rpy="0 0 0"/>
<position xyz="0 0 0" wxyz="1 0 0 0"/>
<position xyz="0 0 0" xyzw="0 0 0 1"/>
<!-- the position represents the position of the handle relatively to the following link -->
<link name="link_name" />
N4
{␚\␅
{␚\␅
-->
<mask>1 1 1 0 0 0</mask>
</handle>

Gripper

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

Contact

<contact name="name">
<!-- Exactly 1 of -->
N4
{␚\␅
3U
{␚\␅
{␚\␅
{␚\␅
5}␚\␅
-->
<link name="link_name" />
<link name="link_name" index="index_collision_object" />
<!-- Exactly 1 -->
<!-- Sequence of 3D points expressed in the frame defined above -->
<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>
␄U
{␚\␅
{␚\␅
␄U
={U
firstSegment ^ secondSegment must points outside the object -->
<shape> 3 0 2 1 3 2 1 3</shape>
<!-- DEPRECATED -->
.U
={U
01 ^ 02 points outside the object -->
<triangle> 0 2 1 2 1 3</triangle>
</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> ();
Transform3s 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>);
}
Class that catch XML Parser events for a specific tag and build the corresponding Object.
Definition: parser.hh:85
Parse an XML document.
Definition: parser.hh:248
std::string prependPrefix(const std::string &in) const
Definition: parser.hh:212
tinyxml2::XMLElement XMLElement
Definition: parser.hh:43
See also
parser::ObjectFactory