Klamp't  0.8.1
urdf_sensor.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 /* Author: John Hsu */
36 
37 /* example
38 
39  <sensor name="my_camera_sensor" update_rate="20">
40  <origin xyz="0 0 0" rpy="0 0 0"/>
41  <camera>
42  <horizontal_hov>1.5708</horizontal_hov>
43  <image width="640" height="480" format="R8G8B8"/>
44  <clip near="0.01" far="50.0"/>
45  </camera>
46  </sensor>
47  <sensor name="my_ray_sensor" update_rate="20">
48  <origin xyz="0 0 0" rpy="0 0 0"/>
49  <ray>
50  <scan>
51  <horizontal samples="100" resolution="1" min_angle="-1.5708" max_angle="1.5708"/>
52  <vertical samples="1" resolution="1" min_angle="0" max_angle="0"/>
53  </scan>
54  </ray>
55  </sensor>
56 
57 */
58 
59 
60 
61 #ifndef URDF_SENSOR_H
62 #define URDF_SENSOR_H
63 
64 #include <string>
65 #include <vector>
66 #include <map>
67 #include <memory>
68 #include "urdf_pose.h"
69 #include "urdf_joint.h"
70 #include "urdf_link.h"
71 
72 namespace urdf{
73 
75 {
76 public:
77  enum {CAMERA, RAY} type;
78  virtual ~VisualSensor(void)
79  {
80  }
81 };
82 
83 class Camera : public VisualSensor
84 {
85 public:
86  Camera() { this->clear(); };
87  unsigned int width, height;
90  std::string format;
91  double hfov;
92  double near;
93  double far;
94 
95  void clear()
96  {
97  hfov = 0;
98  width = 0;
99  height = 0;
100  format.clear();
101  near = 0;
102  far = 0;
103  };
104 };
105 
106 class Ray : public VisualSensor
107 {
108 public:
109  Ray() { this->clear(); };
110  unsigned int horizontal_samples;
111  double horizontal_resolution;
112  double horizontal_min_angle;
113  double horizontal_max_angle;
114  unsigned int vertical_samples;
115  double vertical_resolution;
116  double vertical_min_angle;
117  double vertical_max_angle;
118 
119  void clear()
120  {
121  // set defaults
122  horizontal_samples = 1;
123  horizontal_resolution = 1;
124  horizontal_min_angle = 0;
125  horizontal_max_angle = 0;
126  vertical_samples = 1;
127  vertical_resolution = 1;
128  vertical_min_angle = 0;
129  vertical_max_angle = 0;
130  };
131 };
132 
133 
134 class Sensor
135 {
136 public:
137  Sensor() { this->clear(); };
138 
140  std::string name;
141 
143  double update_rate;
144 
148 
150  std::shared_ptr<VisualSensor> sensor;
151 
152 
154  std::string parent_link_name;
155 
156  std::shared_ptr<Link> getParent() const
157  {return parent_link_.lock();};
158 
159  void setParent(std::shared_ptr<Link> parent)
160  { this->parent_link_ = parent; }
161 
162  void clear()
163  {
164  this->name.clear();
165  this->sensor.reset();
166  this->parent_link_name.clear();
167  this->parent_link_.reset();
168  };
169 
170 private:
171  std::weak_ptr<Link> parent_link_;
172 
173 };
174 }
175 #endif
Definition: urdf_sensor.h:134
std::string name
sensor name must be unique
Definition: urdf_sensor.h:137
Pose origin
Definition: urdf_sensor.h:147
Definition: urdf_sensor.h:83
std::string format
Definition: urdf_sensor.h:90
Definition: urdf_sensor.h:74
Definition: urdf_color.h:46
std::shared_ptr< VisualSensor > sensor
sensor
Definition: urdf_sensor.h:150
Definition: urdf_pose.h:239
Definition: urdf_sensor.h:106
std::string parent_link_name
Parent link element name. A pointer is stored in parent_link_.
Definition: urdf_sensor.h:154
double update_rate
update rate in Hz
Definition: urdf_sensor.h:143