5#ifndef __pinocchio_parsers_graph_model_graph_hpp__ 6#define __pinocchio_parsers_graph_model_graph_hpp__ 8#include "pinocchio/parsers/graph/fwd.hpp" 10#include "pinocchio/parsers/config.hpp" 12#include "pinocchio/parsers/graph/joints.hpp" 13#include "pinocchio/parsers/graph/frames.hpp" 14#include "pinocchio/parsers/graph/geometries.hpp" 18#include <boost/optional.hpp> 19#include <boost/graph/adjacency_list.hpp> 23#include <unordered_map> 42 std::vector<Geometry> geometries;
44 void addGeometry(
const Geometry & geo)
46 geometries.push_back(geo);
91 struct PINOCCHIO_PARSERS_DLLAPI ModelGraph
94 adjacency_list<boost::vecS, boost::vecS, boost::directedS, ModelGraphVertex, ModelGraphEdge>
96 typedef typename boost::graph_traits<Graph>::vertex_descriptor VertexDesc;
97 typedef typename boost::graph_traits<Graph>::edge_descriptor EdgeDesc;
99 ModelGraph() =
default;
104 void addFrame(
const std::string & vertex_name,
const FrameVariant & frame);
110 void addBody(
const std::string & vertex_name,
const Inertia & inert);
113 void addGeometry(
const std::string & vertex_name,
const Geometry & geom);
114 void addGeometries(
const std::string & vertex_name,
const std::vector<Geometry> & geoms);
129 const std::string & joint_name,
130 const JointVariant & joint,
131 const std::string & source_body,
132 const SE3 & source_to_joint,
133 const std::string & target_body,
134 const SE3 & joint_to_target);
182 boost::optional<Eigen::VectorXd>
q_ref = boost::none;
191 const std::string & jname,
192 const std::string & source_name,
194 const std::string & target_name,
196 const JointVariant &
joint,
197 const boost::optional<Eigen::VectorXd>
q_ref = boost::none);
210 boost::optional<Eigen::VectorXd> minConfig;
211 boost::optional<Eigen::VectorXd> maxConfig;
212 boost::optional<Eigen::VectorXd> maxVel;
213 boost::optional<Eigen::VectorXd> maxEffort;
214 boost::optional<Eigen::VectorXd> armature;
215 boost::optional<Eigen::VectorXd> friction;
216 boost::optional<Eigen::VectorXd> damping;
218 double frictionLoss = 0;
242 param.target_vertex = target_name;
248 param.source_vertex = source_name;
254 param.joint_to_target = target_pose;
260 param.source_to_joint = source_pose;
274 minConfig = minConfig_;
281 maxConfig = maxConfig_;
295 maxEffort = maxEffort_;
302 friction = friction_;
316 armature = armature_;
323 frictionLoss = frictionLoss_;
331 struct GeometryBuilder
334 std::string name_body;
343 GeometryBuilder & withName(
const std::string & n)
349 GeometryBuilder & withBody(
const std::string & n)
355 GeometryBuilder & withPlacement(
const SE3 & p)
357 geometry.placement = p;
361 GeometryBuilder & withScale(
const Eigen::Vector3d & s)
367 GeometryBuilder & withColor(
const Eigen::Vector4d & c)
373 GeometryBuilder & withGeomType(
const GeomType
type)
375 geometry.type =
type;
379 GeometryBuilder & withGeom(
const GeomVariant & g)
381 geometry.geometry = g;
387 if (geometry.name.empty())
388 PINOCCHIO_THROW_PRETTY(std::invalid_argument,
"Graph - geometry should have a name.");
390 return g.addGeometry(name_body, geometry);
Main pinocchio namespace.
std::string name(const LieGroupGenericTpl< LieGroupCollection > &lg)
Visit a LieGroupVariant to get the name of it.
Builder interface to add an edge to the graph. Allows for an easy customization of the edge.
EdgeBuilder & withSourcePose(const SE3 &source_pose)
Specify the pose of the joint wrt the source vertex. Default : Identity.
EdgeBuilder & withTargetVertex(const std::string &target_name)
Specify the name of the target vertex.
EdgeBuilder & withMaxEffort(const Eigen::VectorXd &maxEffort_)
Specify limit maxEffort.
EdgeParameters param
Parameters of the edge.
EdgeBuilder & withJointType(const JointVariant &jtype)
Specify the type of joint for the edge. Default : Fixed.
EdgeBuilder & withFriction(const Eigen::VectorXd &friction_)
Specify friction.
EdgeBuilder & withMinConfig(const Eigen::VectorXd &minConfig_)
Specify limit minConfig.
EdgeBuilder & withFrictionLoss(const double frictionLoss_)
Specify friction loss.
ModelGraph & g
ModelGraph to which the edge will be added.
void build()
Add the edge to the ModelGraph.
EdgeBuilder & withArmature(const Eigen::VectorXd &armature_)
Specify armature.
EdgeBuilder & withQref(const Eigen::VectorXd &qref)
Specify a bias for the joint configuration.
EdgeBuilder & withTargetPose(const SE3 &target_pose)
Specify the pose of target vertex wrt edge. Default : Identity.
EdgeBuilder & withDamping(const Eigen::VectorXd &damping_)
Specify damping.
EdgeBuilder & withMaxVel(const Eigen::VectorXd &maxVel_)
Specify limit maxVel.
EdgeBuilder(ModelGraph &graph)
Constructor.
EdgeBuilder & withName(const std::string &name)
Specify the name of the edge.
EdgeBuilder & withMaxConfig(const Eigen::VectorXd &maxConfig_)
Specify limit maxConfig.
EdgeBuilder & withSourceVertex(const std::string &source_name)
Specify the name of the source vertex.
Structure that holds all the parameters useful to create an edge.
std::string source_vertex
Source name.
SE3 joint_to_target
Placement of target wrt edge.
boost::optional< Eigen::VectorXd > q_ref
Bias for the joint.
EdgeParameters(const std::string &jname, const std::string &source_name, const SE3 &source_to_joint, const std::string &target_name, const SE3 &joint_to_target, const JointVariant &joint, const boost::optional< Eigen::VectorXd > q_ref=boost::none)
Constructor with all parameters.
std::string name
Edge name.
std::string target_vertex
Target name.
JointVariant joint
Type of joint for edge.
EdgeParameters()=default
Default Constructor.
SE3 source_to_joint
Placement of Edge wrt source vertex.
Contains information about how buildModel walked the ModelGraph to construct a Model....
bool _is_fixed
True if the root joint is fixed.
std::unordered_map< std::string, bool > _joint_forward
Map joint name to joint direction.
Represents an edge (joint) in the model graph.
SE3 joint_to_target
Transformation from edge to next vertex.
std::string name
Unique name of the joint.
bool forward
boolean to know if we are in a forward or backward edge
JointVariant joint
What is the type of the joint.
SE3 source_to_joint
Transformation from the previous vertex to edge.
JointLimits jlimit
All the limits of the joint.
Represents a vertex (body, sensor, operational frame) in the model graph.
std::string name
Unique name of the body.
Represents multibody model as a bidirectional graph.
void appendGraph(const ModelGraph &g)
add all the vertex and edges from a graph to this one. Attention : it does not add an edge between th...
void addFrame(const std::string &vertex_name, const FrameVariant &frame)
Add a new vertex to the graph.
EdgeBuilder edgeBuilder()
Create an EdgeBuilde. This will allow to use EdgeBuilder interface to have a more flexible edge confi...
std::unordered_map< std::string, VertexDesc > name_to_vertex
Name of the vertexes in the graph. Useful for graph parcours.
void addJoint(const EdgeParameters ¶ms)
Add edges (joint) to the graph. Since it's a bidirectional graph, edge and its reverse are added to t...
Graph graph
Boost graph structure that holds the graph structure.
void addJoint(const std::string &joint_name, const JointVariant &joint, const std::string &source_body, const SE3 &source_to_joint, const std::string &target_body, const SE3 &joint_to_target)
Add edges (joint) to the graph. Since it's a bidirectional graph, edge and its reverse are added to t...
void addBody(const std::string &vertex_name, const Inertia &inert)
Add a new body to the graph.