HeightmapShape Class Reference

HeightmapShape collision shape builds a heightmap from an image. More...

#include <physics/physics.hh>

Inherits Shape.

Inherited by BulletHeightmapShape, DARTHeightmapShape, ODEHeightmapShape, and SimbodyHeightmapShape.

Public Types

enum  EntityType {
  BASE = 0x00000000, ENTITY = 0x00000001, MODEL = 0x00000002, LINK = 0x00000004,
  COLLISION = 0x00000008, LIGHT = 0x00000010, VISUAL = 0x00000020, JOINT = 0x00000040,
  BALL_JOINT = 0x00000080, HINGE2_JOINT = 0x00000100, HINGE_JOINT = 0x00000200, SLIDER_JOINT = 0x00000400,
  SCREW_JOINT = 0x00000800, UNIVERSAL_JOINT = 0x00001000, GEARBOX_JOINT = 0x00002000, FIXED_JOINT = 0x00004000,
  ACTOR = 0x00008000, SHAPE = 0x00010000, BOX_SHAPE = 0x00020000, CYLINDER_SHAPE = 0x00040000,
  HEIGHTMAP_SHAPE = 0x00080000, MAP_SHAPE = 0x00100000, MULTIRAY_SHAPE = 0x00200000, RAY_SHAPE = 0x00400000,
  PLANE_SHAPE = 0x00800000, SPHERE_SHAPE = 0x01000000, MESH_SHAPE = 0x02000000, POLYLINE_SHAPE = 0x04000000,
  SENSOR_COLLISION = 0x10000000
}
 Unique identifiers for all entity types. More...
 

Public Member Functions

 HeightmapShape (CollisionPtr _parent)
 Constructor. More...
 
virtual ~HeightmapShape ()
 Destructor. More...
 
void AddChild (BasePtr _child)
 Add a child to this entity. More...
 
void AddType (EntityType _type)
 Add a type specifier. More...
 
virtual double ComputeVolume () const
 Documentation inherited. More...
 
void FillHeights (msgs::Geometry &_msg) const
 Fill a geometry message with this shape's height data. More...
 
void FillMsg (msgs::Geometry &_msg)
 Fill a geometry message with this shape's data. More...
 
virtual void Fini ()
 Finialize the object. More...
 
BasePtr GetByName (const std::string &_name)
 Get by name. More...
 
BasePtr GetChild (unsigned int _i) const
 Get a child by index. More...
 
BasePtr GetChild (const std::string &_name)
 Get a child by name. More...
 
unsigned int GetChildCount () const
 Get the number of children. More...
 
float GetHeight (int _x, int _y) const
 Get a height at a position. More...
 
uint32_t GetId () const
 Return the ID of this entity. More...
 
common::Image GetImage () const
 Return an image representation of the heightmap. More...
 
float GetMaxHeight () const
 Get the maximum height. More...
 
float GetMinHeight () const
 Get the minimum height. More...
 
std::string GetName () const
 Return the name of the entity. More...
 
BasePtr GetParent () const
 Get the parent. More...
 
int GetParentId () const
 Return the ID of the parent. More...
 
bool GetSaveable () const
 Get whether the object should be "saved", when the user selects to save the world to xml. More...
 
std::string GetScopedName (bool _prependWorldName=false) const
 Return the name of this entity with the model scope model1::...::modelN::entityName. More...
 
virtual const sdf::ElementPtr GetSDF ()
 Get the SDF values for the object. More...
 
int GetSubSampling () const
 Get the amount of subsampling. More...
 
unsigned int GetType () const
 Get the full type definition. More...
 
std::string GetURI () const
 Get the URI of the heightmap image. More...
 
const WorldPtrGetWorld () const
 Get the World this object is in. More...
 
bool HasType (const EntityType &_t) const
 Returns true if this object's type definition has the given type. More...
 
virtual void Init ()
 Initialize the heightmap. More...
 
bool IsSelected () const
 True if the entity is selected by the user. More...
 
virtual void Load (sdf::ElementPtr _sdf)
 Load the heightmap. More...
 
bool operator== (const Base &_ent) const
 Returns true if the entities are the same. More...
 
ignition::math::Vector3d Pos () const
 Get the origin in world coordinate frame. More...
 
void Print (const std::string &_prefix)
 Print this object to screen via gzmsg. More...
 
virtual void ProcessMsg (const msgs::Geometry &_msg)
 Update the heightmap from a message. More...
 
virtual void RemoveChild (unsigned int _id)
 Remove a child from this entity. More...
 
void RemoveChild (const std::string &_name)
 Remove a child by name. More...
 
