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: virtual void SetScale(const math::Vector3 &_scale);
64 
67  public: std::string GetURI() const;
68 
71  public: math::Vector3 GetSize() const;
72 
75  public: math::Vector3 GetPos() const;
76 
81  public: math::Vector2i GetVertexCount() const;
82 
87  public: float GetHeight(int _x, int _y) const;
88 
91  public: void FillMsg(msgs::Geometry &_msg);
92 
95  public: virtual void ProcessMsg(const msgs::Geometry &_msg);
96 
99  public: float GetMaxHeight() const;
100 
103  public: float GetMinHeight() const;
104 
107  public: int GetSubSampling() const;
108 
112  public: common::Image GetImage() const;
113 
115  private: void FillHeightMap();
116 
119  private: void OnRequest(ConstRequestPtr &_msg);
120 
122  protected: std::vector<float> heights;
123 
125  protected: common::Image img;
126 
128  protected: unsigned int vertSize;
129 
131  protected: bool flipY;
132 
134  protected: int subSampling;
135 
137  private: transport::NodePtr node;
138 
140  private: transport::SubscriberPtr requestSub;
141 
143  private: transport::PublisherPtr responsePub;
144  };
146  }
147 }
148 #endif