MultiRayShape.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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 #ifndef GAZEBO_PHYSICS_MULTIRAYSHAPE_HH_
18 #define GAZEBO_PHYSICS_MULTIRAYSHAPE_HH_
19 
20 #include <vector>
21 #include <string>
22 #include <ignition/math/Angle.hh>
23 
25 #include "gazebo/physics/Shape.hh"
27 #include "gazebo/util/system.hh"
28 
29 namespace gazebo
30 {
31  namespace physics
32  {
35 
39  class GZ_PHYSICS_VISIBLE MultiRayShape : public Shape
40  {
43  public: explicit MultiRayShape(CollisionPtr _parent);
44 
56  public: explicit MultiRayShape(PhysicsEnginePtr _physicsEngine);
57 
59  public: virtual ~MultiRayShape();
60 
62  public: virtual void Init();
63 
66  public: virtual void SetScale(const ignition::math::Vector3d &_scale);
67 
71  public: double GetRange(unsigned int _index);
72 
76  public: double GetRetro(unsigned int _index);
77 
81  public: int GetFiducial(unsigned int _index);
82 
85  public: double GetMinRange() const;
86 
89  public: double GetMaxRange() const;
90 
93  public: double GetResRange() const;
94 
97  public: int GetSampleCount() const;
98 
101  public: double GetScanResolution() const;
102 
105  public: ignition::math::Angle MinAngle() const;
106 
109  public: ignition::math::Angle MaxAngle() const;
110 
113  public: int GetVerticalSampleCount() const;
114 
117  public: double GetVerticalScanResolution() const;
118 
121  public: ignition::math::Angle VerticalMinAngle() const;
122 
125  public: ignition::math::Angle VerticalMaxAngle() const;
126 
128  public: void Update();
129 
133  public: void FillMsg(msgs::Geometry &_msg);
134 
138  public: virtual void ProcessMsg(const msgs::Geometry &_msg);
139 
141  public: virtual double ComputeVolume() const;
142 
146  public: template<typename T>
148  {return this->newLaserScans.Connect(_subscriber);}
149 
154  public: virtual void UpdateRays() = 0;
155 
159  public: virtual void AddRay(const ignition::math::Vector3d &_start,
160  const ignition::math::Vector3d &_end);
161 
168  public: bool SetRay(const unsigned int _rayIndex,
169  const ignition::math::Vector3d &_start,
170  const ignition::math::Vector3d &_end);
171 
174  public: unsigned int RayCount() const;
175 
180  public: RayShapePtr Ray(const unsigned int _rayIndex) const;
181 
183  protected: std::vector<RayShapePtr> rays;
184 
186  protected: ignition::math::Pose3d offset;
187 
189  protected: sdf::ElementPtr rayElem;
190 
192  protected: sdf::ElementPtr scanElem;
193 
195  protected: sdf::ElementPtr horzElem;
196 
198  protected: sdf::ElementPtr vertElem;
199 
201  protected: sdf::ElementPtr rangeElem;
202 
205 
207  private: double minRange = 0;
208 
210  private: double maxRange = 1000;
211  };
213  }
214 }
215 #endif
sdf::ElementPtr scanElem
Scan SDF element pointer.
Definition: MultiRayShape.hh:192
Laser collision contains a set of ray-collisions, structured to simulate a laser range scanner...
Definition: MultiRayShape.hh:39
Base class for all shapes.
Definition: Shape.hh:45
boost::shared_ptr< PhysicsEngine > PhysicsEnginePtr
Definition: PhysicsTypes.hh:125
ignition::math::Pose3d offset
Pose offset of all the rays.
Definition: MultiRayShape.hh:186
sdf::ElementPtr rayElem
Ray SDF element pointer.
Definition: MultiRayShape.hh:189
sdf::ElementPtr horzElem
Horizontal SDF element pointer.
Definition: MultiRayShape.hh:195
sdf::ElementPtr rangeElem
Range SDF element pointer.
Definition: MultiRayShape.hh:201
std::vector< RayShapePtr > rays
Ray data.
Definition: MultiRayShape.hh:183
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
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:147
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:113
event::EventT< void()> newLaserScans
New laser scans event.
Definition: MultiRayShape.hh:204
sdf::ElementPtr vertElem
Vertical SDF element pointer.
Definition: MultiRayShape.hh:198