Robowflex
v0.1
Making MoveIt Easy
|
Wrapper class around the planning scene and collision geometry. More...
#include <scene.h>
Classes | |
class | CollisionPluginLoader |
The actual plugin loader for collision plugins. Heavily inspired by code in moveit_ros/planning. More... | |
Public Member Functions | |
Scene (const RobotConstPtr &robot) | |
Constructor. More... | |
Scene (const robot_model::RobotModelConstPtr &robot) | |
Constructor. More... | |
Scene (const Scene &scene) | |
Copy Constructor. More... | |
void | operator= (const Scene &scene) |
Assignment Copy Constructor. More... | |
ScenePtr | deepCopy () const |
Deep Copy. More... | |
Getters and Setters | |
const planning_scene::PlanningScenePtr & | getSceneConst () const |
Get a const reference to the planning scene. More... | |
planning_scene::PlanningScenePtr & | getScene () |
Get a reference to the planning scene. More... | |
moveit_msgs::PlanningScene | getMessage () const |
Get the message that describes the current planning scene. More... | |
robot_state::RobotState & | getCurrentState () |
Get a reference to the current robot state in the planning scene. More... | |
const robot_state::RobotState & | getCurrentStateConst () const |
Get a constant reference to the current robot state in the planning scene. More... | |
collision_detection::AllowedCollisionMatrix & | getACM () |
Get the current allowed collision matrix of the planning scene. More... | |
const collision_detection::AllowedCollisionMatrix & | getACMConst () const |
Get the current allowed collision matrix of the planning scene. More... | |
void | useMessage (const moveit_msgs::PlanningScene &msg, bool diff=false) |
Set the planning scene to be the same as a message. More... | |
Collision Object Management | |
void | updateCollisionObject (const std::string &name, const GeometryConstPtr &geometry, const RobotPose &pose) |
Adds or updates collision object in the planning scene. If the geometry reference is the same, the collision object is updated. Otherwise, the old object named name is deleted and a new one is created. More... | |
bool | hasObject (const std::string &name) const |
Returns true if the object name is in the scene. More... | |
std::vector< std::string > | getCollisionObjects () const |
Returns a list of all the names of collision objects in the scene. More... | |
GeometryPtr | getObjectGeometry (const std::string &name) const |
Returns a representation of a collision object in the scene as a Geometry. If the object has multiple geometries, returns the first. More... | |
void | removeCollisionObject (const std::string &name) |
Removes an object from the planning scene. More... | |
RobotPose | getObjectPose (const std::string &name) const |
Get the current pose of a collision object. If the object has multiple geometries, returns the pose of the first. More... | |
RobotPose | getObjectGraspPose (const std::string &name, const RobotPose &offset) const |
Get a pose in the global frame relative to a collision object for grasping. More... | |
bool | moveAllObjectsGlobal (const RobotPose &transform) |
Move all objects according to a transform specified in world frame. More... | |
bool | moveObjectGlobal (const std::string &name, const RobotPose &transform) |
Move all shapes in an object according to the given transform specified in world frame. More... | |
bool | moveObjectLocal (const std::string &name, const RobotPose &transform) |
Move all shapes in an object according to the given transform specified in object frame. If the object has multiple shapes, the first one is considered the local frame. More... | |
RobotPose | getFramePose (const std::string &id) const |
Get the pose of a particular frame in the scene. Example, use this to get the pose from /world to /base_link. More... | |
bool | setCollisionDetector (const std::string &detector_name) const |
Attempts to set the collision detector plugin used by the scene to name. In MoveIt by default, 'Hybrid' is the only plugin defined. However, you can define your own libraries that contain classes that extend the collision_detection::CollisionPlugin class, and load them here as well. See http://moveit.ros.org/documentation/plugins/#collisionplugin for more details. More... | |
bool | attachObjectToState (robot_state::RobotState &state, const std::string &name) const |
Attach the named collision object name to the default end-effector of the given robot state. Only works if there is one end-effector in the system. Uses all end-effector links as allowed touch links. More... | |
bool | attachObjectToState (robot_state::RobotState &state, const std::string &name, const std::string &ee_link, const std::vector< std::string > &touch_links) const |
Attach the named collision object name to the link ee_link of the given robot state. More... | |
bool | attachObject (const std::string &name) |
Helper function that attaches object to internal state and removes from scene. More... | |
bool | attachObject (robot_state::RobotState &state, const std::string &name) |
Helper function that attaches object provided state and removes from scene. More... | |
bool | attachObject (robot_state::RobotState &state, const std::string &name, const std::string &ee_link, const std::vector< std::string > &touch_links) |
Helper function that attaches object provided state and removes from scene. More... | |
bool | detachObject (const std::string &name) |
Helper function that detaches the object from the internal scene state. More... | |
bool | detachObject (robot_state::RobotState &state, const std::string &name) |
Detach an object name from the robot state. More... | |
Checking Collisions | |
collision_detection::CollisionResult | checkCollision (const robot_state::RobotState &state, const collision_detection::CollisionRequest &request={}) const |
Check if a robot state is in collision. More... | |
double | distanceToCollision (const robot_state::RobotState &state) const |
Get the distance to collision for a robot state. More... | |
double | distanceToObject (const robot_state::RobotState &state, const std::string &object) const |
Get the distance to collision to a specific object. More... | |
double | distanceBetweenObjects (const std::string &one, const std::string &two) const |
Get the distance to collision between two collision objects in the scene. More... | |
double | distanceACM (const robot_state::RobotState &state, const collision_detection::AllowedCollisionMatrix &acm) const |
Get the distance to collision using an ACM. More... | |
void | clearACM (collision_detection::AllowedCollisionMatrix &acm) const |
Disables collision between all entries in the ACM (all robot links and objects in the scene) More... | |
moveit::core::GroupStateValidityCallbackFn | getGSVCF (bool verbose) const |
Get the group state validity callback function that uses this scene. More... | |
IO | |
bool | toYAMLFile (const std::string &file) const |
Serialize the current planning scene to a YAML file. More... | |
bool | fromYAMLFile (const std::string &file) |
Load a planning scene from a YAML file. More... | |
bool | fromOpenRAVEXMLFile (const std::string &file, std::string models_dir="") |
Public Member Functions inherited from robowflex::ID | |
ID () | |
Constructor. More... | |
const std::string & | getID () const |
Get the unique ID for this object. More... | |
std::size_t | getVersion () const |
Get the current version of this object. More... | |
Key | getKey () const |
Get this ID as a Key. More... | |
bool | operator== (const ID &b) const |
Compare with another ID object. More... | |
bool | operator== (const Key &b) const |
Compare with an ID Key. More... | |
Private Member Functions | |
void | fixCollisionObjectFrame (moveit_msgs::PlanningScene &msg) |
Corrects frame mismatches on loaded scenes by using the current root frame instead. More... | |
Private Attributes | |
CollisionPluginLoaderPtr | loader_ |
Plugin loader that sets collision detectors for the scene. More... | |
planning_scene::PlanningScenePtr | scene_ |
Underlying planning scene. More... | |
Additional Inherited Members | |
Public Types inherited from robowflex::ID | |
using | Key = std::pair< std::string, std::size_t > |
A snapshot of the state of an ID. Can be compared against another ID. More... | |
Static Public Member Functions inherited from robowflex::ID | |
static Key | getNullKey () |
Get a null key for initialization. More... | |
Protected Member Functions inherited from robowflex::ID | |
void | incrementVersion () |
Increment the version number of this object. More... | |
Wrapper class around the planning scene and collision geometry.
The Scene class is a wrapper around MoveIt!'s planning_scene::PlanningScene, providing access to set and manipulate collision objects, attach and detach objects to the robot, and so on. There are also utilities to load and save planning scenes from YAML files (toYAMLFile() and fromYAMLFile()). Note that this class has its own robot state, separate from the one in the provided Robot. Information between this state and the Robot's scratch state are not synchronized, you must do this manually.
Scene::Scene | ( | const RobotConstPtr & | robot | ) |
Constructor.
[in] | robot | Robot to construct planning scene for. |
Definition at line 145 of file scene.cpp.
Scene::Scene | ( | const robot_model::RobotModelConstPtr & | robot | ) |
Scene::Scene | ( | const Scene & | scene | ) |
bool Scene::attachObject | ( | const std::string & | name | ) |
Helper function that attaches object to internal state and removes from scene.
[in] | name | Name of object to attach to robot and remove from scene. |
Definition at line 403 of file scene.cpp.
bool Scene::attachObject | ( | robot_state::RobotState & | state, |
const std::string & | name | ||
) |
Helper function that attaches object provided state and removes from scene.
[in] | name | Name of object to attach to robot and remove from scene. |
Definition at line 408 of file scene.cpp.
bool Scene::attachObject | ( | robot_state::RobotState & | state, |
const std::string & | name, | ||
const std::string & | ee_link, | ||
const std::vector< std::string > & | touch_links | ||
) |
Helper function that attaches object provided state and removes from scene.
[in] | state | State of the robot to attach to. |
[in] | name | Name of object to attach to. |
[in] | ee_link | Link to attach object to. |
[in] | touch_links | Links the object is allowed to touch. |
Definition at line 419 of file scene.cpp.
bool Scene::attachObjectToState | ( | robot_state::RobotState & | state, |
const std::string & | name | ||
) | const |
Attach the named collision object name to the default end-effector of the given robot state. Only works if there is one end-effector in the system. Uses all end-effector links as allowed touch links.
[in] | name | Name of collision to attach. |
[in] | state | State of robot the object will be attached to |
Definition at line 354 of file scene.cpp.
bool Scene::attachObjectToState | ( | robot_state::RobotState & | state, |
const std::string & | name, | ||
const std::string & | ee_link, | ||
const std::vector< std::string > & | touch_links | ||
) | const |
Attach the named collision object name to the link ee_link of the given robot state.
[in] | state | State of the robot to attach. |
[in] | name | Name of object to attach. |
[in] | ee_link | Link to attach object to. |
[in] | touch_links | Links the object is allowed to touch. |
Definition at line 369 of file scene.cpp.
collision_detection::CollisionResult Scene::checkCollision | ( | const robot_state::RobotState & | state, |
const collision_detection::CollisionRequest & | request = {} |
||
) | const |
void Scene::clearACM | ( | collision_detection::AllowedCollisionMatrix & | acm | ) | const |
Disables collision between all entries in the ACM (all robot links and objects in the scene)
[in,out] | acm | ACM to clear. |
Definition at line 496 of file scene.cpp.
ScenePtr Scene::deepCopy | ( | ) | const |
Deep Copy.
Definition at line 165 of file scene.cpp.
bool Scene::detachObject | ( | const std::string & | name | ) |
Helper function that detaches the object from the internal scene state.
[in] | name | Name of collision to detach. |
Definition at line 437 of file scene.cpp.
bool Scene::detachObject | ( | robot_state::RobotState & | state, |
const std::string & | name | ||
) |
Detach an object name from the robot state.
[in] | state | State to detatch the object from. |
[in] | name | Name of collision to detach. |
Definition at line 442 of file scene.cpp.
double Scene::distanceACM | ( | const robot_state::RobotState & | state, |
const collision_detection::AllowedCollisionMatrix & | acm | ||
) | const |
Get the distance to collision using an ACM.
[in] | state | State of the robot. |
[in] | one | acm ACM to use for distance check. |
Definition at line 480 of file scene.cpp.
double Scene::distanceBetweenObjects | ( | const std::string & | one, |
const std::string & | two | ||
) | const |
Get the distance to collision between two collision objects in the scene.
[in] | one | One of the objects to check. |
[in] | two | The other object to check. |
Definition at line 535 of file scene.cpp.
double Scene::distanceToCollision | ( | const robot_state::RobotState & | state | ) | const |
double Scene::distanceToObject | ( | const robot_state::RobotState & | state, |
const std::string & | object | ||
) | const |
|
private |
Corrects frame mismatches on loaded scenes by using the current root frame instead.
[in,out] | msg | Message to correct frame names for. |
bool Scene::fromOpenRAVEXMLFile | ( | const std::string & | file, |
std::string | models_dir = "" |
||
) |
Definition at line 611 of file scene.cpp.
bool Scene::fromYAMLFile | ( | const std::string & | file | ) |
Load a planning scene from a YAML file.
[in] | file | File to load planning scene from. |
Definition at line 589 of file scene.cpp.
collision_detection::AllowedCollisionMatrix & Scene::getACM | ( | ) |
Get the current allowed collision matrix of the planning scene.
const collision_detection::AllowedCollisionMatrix & Scene::getACMConst | ( | ) | const |
std::vector< std::string > Scene::getCollisionObjects | ( | ) | const |
robot_state::RobotState & Scene::getCurrentState | ( | ) |
Get a reference to the current robot state in the planning scene.
const robot_state::RobotState & Scene::getCurrentStateConst | ( | ) | const |
RobotPose Scene::getFramePose | ( | const std::string & | id | ) | const |
Get the pose of a particular frame in the scene. Example, use this to get the pose from /world to /base_link.
[in] | id | The ID of the frame to look for. |
moveit::core::GroupStateValidityCallbackFn Scene::getGSVCF | ( | bool | verbose | ) | const |
Get the group state validity callback function that uses this scene.
[in] | verbose | If true, will have verbose collision output. |
Definition at line 563 of file scene.cpp.
moveit_msgs::PlanningScene Scene::getMessage | ( | ) | const |
GeometryPtr Scene::getObjectGeometry | ( | const std::string & | name | ) | const |
RobotPose Scene::getObjectGraspPose | ( | const std::string & | name, |
const RobotPose & | offset | ||
) | const |
Get a pose in the global frame relative to a collision object for grasping.
[in] | name | Name of object to get pose for. |
[in] | offset | The offset of the grasp in the object's frame. |
Definition at line 286 of file scene.cpp.
RobotPose Scene::getObjectPose | ( | const std::string & | name | ) | const |
planning_scene::PlanningScenePtr & Scene::getScene | ( | ) |
Get a reference to the planning scene.
const planning_scene::PlanningScenePtr & Scene::getSceneConst | ( | ) | const |
bool Scene::hasObject | ( | const std::string & | name | ) | const |
bool Scene::moveAllObjectsGlobal | ( | const RobotPose & | transform | ) |
Move all objects according to a transform specified in world frame.
[in] | transform | The transform to move objects in world frame. |
Definition at line 294 of file scene.cpp.
bool Scene::moveObjectGlobal | ( | const std::string & | name, |
const RobotPose & | transform | ||
) |
bool Scene::moveObjectLocal | ( | const std::string & | name, |
const RobotPose & | transform | ||
) |
Move all shapes in an object according to the given transform specified in object frame. If the object has multiple shapes, the first one is considered the local frame.
[in] | name | Name of the object to move. |
[in] | transform | The transform to move the object in object frame. |
Definition at line 322 of file scene.cpp.
void Scene::operator= | ( | const Scene & | scene | ) |
Assignment Copy Constructor.
[in] | scene | Scene to copy. |
void Scene::removeCollisionObject | ( | const std::string & | name | ) |
bool Scene::setCollisionDetector | ( | const std::string & | detector_name | ) | const |
Attempts to set the collision detector plugin used by the scene to name. In MoveIt by default, 'Hybrid' is the only plugin defined. However, you can define your own libraries that contain classes that extend the collision_detection::CollisionPlugin class, and load them here as well. See http://moveit.ros.org/documentation/plugins/#collisionplugin for more details.
[in] | detector_name | Name of the collision detection plugin. |
Definition at line 341 of file scene.cpp.
bool Scene::toYAMLFile | ( | const std::string & | file | ) | const |
Serialize the current planning scene to a YAML file.
[in] | file | File to serialize planning scene to. |
Definition at line 580 of file scene.cpp.
void Scene::updateCollisionObject | ( | const std::string & | name, |
const GeometryConstPtr & | geometry, | ||
const RobotPose & | pose | ||
) |
Adds or updates collision object in the planning scene. If the geometry reference is the same, the collision object is updated. Otherwise, the old object named name is deleted and a new one is created.
[in] | name | Name of object to add or update. |
[in] | geometry | Geometry of object. |
[in] | pose | Pose of object. |
Definition at line 230 of file scene.cpp.
void Scene::useMessage | ( | const moveit_msgs::PlanningScene & | msg, |
bool | diff = false |
||
) |
|
private |
|
private |