All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HeightmapShape.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 /* Desc: Heightmap shape
18  * Author: Nate Koenig, Andrew Howard
19  * Date: 8 May 2003
20  */
21 
22 #ifndef _HEIGHTMAPSHAPE_HH_
23 #define _HEIGHTMAPSHAPE_HH_
24 
25 #include <string>
26 #include <vector>
27 
28 #include "gazebo/common/Image.hh"
29 #include "gazebo/math/Vector3.hh"
32 #include "gazebo/physics/Shape.hh"
33 
34 namespace gazebo
35 {
36  namespace physics
37  {
40 
45  class HeightmapShape : public Shape
46  {
49  public: explicit HeightmapShape(CollisionPtr _parent);
50 
52  public: virtual ~HeightmapShape();
53 
56  public: virtual void Load(sdf::ElementPtr _sdf);
57 
59  public: virtual void Init();
60 
63  public: std::string GetURI() const;
64 
67  public: math::Vector3 GetSize() const;
68 
71  public: math::Vector3 GetPos() const;
72 
77  public: math::Vector2i GetVertexCount() const;
78 
83  public: float GetHeight(int _x, int _y) const;
84 
87  public: void FillMsg(msgs::Geometry &_msg);
88 
91  public: virtual void ProcessMsg(const msgs::Geometry &_msg);
92 
95  public: float GetMaxHeight() const;
96 
99  public: float GetMinHeight() const;
100 
103  public: int GetSubSampling() const;
104 
108  public: common::Image GetImage() const;
109 
111  private: void FillHeightMap();
112 
115  private: void OnRequest(ConstRequestPtr &_msg);
116 
118  protected: std::vector<float> heights;
119 
121  protected: common::Image img;
122 
124  protected: unsigned int vertSize;
125 
127  protected: math::Vector3 scale;
128 
130  protected: bool flipY;
131 
133  protected: int subSampling;
134 
136  private: transport::NodePtr node;
137 
139  private: transport::SubscriberPtr requestSub;
140 
142  private: transport::PublisherPtr responsePub;
143  };
145  }
146 }
147 #endif