cartographer-project / cartographer_ros

Provides ROS integration for Cartographer.
Apache License 2.0
1.64k stars 1.2k forks source link

Huge Drift In Map (Loop Not Closing) #629

Closed shreyashub closed 6 years ago

shreyashub commented 6 years ago

Hi, I have used cartographer to create an outdoor map using a 3D lidar(Quanergy M8). Data is collected from a car moving at about 12 miles/hr in an dynamic environment. 1.It works fine with tiny maps(image, bagfile ), 2.But with a large map, there is a huge drift( image, odometry from ins )
3.Even if I don't provide odometery to it, there is no difference in the map that is generated. 4.It also takes the ground as an obstacle and gives it a dark color. Is there a way around it? 5.Also is there an way to remove dynamic objects to not be mapped. Attachments: rosbag_validate output : link bag_file : link URDF, rosbag_validate CSV ,Config Files and Launch files link Forked Repo : link

gaschler commented 6 years ago

Having just a quick look at your configuration,

  1. TRAJECTORY_BUILDER_3D.num_accumulated_range_data = 1 is too low, this is ~0.01 s, I'd try something in the 0.5 s range first.
  2. Lidar has a very high jitter, I'd speculate you are dropping most frames.

Concerning your questions, (4.) Of course ground is part of the submaps, it's good for scan matching. (5.) There is no such feature.

shreyashub commented 6 years ago

Changing TRAJECTORY_BUILDER_3D.num_accumulated_range_data to 2 or 4, doesn't seem to make a big change. But I'll try again. I'll try fixing the lidar data too. In the demo bagfile, it assigns the ground as white(very light). But in my case it's pretty dark. Is that a problem? Any other insights will be deeply appreciated.

gaschler commented 6 years ago

Since your range data messages are very small, I'd recommend to try TRAJECTORY_BUILDER_3D.num_accumulated_range_data = 50 or similar to accumulate one lidar revolution.

shreyashub commented 6 years ago

Thanks, it(loop closure) works almost perfectly (image). But now the maps loose detail, and at a particular point its very hazy old(clear) , new(not clear)

gaschler commented 6 years ago

I believe the result quality are limited by the high Lidar frame drop.

The color of the x-ray images in rviz are some projection of the submap data for visualization only, and IMHO not a strong indicator for the quality of the submaps.

Closing, feel free to re-open, for instance when better Lidar recordings are available.

tiberium24 commented 5 years ago

Hello could you please help me,

I am trying to use the same Quanergy M8 lidar with Cartographer in ROS. My approach is similar to yours. I am first trying to test it only with lidar point cloud without IMU or other sensors. I get the following error however and no map is built or scan match points published. The topic Sensor/points is publishing however.

screenshot from 2018-12-11 17-04-34

My launch file:

<launch>
  <param name="robot_description"
    textfile="$(find cartographer_ros)/urdf/test1.urdf" />

  <node name="robot_state_publisher" pkg="robot_state_publisher"
    type="robot_state_publisher" />

  <node name="cartographer_node" pkg="cartographer_ros"
      type="cartographer_node" args="
          -configuration_directory $(find cartographer_ros)/configuration_files
          -configuration_basename test1.lua"
      output="screen">
    <remap from="points2" to="Sensor/points" />
<!--     <remap from="imu" to="imu/data" />--> 
  </node>

  <node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"
      type="cartographer_occupancy_grid_node" args="-resolution 0.05" />

  <node name="rviz" pkg="rviz" type="rviz" required="true"/>
</launch>

My lua file:

include "map_builder.lua"
include "trajectory_builder.lua"

options = {
  map_builder = MAP_BUILDER,
  trajectory_builder = TRAJECTORY_BUILDER,
  map_frame = "map",
  tracking_frame = "base_link",
  published_frame = "base_link",
  odom_frame = "base_link",
  provide_odom_frame = false,
  publish_frame_projected_to_2d = false,
  use_odometry = false,
  use_nav_sat = false,
  use_landmarks = false,
  num_laser_scans = 0,
  num_multi_echo_laser_scans = 0,
  num_subdivisions_per_laser_scan = 1,
  num_point_clouds = 1,
  lookup_transform_timeout_sec = 0.2,
  submap_publish_period_sec = 0.3,
  pose_publish_period_sec = 5e-3,
  trajectory_publish_period_sec = 30e-3,
  rangefinder_sampling_ratio = 1.,
  odometry_sampling_ratio = 1.,
  fixed_frame_pose_sampling_ratio = 1.,
  imu_sampling_ratio = 1.,
  landmarks_sampling_ratio = 1.,
}

TRAJECTORY_BUILDER_3D.num_accumulated_range_data = 65

MAP_BUILDER.use_trajectory_builder_3d = true
MAP_BUILDER.num_background_threads = 7
POSE_GRAPH.optimization_problem.huber_scale = 5e2
POSE_GRAPH.optimize_every_n_nodes = 320
POSE_GRAPH.constraint_builder.sampling_ratio = 0.03
POSE_GRAPH.optimization_problem.ceres_solver_options.max_num_iterations = 10
POSE_GRAPH.constraint_builder.min_score = 0.62
POSE_GRAPH.constraint_builder.global_localization_min_score = 0.66

return options

My urdf:

<robot name="cartographer_backpack_3d">
  <material name="orange">
    <color rgba="1.0 0.5 0.2 1" />
  </material>
  <material name="gray">
    <color rgba="0.2 0.2 0.2 1" />
  </material>

<!--   <link name="imu_link">
    <visual>
      <origin xyz="0.0 0.0 0.0" />
      <geometry>
        <box size="0.06 0.04 0.02" />
      </geometry>
      <material name="orange" />
    </visual>
  </link> -->

  <link name="Sensor">
    <visual>
      <origin xyz="0.0 0.0 0.0" />
      <geometry>
        <cylinder length="0.07" radius="0.05" />
      </geometry>
      <material name="gray" />
    </visual>
  </link>

  <link name="base_link" />

<!--   <joint name="imu_link_joint" type="fixed">
    <parent link="base_link" />
    <child link="imu_link" />
    <origin xyz="0 0 0" rpy="3.1416 0 0" />
  </joint>
 -->
  <joint name="Lidar_joint" type="fixed">
    <parent link="base_link" />
    <child link="Sensor" />
    <origin xyz="0.01 0. 0.19" rpy="0. -0.1745 3.1416" />
  </joint>

</robot>
rdesc commented 5 years ago

@tiberium24 just add TRAJECTORY_BUILDER_2D.use_imu_data = false in your lua file. By default it is set to true

Duke-Allen commented 5 years ago

Hello, I am using a 16-lines LIDAR and IMU to build 3D map by cartographer. I tun the parameters and run it with no error, the results are as follows: 2019-02-27 21-56-15 2019-02-27 21-56-43

There is a big gap with the real environment. I think the map is messy. What is the problem of this result? How can I solve it? This is the validate result of my bag:

2019-02-27 22-16-52

Here are my files: demo_rsldiar_3d.launch rslidar_3d.launch mydemo_3d.rviz rslidar_2d.urdf rslidar_scan_3d.lua my data bag Do you know the problem?