1 #ifndef SLAM_CTOR_UTILS_DG_LASER_SCAN_GENERATOR_H 2 #define SLAM_CTOR_UTILS_DG_LASER_SCAN_GENERATOR_H 7 #include "../../core/math_utils.h" 8 #include "../../core/maps/grid_map.h" 9 #include "../../core/states/sensor_data.h" 10 #include "../../core/geometry_utils.h" 26 constexpr
static auto to_lsp(
double max_dist,
double fow_deg,
unsigned pts_nm) {
36 double occ_threshold = 1) {
39 scan.
trig_provider = std::make_shared<RawTrigonometryProvider>();
40 auto robot_point = pose.
point();
44 "LS Gen: robot at cell boundary is not supported");
46 auto hhsector = _lsp.h_hsector;
47 for (
double a = -hhsector; a <= hhsector; a += _lsp.h_angle_inc) {
48 if (2*M_PI <= hhsector + a) {
break; }
49 auto beam_dir =
Point2D{_lsp.max_dist * std::cos(a + pose.
theta),
50 _lsp.max_dist * std::sin(a + pose.
theta)};
51 auto area_ids = map.
world_to_cells({robot_point, robot_point + beam_dir});
52 for (
auto& area_id : area_ids) {
53 if (map[area_id] < occ_threshold) {
continue; }
56 auto ray =
Ray{robot_point.x, beam_dir.x, robot_point.y, beam_dir.y};
58 if (inters.size() == 1) {
64 assert(2 == inters.size() &&
"BUG! LS Gen: obstacle is not pierced");
65 auto obst_pnt =
Point2D{(inters[0].x + inters[1].x) / 2,
66 (inters[0].
y + inters[1].
y) / 2};
67 auto range = std::sqrt(robot_point.dist_sq(obst_pnt));
69 scan.
points().push_back(scan_point);
71 auto added_wp = scan_point.move_origin(pose.
x, pose.
y, pose.
theta);
73 assert(area_id == sp_area_id &&
74 "[BUG] Estimated scan point doesn't lie is expected area");
static ScanPoint2D make_polar(double range, double angle, bool is_occ)
static constexpr auto to_lsp(double max_dist, double fow_deg, unsigned pts_nm)
constexpr LaserScannerParams()
LaserScanGenerator(LaserScannerParams ls_params={})
Coord world_to_cell(const Point2D &pt) const
Rectangle world_cell_bounds(const Coord &coord) const
CONSTEXPR bool are_equal(const T &a, const T &b, const T &eps)
TFSIMD_FORCE_INLINE const tfScalar & y() const
constexpr LaserScannerParams(double mx_dist, double h_a_inc, double h_half_sector)
Intersections find_intersections(const Segment2D &s) const
const Points & points() const
std::vector< Coord > world_to_cells(const Segment2D &s) const
LaserScan2D laser_scan_2D(const GridMap &map, const RobotPose &pose, double occ_threshold=1)
std::shared_ptr< TrigonometryProvider > trig_provider
constexpr double deg2rad(double angle_deg)
virtual double scale() const