laser_scan_grid_world.h
Go to the documentation of this file.
1 
7 #ifndef __LASER_SCAN_GRID_WORLD_H
8 #define __LASER_SCAN_GRID_WORLD_H
9 
10 #include <memory>
11 
12 #include "sensor_data.h"
13 #include "state_data.h"
15 #include "maps/grid_map.h"
16 
22 class LaserScanGridWorld : public World<TransformedLaserScan, GridMap> {
23 public: //types
24  using MapType = GridMap;
26 public: // methods
27 
32  LaserScanGridWorld(std::shared_ptr<GridCellStrategy> gcs,
33  const GridMapParams &init_params) :
34  _map(gcs->cell_factory(), init_params) {}
35 
43  for (const auto &sp : scan.points) {
44  // move to world frame assume sensor is in robots' (0,0)
45  double x_world = pose.x + sp.range * std::cos(sp.angle + pose.theta);
46  double y_world = pose.y + sp.range * std::sin(sp.angle + pose.theta);
47 
48  handle_scan_point(map(), pose.x, pose.y, x_world, y_world,
49  sp.is_occupied, scan.quality);
50  }
51  }
52 
62  virtual void handle_scan_point(MapType &map,
63  double laser_x, double laser_y,
64  double beam_end_x, double beam_end_y,
65  bool is_occ, double quality) {
66  Point robot_pt = map.world_to_cell(laser_x, laser_y);
67  Point obst_pt = map.world_to_cell(beam_end_x, beam_end_y);
68 
69  std::vector<Point> pts = DiscreteLine2D(robot_pt, obst_pt).points();
70 
71  map.update_cell(pts.back(), Occupancy{is_occ ? 1.0 : 0.0, 1.0}, quality);
72  pts.pop_back();
73  for (const auto &pt : pts) {
74  map.update_cell(pt, Occupancy{0.0, 1.0}, quality);
75  }
76  }
77 
78  virtual const MapType& map() const { return _map; }
79  virtual MapType& map() { return _map; }
80 
81 private: // fields
83 };
84 
85 #endif
double x
Definition: state_data.h:38
Tracks a robots perception of an environment. The environment is represented by a GridMap; A laser sc...
virtual const RobotState & pose() const
Returns the robot pose.
Definition: state_data.h:69
An occupancy grid implementation.
Definition: grid_map.h:22
void update_cell(const DiscretePoint2D &cell_coord, const Occupancy &new_value, double quality=1.0)
Definition: grid_map.h:76
Defines some structures related to data obtained from sensors. There are structures ScanPoint and Tra...
double theta
The position of robot.
Definition: state_data.h:38
double y
Definition: state_data.h:38
Defines the Grid map.
Defines a robot position in cartesian coordinates and an angle of rotation.
Definition: state_data.h:14
Defines some classes related to a robot state. There are classes RobotState and World.
const std::vector< Point > & points() const
Returns the line&#39;s component points.
virtual const MapType & map() const
Returns the map.
DiscretePoint2D world_to_cell(double x, double y) const
Definition: grid_map.h:101
std::vector< ScanPoint > points
The vector of points on scan.
Definition: sensor_data.h:36
double quality
The quality of scan. 0 - low, 1 - fine.
Definition: sensor_data.h:37
virtual void handle_scan_point(MapType &map, double laser_x, double laser_y, double beam_end_x, double beam_end_y, bool is_occ, double quality)
Defines a line segment on a plane.
Defines a point with integer coordinates on a plane.
Framework internal representation of a laser scan.
Definition: sensor_data.h:33
virtual MapType & map()
LaserScanGridWorld(std::shared_ptr< GridCellStrategy > gcs, const GridMapParams &init_params)
virtual void handle_observation(TransformedLaserScan &scan)


tiny_slam
Author(s):
autogenerated on Mon Jun 10 2019 15:30:57