Skip to content

Some possible bugs in voxel_layer #5099

@coderbaibai

Description

@coderbaibai

Bug report

Required Info:

  • Operating System: Ubuntu 24.04
  • Computer:12th Gen Interl(R) Core(TM) i5-1240P
  • ROS2 Version: jazzy
  • Version or commit hash:0aee198
  • DDS implementation:fastdds

Steps to reproduce issue

1.Use voxel layer on local_costmap and start a simulation or a real robot.
for example

plugins: ["voxel_layer", "inflation_layer"]
inflation_layer:
        plugin: "nav2_costmap_2d::InflationLayer"
        cost_scaling_factor: 3.0
        inflation_radius: 0.5
      voxel_layer:
        plugin: "nav2_costmap_2d::VoxelLayer"
        enabled: True
        publish_voxel_map: True
        origin_z: 0.0
        z_resolution: 0.05
        z_voxels: 16
        max_obstacle_height: 2.0
        mark_threshold: 0
        observation_sources: scan
        scan:
          topic: /scan
          max_obstacle_height: 2.0
          clearing: True
          marking: True
          data_type: "LaserScan"
          raytrace_max_range: 3.0
          raytrace_min_range: 0.0
          obstacle_max_range: 2.5
          obstacle_min_range: 0.0
  1. Subscribing /local_costmap/clearing_endpoints in rviz2.
  2. Send some goal to the robot, drive it around.

Expected behavior

The points of /local_costmap/clearing_endpoints are stable in some ways.I mean we would not abandon points easily.

Actual behavior

Many points are abandon.I print the infomation of the points, I found they are all on the boundary of the local_costmap.

Reproduction instructions

Add some tolerant for the precision.As a result it works.

inline bool worldToMap3DFloat(
    double wx, double wy, double wz, double & mx, double & my,
    double & mz)
  {
    if (wx < origin_x_-0.001 || wy < origin_y_-0.001 || wz < origin_z_-0.001) {
      RCLCPP_WARN(logger_,"drop point (%.3lf,%.3lf,%.3lf) below (%.3lf,%.3lf,%.3lf)",wx,wy,wz,origin_x_,origin_y_,origin_z_);
      return false;
    }
    if(wx < origin_x_) wx = origin_x_;
    if(wy < origin_y_) wy = origin_y_;
    if(wz < origin_z_) wz = origin_z_;
    mx = ((wx - origin_x_) / resolution_);
    my = ((wy - origin_y_) / resolution_);
    mz = ((wz - origin_z_) / z_resolution_);
    if (mx < size_x_ && my < size_y_ && mz < size_z_) {
      return true;
    }
    RCLCPP_WARN(logger_,"drop point (%.3lf,%.3lf,%.3lf) over (%.3lf,%.3lf,%.3lf)",wx,wy,wz,size_x_*resolution_+origin_x_,size_y_*resolution_+origin_y_,size_z_*z_resolution_+origin_z_);
    return false;
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions