##

HeightmapShape.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GAZEBO_PHYSICS_HEIGHTMAPSHAPE_HH_
#define GAZEBO_PHYSICS_HEIGHTMAPSHAPE_HH_
#include <string>
#include <vector>
#include <ignition/transport/Node.hh>
#include <ignition/math/Vector2.hh>
#include "gazebo/common/ImageHeightmap.hh"
#include "gazebo/common/HeightmapData.hh"
#include "gazebo/common/Dem.hh"
#include "gazebo/transport/TransportTypes.hh"
#include "gazebo/physics/PhysicsTypes.hh"
#include "gazebo/physics/Shape.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace physics
{
class GZ_PHYSICS_VISIBLE HeightmapShape : public Shape
{
public: explicit HeightmapShape(CollisionPtr _parent);
public: virtual ~HeightmapShape();
public: virtual void Load(sdf::ElementPtr _sdf);
public: virtual void Init();
public: virtual void SetScale(const ignition::math::Vector3d &_scale);
public: std::string GetURI() const;
public: ignition::math::Vector3d Size() const;
public: ignition::math::Vector3d Pos() const;
public: ignition::math::Vector2i VertexCount() const;
public: float GetHeight(int _x, int _y) const;
public: void FillMsg(msgs::Geometry &_msg);
public: void FillHeights(msgs::Geometry &_msg) const;
public: virtual void ProcessMsg(const msgs::Geometry &_msg);
public: virtual double ComputeVolume() const;
public: float GetMaxHeight() const;
public: float GetMinHeight() const;
public: int GetSubSampling() const;
public: common::Image GetImage() const;
private: int LoadTerrainFile(const std::string &_filename);
private: void OnRequest(ConstRequestPtr &_msg);
protected: std::vector<float> heights;
protected: common::ImageHeightmap img;
protected: common::HeightmapData *heightmapData;
protected: unsigned int vertSize;
protected: bool flipY;
protected: int subSampling;
private: transport::NodePtr node;
private: transport::SubscriberPtr requestSub;
private: transport::PublisherPtr responsePub;
private: std::string fileFormat;
private: ignition::math::Vector3d heightmapSize;
#ifdef HAVE_GDAL
private: common::Dem dem;
#endif
// Place ignition::transport objects at the end of this file to
// guarantee they are destructed first.
private: ignition::transport::Node nodeIgn;
private: ignition::transport::Node::Publisher responsePubIgn;
};
}
}
#endif
gazebo::common::HeightmapData
Encapsulates a generic heightmap data file.
Definition: HeightmapData.hh:39
gazebo::physics::HeightmapShape::heights
std::vector< float > heights
Lookup table of heights.
Definition: HeightmapShape.hh:136
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::physics::HeightmapShape::GetMaxHeight
float GetMaxHeight() const
Get the maximum height.
gazebo::transport::PublisherPtr
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
gazebo::physics::HeightmapShape::HeightmapShape
HeightmapShape(CollisionPtr _parent)
Constructor.
gazebo::physics::HeightmapShape::FillHeights
void FillHeights(msgs::Geometry &_msg) const
Fill a geometry message with this shape's height data.
TransportTypes.hh
Forward declarations for transport.
gazebo::physics::HeightmapShape::GetURI
std::string GetURI() const
Get the URI of the heightmap image.
HeightmapData.hh
system.hh
gazebo::physics::HeightmapShape::FillMsg
void FillMsg(msgs::Geometry &_msg)
Fill a geometry message with this shape's data.
gazebo::transport::SubscriberPtr
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
ImageHeightmap.hh
gazebo::physics::HeightmapShape::ComputeVolume
virtual double ComputeVolume() const
Documentation inherited.
PhysicsTypes.hh
default namespace for gazebo
gazebo::transport::NodePtr
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
gazebo::common::Image
Encapsulates an image.
Definition: Image.hh:66
Dem.hh
gazebo::physics::HeightmapShape::vertSize
unsigned int vertSize
Size of the height lookup table.
Definition: HeightmapShape.hh:145
gazebo::physics::HeightmapShape::VertexCount
ignition::math::Vector2i VertexCount() const
Return the number of vertices, which equals the size of the image used to load the heightmap.
gazebo::physics::HeightmapShape
HeightmapShape collision shape builds a heightmap from an image. The supplied image must be square wi...
Definition: HeightmapShape.hh:45
Shape.hh
gazebo::physics::HeightmapShape::~HeightmapShape
virtual ~HeightmapShape()
Destructor.
gazebo::physics::HeightmapShape::subSampling
int subSampling
The amount of subsampling. Default is 2.
Definition: HeightmapShape.hh:151
gazebo::physics::HeightmapShape::Size
ignition::math::Vector3d Size() const
Get the size in meters.
gazebo::physics::HeightmapShape::SetScale
virtual void SetScale(const ignition::math::Vector3d &_scale)
Set the scale of the heightmap shape.
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gazebo::common::Dem
Definition: Dem.hh:44
gazebo::physics::HeightmapShape::GetMinHeight
float GetMinHeight() const
Get the minimum height.
gazebo::physics::HeightmapShape::GetHeight
float GetHeight(int _x, int _y) const
Get a height at a position.
gazebo::physics::HeightmapShape::flipY
bool flipY
True to flip the heights along the y direction.
Definition: HeightmapShape.hh:148
gazebo::physics::HeightmapShape::GetImage
common::Image GetImage() const
Return an image representation of the heightmap.
gazebo::physics::HeightmapShape::ProcessMsg
virtual void ProcessMsg(const msgs::Geometry &_msg)
Update the heightmap from a message.
gazebo::physics::HeightmapShape::heightmapData
common::HeightmapData * heightmapData
HeightmapData used to generate the heights.
Definition: HeightmapShape.hh:142
gazebo::physics::CollisionPtr
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:113
gazebo::physics::HeightmapShape::Init
virtual void Init()
Initialize the heightmap.
gazebo::physics::HeightmapShape::img
common::ImageHeightmap img
Image used to generate the heights.
Definition: HeightmapShape.hh:139
gazebo::physics::HeightmapShape::GetSubSampling
int GetSubSampling() const
Get the amount of subsampling.
gazebo::physics::HeightmapShape::Pos
ignition::math::Vector3d Pos() const
Get the origin in world coordinate frame.
gazebo::common::ImageHeightmap
Encapsulates an image that will be interpreted as a heightmap.
Definition: ImageHeightmap.hh:38
gazebo::physics::Shape
Base class for all shapes.
Definition: Shape.hh:39
gazebo::physics::HeightmapShape::Load
virtual void Load(sdf::ElementPtr _sdf)
Load the heightmap.