void RemoveChild (physics::BasePtr _child)
 Remove a child by pointer. More...
 
void RemoveChildren ()
 Remove all children. More...
 
virtual void Reset ()
 Reset the object. More...
 
virtual void Reset (Base::EntityType _resetType)
 Calls recursive Reset on one of the Base::EntityType's. More...
 
virtual ignition::math::Vector3d Scale () const
 Get the scale of the shape. More...
 
virtual void SetName (const std::string &_name)
 Set the name of the entity. More...
 
void SetParent (BasePtr _parent)
 Set the parent. More...
 
void SetSaveable (bool _v)
 Set whether the object should be "saved", when the user selects to save the world to xml. More...
 
virtual void SetScale (const ignition::math::Vector3d &_scale)
 Set the scale of the heightmap shape. More...
 
virtual bool SetSelected (bool _show)
 Set whether this entity has been selected by the user through the gui. More...
 
void SetWorld (const WorldPtr &_newWorld)
 Set the world this object belongs to. More...
 
ignition::math::Vector3d Size () const
 Get the size in meters. More...
 
std::string TypeStr () const
 Get the string name for the entity type. More...
 
virtual void Update ()
 Update the object. More...
 
virtual void UpdateParameters (sdf::ElementPtr _sdf)
 Update the parameters using new sdf values. More...
 
common::URI URI () const
 Return the common::URI of this entity. More...
 
ignition::math::Vector2i VertexCount () const
 Return the number of vertices, which equals the size of the image used to load the heightmap. More...
 

Protected Member Functions

void ComputeScopedName ()
 Compute the scoped name of this object based on its parents. More...
 
virtual void RegisterIntrospectionItems ()
 Register items in the introspection service. More...
 
virtual void UnregisterIntrospectionItems ()
 Unregister items in the introspection service. More...
 

Protected Attributes

Base_V children
 Children of this entity. More...
 
CollisionPtr collisionParent
 This shape's collision parent. More...
 
bool flipY
 True to flip the heights along the y direction. More...
 
common::HeightmapDataheightmapData
 HeightmapData used to generate the heights. More...
 
std::vector< float > heights
 Lookup table of heights. More...
 
common::ImageHeightmap img
 Image used to generate the heights. More...
 
std::vector< common::URIintrospectionItems
 All the introspection items regsitered for this. More...
 
BasePtr parent
 Parent of this entity. More...
 
ignition::math::Vector3d scale = ignition::math::Vector3d::One
 This shape's scale;. More...
 
sdf::ElementPtr sdf
 The SDF values for this object. More...
 
int subSampling
 The amount of subsampling. Default is 2. More...
 
unsigned int vertSize
 Size of the height lookup table. More...
 
WorldPtr world
 Pointer to the world. More...
 

Detailed Description

HeightmapShape collision shape builds a heightmap from an image.

The supplied image must be square with N*N+1 pixels per side, where N is an integer.

Member Enumeration Documentation

enum EntityType
inherited

Unique identifiers for all entity types.

Enumerator
BASE 

Base type.

ENTITY 

Entity type.

MODEL 

Model type.

LINK 

Link type.

COLLISION 

Collision type.

LIGHT 

Light type.

VISUAL 

Visual type.

JOINT 

Joint type.

BALL_JOINT 

BallJoint type.

HINGE2_JOINT 

Hing2Joint type.

HINGE_JOINT 

HingeJoint type.

SLIDER_JOINT 

SliderJoint type.

SCREW_JOINT 

ScrewJoint type.

UNIVERSAL_JOINT 

UniversalJoint type.

GEARBOX_JOINT 

GearboxJoint type.

FIXED_JOINT 

FixedJoint type.

ACTOR 

Actor type.

SHAPE 

Shape type.

BOX_SHAPE 

BoxShape type.

CYLINDER_SHAPE 

CylinderShape type.

HEIGHTMAP_SHAPE 

HeightmapShape type.

MAP_SHAPE 

MapShape type.

MULTIRAY_SHAPE 

MultiRayShape type.

RAY_SHAPE 

RayShape type.

PLANE_SHAPE 

PlaneShape type.

SPHERE_SHAPE 

SphereShape type.

MESH_SHAPE 

MeshShape type.

POLYLINE_SHAPE 

PolylineShape type.

SENSOR_COLLISION 

Indicates a collision shape used for sensing.

Constructor & Destructor Documentation

HeightmapShape ( CollisionPtr  _parent)
explicit

Constructor.

Parameters
[in]_parentParent Collision object.
virtual ~HeightmapShape ( )
virtual

Destructor.

