3 #ifndef ROBOWFLEX_GEOMETRY_
4 #define ROBOWFLEX_GEOMETRY_
7 #include <Eigen/Geometry>
9 #include <geometric_shapes/shapes.h>
10 #include <geometric_shapes/bodies.h>
12 #include <shape_msgs/SolidPrimitive.h>
13 #include <shape_msgs/Mesh.h>
15 #include <moveit/robot_model/aabb.h>
52 static const unsigned int MAX;
121 const EigenSTL::vector_Vector3d &vertices = EigenSTL::vector_Vector3d{});
127 Geometry(
const shapes::Shape &shape);
133 Geometry(
const shape_msgs::SolidPrimitive &msg);
139 Geometry(
const shape_msgs::Mesh &msg);
149 bool contains(
const Eigen::Vector3d &point)
const;
165 const shape_msgs::SolidPrimitive
getSolidMsg()
const;
175 const shapes::ShapePtr &
getShape()
const;
180 const bodies::BodyPtr &
getBody()
const;
195 const EigenSTL::vector_Vector3d &
getVertices()
const;
206 Eigen::AlignedBox3d
getAABB(
const RobotPose &pose = RobotPose::Identity())
const;
#define ROBOWFLEX_CLASS_FORWARD(C)
Macro that forward declares a class and defines two shared ptrs types:
A shared pointer wrapper for robowflex::Geometry.
static const std::string & toString(Type type)
Converts a ShapeType to its string.
@ CYLINDER
Solid primitive cylinder. Uses two dimensions (height, radius).
@ MESH
Mesh. Dimensions scale along x, y, z.
@ CONE
Solid primitive cone. Uses two dimensions (height, radius).
@ BOX
Solid primitive box. Uses three dimensions (x, y, z).
@ SPHERE
Solid primitive sphere. Uses one dimension (radius).
static Type toType(const std::string &str)
Converts a string into a ShapeType.
static const std::vector< std::string > STRINGS
Mapping of ShapeType to string.
static const unsigned int MAX
Maximum value of ShapeType.
A class that manages both solid and mesh geometry for various parts of the motion planning system.
const std::string & getResource() const
Gets the mesh resource of the geometry.
static GeometryPtr makeMesh(const std::string &resource, const Eigen::Vector3d &scale={1, 1, 1})
Create a mesh from resource file.
Geometry & operator=(const Geometry &)=delete
Geometry(ShapeType::Type type, const Eigen::Vector3d &dimensions, const std::string &resource="", const EigenSTL::vector_Vector3d &vertices=EigenSTL::vector_Vector3d{})
Constructor. Builds and loads the specified geometry.
Eigen::Vector3d dimensions_
Dimensions to scale geometry.
static GeometryPtr makeSphere(double radius)
Create a sphere.
static GeometryPtr makeBox(double x, double y, double z)
Create a box.
const EigenSTL::vector_Vector3d & getVertices() const
Gets the Vertices of the primitive.
const shape_msgs::Mesh getMeshMsg() const
Gets the message form of mesh geometry.
shapes::ShapePtr shape_
Loaded shape.
static GeometryPtr makeCone(double radius, double length)
Create a cone.
const Eigen::Vector3d & getDimensions() const
Gets the dimensions of the geometry.
bool isMesh() const
Checks if the geometry is a mesh geometry.
const shape_msgs::SolidPrimitive getSolidMsg() const
Gets the message form of solid primitive geometry (all but ShapeType::MESH).
Eigen::AlignedBox3d getAABB(const RobotPose &pose=RobotPose::Identity()) const
Compute the AABB (axis-aligned bounding box) of the geometry at a given pose.
const shapes::ShapePtr & getShape() const
Gets the underlying shape.
Geometry(const Geometry &)=delete
ShapeType::Type getType() const
Gets the type of the geometry.
bodies::BodyPtr body_
Body operation.
std::pair< bool, Eigen::Vector3d > sample(const unsigned int attempts=50) const
Tries to sample a point in the geometry.
shapes::Shape * loadShape() const
Loads a shape from the set type_ and dimensions_, and resource_ if a mesh.
bodies::Body * loadBody() const
Loads a body from the loaded shape_.
EigenSTL::vector_Vector3d vertices_
Vertices of the primitive.
static GeometryPtr makeCylinder(double radius, double length)
Create a cylinder.
std::string resource_
Resource locator for MESH types.
ShapeType::Type type_
Geometry Type.
const bodies::BodyPtr & getBody() const
Gets the underlying body.
static GeometryPtr makeSolidPrimitive(const shape_msgs::SolidPrimitive &msg)
Create a solid primitive.
bool contains(const Eigen::Vector3d &point) const
Checks if the geometry contains a point.
Main namespace. Contains all library classes and functions.
std::decay< decltype(std::declval< moveit::core::Transforms >().getTransform("")) >::type RobotPose
A pose (point in SE(3)) used in various functions. Defined from what MoveIt! uses.