Go to the documentation of this file.
26 #ifndef TESSERACT_SCENE_GRAPH_GRAPH_H
27 #define TESSERACT_SCENE_GRAPH_GRAPH_H
31 #include <boost/serialization/export.hpp>
32 #include <boost/graph/adjacency_list.hpp>
33 #include <boost/graph/properties.hpp>
35 #include <unordered_map>
36 #include <Eigen/Geometry>
91 boost::property<boost::graph_name_t, std::string, boost::property<boost::graph_root_t, std::string>>;
96 std::shared_ptr<Link>,
97 boost::property<boost::vertex_link_visible_t, bool, boost::property<boost::vertex_link_collision_enabled_t, bool>>>;
105 boost::property<boost::edge_joint_t, std::shared_ptr<Joint>, boost::property<boost::edge_weight_t, double>>;
107 using Graph = boost::
108 adjacency_list<boost::listS, boost::listS, boost::bidirectionalS, VertexProperty, EdgeProperty, GraphProperty>;
128 public boost::noncopyable
132 using Vertex = SceneGraph::vertex_descriptor;
133 using Edge = SceneGraph::edge_descriptor;
135 using Ptr = std::shared_ptr<SceneGraph>;
136 using ConstPtr = std::shared_ptr<const SceneGraph>;
137 using UPtr = std::unique_ptr<SceneGraph>;
162 void setName(
const std::string& name);
168 const std::string&
getName()
const;
175 bool setRoot(
const std::string& name);
181 const std::string&
getRoot()
const;
192 bool addLink(
const Link& link,
bool replace_allowed =
false);
210 std::shared_ptr<const Link>
getLink(
const std::string& name)
const;
216 std::vector<std::shared_ptr<const Link>>
getLinks()
const;
222 std::vector<std::shared_ptr<const Link>>
getLeafLinks()
const;
233 bool removeLink(
const std::string& name,
bool recursive =
false);
280 std::shared_ptr<const Joint>
getJoint(
const std::string& name)
const;
288 bool removeJoint(
const std::string& name,
bool recursive =
false);
296 bool moveJoint(
const std::string& name,
const std::string& parent_link);
302 std::vector<std::shared_ptr<const Joint>>
getJoints()
const;
315 bool changeJointOrigin(
const std::string& name,
const Eigen::Isometry3d& new_origin);
362 std::shared_ptr<const JointLimits>
getJointLimits(
const std::string& name);
376 void addAllowedCollision(
const std::string& link_name1,
const std::string& link_name2,
const std::string& reason);
400 bool isCollisionAllowed(
const std::string& link_name1,
const std::string& link_name2)
const;
419 std::shared_ptr<const Link>
getSourceLink(
const std::string& joint_name)
const;
426 std::shared_ptr<const Link>
getTargetLink(
const std::string& joint_name)
const;
437 std::vector<std::shared_ptr<const Joint>>
getInboundJoints(
const std::string& link_name)
const;
448 std::vector<std::shared_ptr<const Joint>>
getOutboundJoints(
const std::string& link_name)
const;
502 std::unordered_map<std::string, std::string>
getAdjacencyMap(
const std::vector<std::string>& link_names)
const;
516 void saveDOT(
const std::string& path)
const;
565 const std::string& prefix =
"");
580 bool addLinkHelper(
const std::shared_ptr<Link>& link_ptr,
bool replace_allowed =
false);
592 std::unordered_map<std::string, std::pair<std::shared_ptr<Joint>,
Edge>>
joint_map_;
593 std::shared_ptr<tesseract_common::AllowedCollisionMatrix>
acm_;
610 template <
class Archive>
611 void save(Archive& ar,
const unsigned int version)
const;
613 template <
class Archive>
614 void load(Archive& ar,
const unsigned int version);
616 template <
class Archive>
617 void serialize(Archive& ar,
const unsigned int version);
626 #endif // TESSERACT_SCENE_GRAPH_GRAPH_H
std::unordered_map< std::string, std::pair< std::shared_ptr< Link >, Vertex > > link_map_
boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS, VertexProperty, EdgeProperty, GraphProperty > Graph
vertex_link_collision_enabled_t
std::vector< std::string > getLinkChildrenHelper(Vertex start_vertex) const
Get the children of a vertex starting with start_vertex.
void save(Archive &ar, const unsigned int version) const
bool setRoot(const std::string &name)
Sets the root link name (aka. World Coordinate Frame)
boost::property< boost::graph_name_t, std::string, boost::property< boost::graph_root_t, std::string > > GraphProperty
Defines the boost graph property.
bool getLinkCollisionEnabled(const std::string &name) const
Get whether a link should be considered during collision checking.
SceneGraph::vertex_descriptor Vertex
SceneGraph::UPtr clone() const
Clone the scene graph.
void saveDOT(const std::string &path) const
Saves Graph as Graph Description Language (DOT)
void setLinkCollisionEnabled(const std::string &name, bool enabled)
Set whether a link should be considered during collision checking.
bool changeJointVelocityLimits(const std::string &name, double limit)
Changes the velocity limits associated with a joint.
std::vector< std::shared_ptr< const Link > > getLinks() const
Get a vector links in the scene graph.
friend class boost::serialization::access
bool changeJointLimits(const std::string &name, const JointLimits &limits)
Changes the limits of a joint. The JointLimits::Ptr remains the same, but the values passed in are as...
bool isTree() const
Determine if the graph is a tree.
bool changeJointPositionLimits(const std::string &name, double lower, double upper)
Changes the position limits associated with a joint.
std::vector< std::string > active_joints
A list of active joints along the shortest path.
std::vector< std::shared_ptr< const Joint > > getJoints() const
Get a vector of joints in the scene graph.
@ vertex_link_collision_enabled
std::shared_ptr< const tesseract_common::AllowedCollisionMatrix > getAllowedCollisionMatrix() const
Get the allowed collision matrix.
void addAllowedCollision(const std::string &link_name1, const std::string &link_name2, const std::string &reason)
Disable collision between two collision objects.
std::shared_ptr< const JointLimits > getJointLimits(const std::string &name)
Gets the limits of the joint specified by name.
SceneGraph::edge_descriptor Edge
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
boost::property< boost::edge_joint_t, std::shared_ptr< Joint >, boost::property< boost::edge_weight_t, double > > EdgeProperty
EdgeProperty.
bool moveJoint(const std::string &name, const std::string &parent_link)
Move joint to new parent link.
std::vector< std::shared_ptr< const Joint > > getOutboundJoints(const std::string &link_name) const
Get outbound joints for a link.
bool operator==(const SceneGraph &rhs) const
bool addLink(const Link &link, bool replace_allowed=false)
Adds a link to the graph.
bool addJointHelper(const std::shared_ptr< Joint > &joint_ptr)
Adds joint to the graph.
BOOST_INSTALL_PROPERTY(vertex, link)
std::unique_ptr< SceneGraph > UPtr
std::vector< std::string > getAdjacentLinkNames(const std::string &name) const
Get a vector of adjacent link names provided a link name.
const std::string & getName() const
Sets the graph name.
std::vector< std::string > getInvAdjacentLinkNames(const std::string &name) const
Geta a vectpr pf inverse adjacent link names provided a link name.
void removeAllowedCollision(const std::string &link_name1, const std::string &link_name2)
Remove disabled collision pair from allowed collision matrix.
std::shared_ptr< const SceneGraph > ConstPtr
bool isCollisionAllowed(const std::string &link_name1, const std::string &link_name2) const
Check if two links are allowed to be in collision.
bool removeJoint(const std::string &name, bool recursive=false)
Removes a joint from the graph.
std::shared_ptr< tesseract_common::AllowedCollisionMatrix > acm_
bool changeJointOrigin(const std::string &name, const Eigen::Isometry3d &new_origin)
Changes the "origin" transform of the joint and recomputes the associated edge.
bool moveLink(const Joint &joint)
Move link defined by provided joint This deletes all inbound joints on the parent link defined by the...
boost::property< boost::vertex_link_t, std::shared_ptr< Link >, boost::property< boost::vertex_link_visible_t, bool, boost::property< boost::vertex_link_collision_enabled_t, bool > >> VertexProperty
Defines the boost graph vertex property.
Edge getEdge(const std::string &name) const
Get the graph edge by name.
ShortestPath getShortestPath(const std::string &root, const std::string &tip) const
Get the shortest path between two links.
bool addJoint(const Joint &joint)
Adds joint to the graph.
void setAllowedCollisionMatrix(std::shared_ptr< tesseract_common::AllowedCollisionMatrix > acm)
Set the allowed collision matrix.
std::vector< std::shared_ptr< const Joint > > getInboundJoints(const std::string &link_name) const
Get inbound joints for a link.
bool getLinkVisibility(const std::string &name) const
Get a given links visibility setting.
std::shared_ptr< const Link > getSourceLink(const std::string &joint_name) const
Get the source link (parent link) for a joint.
std::vector< std::string > getJointChildrenNames(const std::string &name) const
Get all children link names for a given joint name.
bool insertSceneGraph(const tesseract_scene_graph::SceneGraph &scene_graph, const std::string &prefix="")
Merge a graph into the current graph.
void load(Archive &ar, const unsigned int version)
std::vector< std::shared_ptr< const Joint > > getActiveJoints() const
Get a vector of active joints in the scene graph.
std::shared_ptr< const Link > getTargetLink(const std::string &joint_name) const
Get the target link (child link) for a joint.
std::unique_ptr< const SceneGraph > ConstUPtr
Holds the shortest path information.
std::vector< std::string > joints
A list of joints along the shortest path.
bool addLinkHelper(const std::shared_ptr< Link > &link_ptr, bool replace_allowed=false)
Adds a link to the graph.
void clearAllowedCollisions()
Remove all allowed collisions.
bool isEmpty() const
Check if the graph is empty.
#define TESSERACT_COMMON_IGNORE_WARNINGS_POP
void setName(const std::string &name)
Sets the graph name.
bool operator!=(const SceneGraph &rhs) const
const std::string & getRoot() const
Gets the root link name (aka. World Coordinate Frame)
std::shared_ptr< const Joint > getJoint(const std::string &name) const
Get a joint in the graph.
std::ostream & operator<<(std::ostream &os, const ShortestPath &path)
bool changeJointJerkLimits(const std::string &name, double limit)
Changes the jerk limits associated with a joint.
std::vector< std::shared_ptr< const Link > > getLeafLinks() const
Get a vector leaf links in the scene graph.
bool removeLink(const std::string &name, bool recursive=false)
Removes a link from the graph.
std::unordered_map< std::string, std::pair< std::shared_ptr< Joint >, Edge > > joint_map_
void rebuildLinkAndJointMaps()
The rebuild the link and joint map by extraction information from the graph.
void setLinkVisibility(const std::string &name, bool visibility)
Set a links visibility.
void serialize(Archive &ar, const unsigned int version)
bool changeJointAccelerationLimits(const std::string &name, double limit)
Changes the acceleration limits associated with a joint.
std::shared_ptr< const Link > getLink(const std::string &name) const
Get a link in the graph.
std::vector< std::string > links
a list of links along the shortest path
std::unordered_map< std::string, std::string > getAdjacencyMap(const std::vector< std::string > &link_names) const
Create mapping between links in the scene to the provided links if they are directly affected if the ...
Vertex getVertex(const std::string &name) const
Get the graph vertex by name.
std::shared_ptr< SceneGraph > Ptr
bool isAcyclic() const
Determine if the graph contains cycles.
SceneGraph(const std::string &name="")
SceneGraph & operator=(const SceneGraph &other)=delete
void clear()
Clear the scene graph.
std::vector< std::string > getLinkChildrenNames(const std::string &name) const
Get all children for a given link name.