Member Function Documentation

void AddChild ( BasePtr  _child)
inherited

Add a child to this entity.

Parameters
[in]_childChild entity.
void AddType ( EntityType  _type)
inherited

Add a type specifier.

Parameters
[in]_typeNew type to append to this objects type definition.
void ComputeScopedName ( )
protectedinherited

Compute the scoped name of this object based on its parents.

See Also
Base::GetScopedName
virtual double ComputeVolume ( ) const
virtual

Documentation inherited.

Reimplemented from Shape.

void FillHeights ( msgs::Geometry &  _msg) const

Fill a geometry message with this shape's height data.

Parameters
[in]_msgMessage to fill.
void FillMsg ( msgs::Geometry &  _msg)
virtual

Fill a geometry message with this shape's data.

Raw height data are not packed in this message to minimize packet size.

Parameters
[in]_msgMessage to fill.
See Also
FillHeights

Implements Shape.

virtual void Fini ( )
virtualinherited
BasePtr GetByName ( const std::string &  _name)
inherited

Get by name.

Parameters
[in]_nameGet a child (or self) object by name
Returns
A pointer to the object, NULL if not found
BasePtr GetChild ( unsigned int  _i) const
inherited

Get a child by index.

Parameters
[in]_iIndex of the child to retreive.
Returns
A pointer to the object, NULL if the index is invalid.
BasePtr GetChild ( const std::string &  _name)
inherited

Get a child by name.

Parameters
[in]_nameName of the child.
Returns
A pointer to the object, NULL if not found
unsigned int GetChildCount ( ) const
inherited

Get the number of children.

Returns
The number of children.
float GetHeight ( int  _x,
int  _y 
) const

Get a height at a position.

Parameters
[in]_xX position.
[in]_yY position.
Returns
The height at a the specified location.
uint32_t GetId ( ) const
inherited

Return the ID of this entity.

This id is unique.

Returns
Integer ID.
common::Image GetImage ( ) const

Return an image representation of the heightmap.

Returns
Image where white pixels represents the highest locations, and black pixels the lowest.
float GetMaxHeight ( ) const

Get the maximum height.

Returns
The maximum height.
float GetMinHeight ( ) const

Get the minimum height.

Returns
The minimum height.
std::string GetName ( ) const
inherited

Return the name of the entity.

Returns
Name of the entity.
BasePtr GetParent ( ) const
inherited

Get the parent.

Returns
Pointer to the parent entity.
int GetParentId ( ) const
inherited

Return the ID of the parent.

Returns
Integer ID.
bool GetSaveable ( ) const
inherited

Get whether the object should be "saved", when the user selects to save the world to xml.

Returns
True if the object is saveable.
std::string GetScopedName ( bool  _prependWorldName = false) const
inherited

Return the name of this entity with the model scope model1::...::modelN::entityName.

Parameters
[in]_prependWorldNameTrue to prended the returned string with the world name. The result will be world::model1::...::modelN::entityName.
Returns
The scoped name.
virtual const sdf::ElementPtr GetSDF ( )
virtualinherited

Get the SDF values for the object.

Returns
The SDF values for the object.

Reimplemented in Actor, and Model.

int GetSubSampling ( ) const

Get the amount of subsampling.

Returns
Amount of subsampling.
unsigned int GetType ( ) const
inherited

Get the full type definition.

Returns
The full type definition.
std::string GetURI ( ) const

Get the URI of the heightmap image.

Returns
The heightmap image URI.
const WorldPtr& GetWorld ( ) const
inherited

Get the World this object is in.

Returns
The World this object is part of.
bool HasType ( const EntityType _t) const
inherited

Returns true if this object's type definition has the given type.

Parameters
[in]_tType to check.
Returns
True if this object's type definition has the.
virtual void Init ( )
virtual

Initialize the heightmap.

Implements Shape.

Reimplemented in BulletHeightmapShape, DARTHeightmapShape, SimbodyHeightmapShape, and ODEHeightmapShape.

bool IsSelected ( ) const
inherited

True if the entity is selected by the user.

Returns
True if the entity is selected.
virtual void Load ( sdf::ElementPtr  _sdf)
virtual

Load the heightmap.

Parameters
[in]_sdfSDF value to load from.

Reimplemented from Base.

bool operator== ( const Base _ent) const
inherited

Returns true if the entities are the same.

Checks only the name.

Parameters
[in]_entBase object to compare with.
Returns
True if the entities are the same.
ignition::math::Vector3d Pos ( ) const

Get the origin in world coordinate frame.

Returns
The origin in world coordinate frame.
void Print ( const std::string &  _prefix)
inherited

Print this object to screen via gzmsg.

Parameters
[in]_prefixUsually a set of spaces.
virtual void ProcessMsg ( const msgs::Geometry &  _msg)
virtual

Update the heightmap from a message.

Parameters
[in]_msgMessage to update from.

Implements Shape.

virtual void RegisterIntrospectionItems ( )
protectedvirtualinherited

Register items in the introspection service.

Reimplemented in Link, Joint, and Model.

virtual void RemoveChild ( unsigned int  _id)
virtualinherited

Remove a child from this entity.

Parameters
[in]_idID of the child to remove.
void RemoveChild ( const std::string &  _name)
inherited

Remove a child by name.

Parameters
[in]_nameName of the child.
void RemoveChild ( physics::BasePtr  _child)
inherited

Remove a child by pointer.

Parameters
[in]_childPointer to the child.
void RemoveChildren ( )
inherited

Remove all children.

virtual void Reset ( )
virtualinherited

Reset the object.

Reimplemented in Joint, Actor, Model, Link, Entity, ODEJoint, DARTJoint, BulletJoint, and SimbodyJoint.

virtual void Reset ( Base::EntityType  _resetType)
virtualinherited

Calls recursive Reset on one of the Base::EntityType's.

Parameters
[in]_resetTypeThe type of reset operation
virtual ignition::math::Vector3d Scale ( ) const
virtualinherited

Get the scale of the shape.

Returns
Scale of the shape.

Reimplemented in MapShape.

virtual void SetName ( const std::string &  _name)
virtualinherited

Set the name of the entity.

Parameters
[in]_nameNew name.

Reimplemented in Entity.

void SetParent ( BasePtr  _parent)
inherited

Set the parent.

Parameters
[in]_parentParent object.
void SetSaveable ( bool  _v)
inherited

Set whether the object should be "saved", when the user selects to save the world to xml.

Parameters
[in]_vSet to True if the object should be saved.
virtual void SetScale ( const ignition::math::Vector3d &  _scale)
virtual

Set the scale of the heightmap shape.

Parameters
[in]_scaleScale to set the heightmap shape to.

Implements Shape.

virtual bool SetSelected ( bool  _show)
virtualinherited

Set whether this entity has been selected by the user through the gui.

Parameters
[in]_showTrue to set this entity as selected.

Reimplemented in Link.

void SetWorld ( const WorldPtr _newWorld)
inherited

Set the world this object belongs to.

This will also set the world for all children.

Parameters
[in]_newWorldThe new World this object is part of.
ignition::math::Vector3d Size ( ) const

Get the size in meters.

Returns
The size in meters.
std::string TypeStr ( ) const
inherited

Get the string name for the entity type.

Returns
The string name for this entity.
virtual void UnregisterIntrospectionItems ( )
protectedvirtualinherited

Unregister items in the introspection service.

virtual void Update ( )
inlinevirtualinherited
virtual void UpdateParameters ( sdf::ElementPtr  _sdf)
virtualinherited

Update the parameters using new sdf values.

Parameters
[in]_sdfUpdate the object's parameters based on SDF values.

Reimplemented in Joint, Actor, Link, Model, Entity, and Collision.

common::URI URI ( ) const
inherited

Return the common::URI of this entity.

The URI includes the world where the entity is contained and all the hierarchy of sub-entities that can compose this entity. E.g.: A link entity contains the name of the link and the model where the link is contained.

Returns
The URI of this entity.
ignition::math::Vector2i VertexCount ( ) const

Return the number of vertices, which equals the size of the image used to load the heightmap.

Returns
ignition::math::Vector2i, result.X() == width, result.Y() == length/height.

Member Data Documentation

Base_V children
protectedinherited

Children of this entity.

bool flipY
protected

True to flip the heights along the y direction.

common::HeightmapData* heightmapData
protected

HeightmapData used to generate the heights.

std::vector<float> heights
protected

Lookup table of heights.

common::ImageHeightmap img
protected

Image used to generate the heights.

std::vector<common::URI> introspectionItems
protectedinherited

All the introspection items regsitered for this.

BasePtr parent
protectedinherited

Parent of this entity.

ignition::math::Vector3d scale = ignition::math::Vector3d::One
protectedinherited

This shape's scale;.

sdf::ElementPtr sdf
protectedinherited

The SDF values for this object.

int subSampling
protected

The amount of subsampling. Default is 2.

unsigned int vertSize
protected

Size of the height lookup table.

WorldPtr world
protectedinherited

Pointer to the world.


The documentation for this class was generated from the following file: