Class Body

Inheritance Relationships

Derived Types

Class Documentation

class Body

A body is a shape + its pose. Point inclusion, ray intersection can be tested, volumes and bounding spheres can be computed.

Subclassed by bodies::Box, bodies::ConvexMesh, bodies::Cylinder, bodies::Sphere

Public Functions

inline Body()
virtual ~Body() = default
inline shapes::ShapeType getType() const

Get the type of shape this body represents.

inline void setScaleDirty(double scale)

If the dimension of the body should be scaled, this method sets the scale.

Note

This is the dirty version of the function which does not update internal data that depend on the scale. In the general case, you should call setScale() instead. Only call this function if you have a series of calls like setScale/setPadding/setPose/setDimensions and you want to avoid the overhead of updating the internal structures after each call. When you are finished with the batch, call updateInternalData().

Parameters:

scale – The scale to set. 1.0 means no scaling.

inline void setScale(double scale)

If the dimension of the body should be scaled, this method sets the scale. Default is 1.0.

inline double getScale() const

Retrieve the current scale.

inline void setPaddingDirty(double padd)

If the dimension of the body should be padded, this method sets the pading.

Note

This is the dirty version of the function which does not update internal data that depend on the scale. In the general case, you should call setPadding() instead. Only call this function if you have a series of calls like setScale/setPadding/setPose/setDimensions and you want to avoid the overhead of updating the internal structures after each call. When you are finished with the batch, call updateInternalData().

Parameters:

padd – The padding to set (in meters). 0.0 means no padding.

inline void setPadding(double padd)

If constant padding should be added to the body, this method sets the padding. Default is 0.0.

inline double getPadding() const

Retrieve the current padding.

inline void setPoseDirty(const Eigen::Isometry3d &pose)

Set the pose of the body.

Note

This is the dirty version of the function which does not update internal data that depend on the pose. In the general case, you should call setPose() instead. Only call this function if you have a series of calls like setScale/setPadding/setPose/setDimensions and you want to avoid the overhead of updating the internal structures after each call. When you are finished with the batch, call updateInternalData().

Parameters:

pose – The pose to set. Default is identity.

inline void setPose(const Eigen::Isometry3d &pose)

Set the pose of the body. Default is identity.

inline const Eigen::Isometry3d &getPose() const

Retrieve the pose of the body.

inline void setDimensionsDirty(const shapes::Shape *shape)

Set the dimensions of the body (from corresponding shape).

Note

This is the dirty version of the function which does not update internal data that depend on the dimensions. In the general case, you should call setDimensions() instead. Only call this function if you have a series of calls like setScale/setPadding/setPose/setDimensions and you want to avoid the overhead of updating the internal structures after each call. When you are finished with the batch, call updateInternalData().

Parameters:

shape – The shape whose dimensions should be assumed. After the function finishes, the pointer can be deleted.

virtual std::vector<double> getDimensions() const = 0

Get the dimensions associated to this body (as read from corresponding shape)

virtual std::vector<double> getScaledDimensions() const = 0

Get the dimensions associated to this body (scaled and padded)

inline void setDimensions(const shapes::Shape *shape)

Set the dimensions of the body (from corresponding shape)

inline bool containsPoint(double x, double y, double z, bool verbose = false) const

Check if a point is inside the body.

virtual bool containsPoint(const Eigen::Vector3d &p, bool verbose = false) const = 0

Check if a point is inside the body. Surface points are included.

virtual bool intersectsRay(const Eigen::Vector3d &origin, const Eigen::Vector3d &dir, EigenSTL::vector_Vector3d *intersections = nullptr, unsigned int count = 0) const = 0

Check if a ray intersects the body, and find the set of intersections, in order, along the ray. A maximum number of intersections can be specified as well. If that number is 0, all intersections are returned. Passing dir as a unit vector will result in faster computation.

virtual double computeVolume() const = 0

Compute the volume of the body. This method includes changes induced by scaling and padding.

virtual bool samplePointInside(random_numbers::RandomNumberGenerator &rng, unsigned int max_attempts, Eigen::Vector3d &result) const

Sample a point that is included in the body using a given random number generator.

Sometimes multiple attempts need to be generated. The function terminates with failure (returns false) after max_attempts attempts. If the call is successful (returns true) the point is written to result

virtual void computeBoundingSphere(BoundingSphere &sphere) const = 0

Compute the bounding radius for the body, in its current pose. Scaling and padding are accounted for.

virtual void computeBoundingCylinder(BoundingCylinder &cylinder) const = 0

Compute the bounding cylinder for the body, in its current pose. Scaling and padding are accounted for.

virtual void computeBoundingBox(AABB &bbox) const = 0

Compute the axis-aligned bounding box for the body, in its current pose. Scaling and padding are accounted for.

inline BodyPtr cloneAt(const Eigen::Isometry3d &pose) const

Get a clone of this body, but one that is located at the pose pose.

virtual BodyPtr cloneAt(const Eigen::Isometry3d &pose, double padding, double scaling) const = 0

Get a clone of this body, but one that is located at the pose pose and has possibly different passing and scaling: padding and scaling. This function is useful to implement thread safety, when bodies need to be moved around.

virtual void updateInternalData() = 0

This function is called every time a change to the body is made, so that intermediate values stored for efficiency reasons are kept up to date.

Protected Functions

virtual void useDimensions(const shapes::Shape *shape) = 0

Depending on the shape, this function copies the relevant data to the body.

Protected Attributes

double scale_

The scale that was set for this body.

double padding_

The scale that was set for this body.

shapes::ShapeType type_

The type of shape this body was constructed from.

Eigen::Isometry3d pose_

The location of the body (position and orientation)