mars
HighResRangeFinder.hpp
Go to the documentation of this file.
1 /* Generated from orogen/lib/orogen/templates/tasks/Task.hpp */
2 
3 #ifndef SIMULATION_MARSHIGHRESRANGEFINDER_TASK_HPP
4 #define SIMULATION_MARSHIGHRESRANGEFINDER_TASK_HPP
5 
6 #include "mars/HighResRangeFinderBase.hpp"
7 #include <base/samples/DistanceImage.hpp>
8 
9 namespace mars {
10 
29  class HighResRangeFinder : public HighResRangeFinderBase
30  {
31  friend class HighResRangeFinderBase;
32  protected:
33  struct Camera {
43  Camera(long id, mars::sim::CameraSensor* cam, double rot_y) :
44  sensor_id(id), camera_sensor(cam), name()
45  {
46  width = camera_sensor->getConfig().width;
47  height = camera_sensor->getConfig().height;
48  image = new base::samples::DistanceImage(width, height);
49  image->setSize(width, height);
50  camera_sensor->getCameraInfo(&cam_info);
51  image->setIntrinsic(cam_info.scale_x, cam_info.scale_y,
52  cam_info.center_x, cam_info.center_y );
53  cam_sensor_info = camera_sensor->getConfig();
54  // Degree to rad.
55  // INVERTS ROTATION, has to be done to match the viewing direction of the MARS camera.
56  rot_y = (-rot_y / 180.0) * M_PI;
57  Eigen::AngleAxis<double> rot(rot_y, Eigen::Vector3d(0.0, 1.0, 0.0));
58  orientation = rot;
59  }
60 
61  ~Camera() {
62  delete image; image = NULL;
63  }
64 
65  long sensor_id;
66  mars::sim::CameraSensor* camera_sensor;
67  int width;
68  int height;
69  mars::interfaces::cameraStruct cam_info;
70  mars::sim::CameraConfigStruct cam_sensor_info;
71  base::samples::DistanceImage* image;
72  // Rotation of the camera around the y-axis within the camera frame.
73  Eigen::Quaternion<double, Eigen::DontAlign> orientation;
74 
77  double lower_pixel;
78  double upper_pixel;
79  double left_pixel;
80  double right_pixel;
81  double v_steps;
82  double h_steps;
83  std::string name;
84  };
85 
86  std::vector<Camera*> cameras;
87 
115  virtual bool addCamera(::std::string const & name, double orientation);
116 
121  void calcCamParameters(Camera* camera);
122 
123  public:
128  HighResRangeFinder(std::string const& name = "mars::HighResRangeFinder");
129 
135  HighResRangeFinder(std::string const& name, RTT::ExecutionEngine* engine);
136 
140 
155  bool configureHook();
156 
162  bool startHook();
163 
178  void updateHook();
179 
186  void errorHook();
187 
191  void stopHook();
192 
197  void cleanupHook();
198 
203  virtual void getData();
204  };
205 }
206 
207 #endif
208 
Definition: HighResRangeFinder.hpp:29
std::string name
Definition: HighResRangeFinder.hpp:83
double pixel_per_rad_horizontal
Definition: HighResRangeFinder.hpp:75
double upper_pixel
Definition: HighResRangeFinder.hpp:78
void updateHook()
Definition: HighResRangeFinder.cpp:123
mars::sim::CameraConfigStruct cam_sensor_info
Definition: HighResRangeFinder.hpp:70
base::samples::DistanceImage * image
Definition: HighResRangeFinder.hpp:71
long sensor_id
Definition: HighResRangeFinder.hpp:65
Camera(long id, mars::sim::CameraSensor *cam, double rot_y)
Definition: HighResRangeFinder.hpp:43
void errorHook()
Definition: HighResRangeFinder.cpp:127
double h_steps
Definition: HighResRangeFinder.hpp:82
Eigen::Quaternion< double, Eigen::DontAlign > orientation
Definition: HighResRangeFinder.hpp:73
bool startHook()
Definition: HighResRangeFinder.cpp:110
HighResRangeFinder(std::string const &name="mars::HighResRangeFinder")
Definition: HighResRangeFinder.cpp:8
double lower_pixel
Definition: HighResRangeFinder.hpp:77
double left_pixel
Definition: HighResRangeFinder.hpp:79
mars::sim::CameraSensor * camera_sensor
Definition: HighResRangeFinder.hpp:66
friend class HighResRangeFinderBase
Definition: HighResRangeFinder.hpp:31
double pixel_per_rad_vertical
Definition: HighResRangeFinder.hpp:76
int height
Definition: HighResRangeFinder.hpp:68
void stopHook()
Definition: HighResRangeFinder.cpp:131
double v_steps
Definition: HighResRangeFinder.hpp:81
~HighResRangeFinder()
Definition: HighResRangeFinder.cpp:18
void cleanupHook()
Definition: HighResRangeFinder.cpp:135
Definition: jointTypes.hpp:9
Definition: HighResRangeFinder.hpp:33
~Camera()
Definition: HighResRangeFinder.hpp:61
mars::interfaces::cameraStruct cam_info
Definition: HighResRangeFinder.hpp:69
double right_pixel
Definition: HighResRangeFinder.hpp:80
std::vector< Camera * > cameras
Definition: HighResRangeFinder.hpp:86
int width
Definition: HighResRangeFinder.hpp:67
bool configureHook()
The following lines are template definitions for the various state machine.
Definition: HighResRangeFinder.cpp:103
void calcCamParameters(Camera *camera)
Definition: HighResRangeFinder.cpp:49
virtual bool addCamera(::std::string const &name, double orientation)
Definition: HighResRangeFinder.cpp:27
virtual void getData()
Definition: HighResRangeFinder.cpp:140