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
27#include "gazebo/util/system.hh"
28
29namespace 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
204 protected: event::EventT<void()> newLaserScans;
205
207 private: double minRange = 0;
208
210 private: double maxRange = 1000;
211 };
213 }
214}
215#endif
A class for event processing.
Definition Event.hh:98
Laser collision contains a set of ray-collisions, structured to simulate a laser range scanner.
Definition MultiRayShape.hh:40
virtual void SetScale(const ignition::math::Vector3d &_scale)
Set the scale of the multi ray shape.
virtual void UpdateRays()=0
Method for updating the rays.
int GetFiducial(unsigned int _index)
Get detected fiducial value for a ray.
event::ConnectionPtr ConnectNewLaserScans(T _subscriber)
Connect a to the new laser scan signal.
Definition MultiRayShape.hh:147
virtual double ComputeVolume() const
Documentation inherited.
virtual void Init()
Init the shape.
double GetMaxRange() const
Get the maximum range.
MultiRayShape(PhysicsEnginePtr _physicsEngine)
Constructor for a stand alone multiray shape.
sdf::ElementPtr vertElem
Vertical SDF element pointer.
Definition MultiRayShape.hh:198
ignition::math::Pose3d offset
Pose offset of all the rays.
Definition MultiRayShape.hh:186
MultiRayShape(CollisionPtr _parent)
Constructor.
double GetRetro(unsigned int _index)
Get detected retro (intensity) value for a ray.
event::EventT< void()> newLaserScans
New laser scans event.
Definition MultiRayShape.hh:204
sdf::ElementPtr rayElem
Ray SDF element pointer.
Definition MultiRayShape.hh:189
double GetVerticalScanResolution() const
Get the vertical range resolution.
std::vector< RayShapePtr > rays
Ray data.
Definition MultiRayShape.hh:183
int GetVerticalSampleCount() const
Get the vertical sample count.
ignition::math::Angle MinAngle() const
Get the minimum angle.
virtual ~MultiRayShape()
Destructor.
int GetSampleCount() const
Get the horizontal sample count.
double GetMinRange() const
Get the minimum range.
bool SetRay(const unsigned int _rayIndex, const ignition::math::Vector3d &_start, const ignition::math::Vector3d &_end)
Set the points of a ray.
ignition::math::Angle VerticalMaxAngle() const
Get the vertical max angle.
ignition::math::Angle MaxAngle() const
Get the maximum angle.
double GetResRange() const
Get the range resolution.
double GetRange(unsigned int _index)
Get detected range for a ray.
unsigned int RayCount() const
Get the number of rays.
ignition::math::Angle VerticalMinAngle() const
Get the vertical min angle.
sdf::ElementPtr rangeElem
Range SDF element pointer.
Definition MultiRayShape.hh:201
double GetScanResolution() const
Get the horizontal resolution.
void Update()
Update the ray collisions.
virtual void ProcessMsg(const msgs::Geometry &_msg)
\TODO This function is not implemented.
sdf::ElementPtr horzElem
Horizontal SDF element pointer.
Definition MultiRayShape.hh:195
void FillMsg(msgs::Geometry &_msg)
\TODO This function is not implemented.
RayShapePtr Ray(const unsigned int _rayIndex) const
Get a pointer to a ray.
virtual void AddRay(const ignition::math::Vector3d &_start, const ignition::math::Vector3d &_end)
Add a ray to the collision.
sdf::ElementPtr scanElem
Scan SDF element pointer.
Definition MultiRayShape.hh:192
Base class for all shapes.
Definition Shape.hh:40
ConnectionPtr Connect(const std::function< T > &_subscriber)
Connect a callback to this event.
Definition Event.hh:558
boost::shared_ptr< Connection > ConnectionPtr
Definition CommonTypes.hh:134
boost::shared_ptr< PhysicsEngine > PhysicsEnginePtr
Definition PhysicsTypes.hh:125
boost::shared_ptr< Collision > CollisionPtr
Definition PhysicsTypes.hh:113
boost::shared_ptr< RayShape > RayShapePtr
Definition PhysicsTypes.hh:145
Forward declarations for the common classes.
Definition Animation.hh:27