MultiRayShape.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 #ifndef _MULTIRAYSHAPE_HH_
18 #define _MULTIRAYSHAPE_HH_
19 
20 #include <vector>
21 #include <string>
22 
23 #include "gazebo/math/Vector3.hh"
24 #include "gazebo/math/Angle.hh"
25 
27 #include "gazebo/physics/Shape.hh"
29 #include "gazebo/util/system.hh"
30 
31 namespace gazebo
32 {
33  namespace physics
34  {
37 
41  class GZ_PHYSICS_VISIBLE MultiRayShape : public Shape
42  {
45  public: explicit MultiRayShape(CollisionPtr _parent);
46 
58  public: explicit MultiRayShape(PhysicsEnginePtr _physicsEngine);
59 
61  public: virtual ~MultiRayShape();
62 
64  public: virtual void Init();
65 
68  public: virtual void SetScale(const math::Vector3 &_scale);
69 
73  public: double GetRange(unsigned int _index);
74 
78  public: double GetRetro(unsigned int _index);
79 
83  public: int GetFiducial(unsigned int _index);
84 
87  public: double GetMinRange() const;
88 
91  public: double GetMaxRange() const;
92 
95  public: double GetResRange() const;
96 
99  public: int GetSampleCount() const;
100 
103  public: double GetScanResolution() const;
104 
107  public: math::Angle GetMinAngle() const;
108 
111  public: math::Angle GetMaxAngle() const;
112 
115  public: int GetVerticalSampleCount() const;
116 
119  public: double GetVerticalScanResolution() const;
120 
123  public: math::Angle GetVerticalMinAngle() const;
124 
127  public: math::Angle GetVerticalMaxAngle() const;
128 
130  public: void Update();
131 
135  public: void FillMsg(msgs::Geometry &_msg);
136 
140  public: virtual void ProcessMsg(const msgs::Geometry &_msg);
141 
143  public: virtual double ComputeVolume() const;
144 
148  public: template<typename T>
150  {return this->newLaserScans.Connect(_subscriber);}
151 
155  {this->newLaserScans.Disconnect(_conn);}
156 
161  public: virtual void UpdateRays() = 0;
162 
166  public: virtual void AddRay(const math::Vector3 &_start,
167  const math::Vector3 &_end);
168 
175  public: bool SetRay(const unsigned int _rayIndex,
176  const ignition::math::Vector3d &_start,
177  const ignition::math::Vector3d &_end);
178 
181  public: unsigned int RayCount() const;
182 
187  public: RayShapePtr Ray(const unsigned int _rayIndex) const;
188 
190  protected: std::vector<RayShapePtr> rays;
191 
193  protected: math::Pose offset;
194 
196  protected: sdf::ElementPtr rayElem;
197 
199  protected: sdf::ElementPtr scanElem;
200 
202  protected: sdf::ElementPtr horzElem;
203 
205  protected: sdf::ElementPtr vertElem;
206 
208  protected: sdf::ElementPtr rangeElem;
209 
212 
214  private: double minRange = 0;
215 
217  private: double maxRange = 1000;
218  };
220  }
221 }
222 #endif
sdf::ElementPtr scanElem
Scan SDF element pointer.
Definition: MultiRayShape.hh:199
math::Pose offset
Pose offset of all the rays.
Definition: MultiRayShape.hh:193
Encapsulates a position and rotation in three space.
Definition: Pose.hh:37
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
Laser collision contains a set of ray-collisions, structured to simulate a laser range scanner...
Definition: MultiRayShape.hh:41
Base class for all shapes.
Definition: Shape.hh:46
void DisconnectNewLaserScans(event::ConnectionPtr &_conn)
Disconnect from the new laser scans signal.
Definition: MultiRayShape.hh:154
boost::shared_ptr< PhysicsEngine > PhysicsEnginePtr
Definition: PhysicsTypes.hh:125
sdf::ElementPtr rayElem
Ray SDF element pointer.
Definition: MultiRayShape.hh:196
sdf::ElementPtr horzElem
Horizontal SDF element pointer.
Definition: MultiRayShape.hh:202
sdf::ElementPtr rangeElem
Range SDF element pointer.
Definition: MultiRayShape.hh:208
std::vector< RayShapePtr > rays
Ray data.
Definition: MultiRayShape.hh:190
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:153
boost::shared_ptr< RayShape > RayShapePtr
Definition: PhysicsTypes.hh:145
event::ConnectionPtr ConnectNewLaserScans(T _subscriber)
Connect a to the new laser scan signal.
Definition: MultiRayShape.hh:149
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
An angle and related functions.
Definition: Angle.hh:53
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:113
event::EventT< void()> newLaserScans
New laser scans event.
Definition: MultiRayShape.hh:211
sdf::ElementPtr vertElem
Vertical SDF element pointer.
Definition: MultiRayShape.hh:205