cartographer-project / cartographer_ros

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

Mapping tune help #1681

Closed sai5555 closed 2 years ago

sai5555 commented 2 years ago

Dear

I use real robot to run cartographer and gmapping for environment. (Lidar is rplidar S1)

But created map by gmapping have good effect than cartographer.

please help me , thanks.

The following link are launch(including static's tf) , bag , woIMU.lua . http://blackdragonyu.synology.me:5000/d/s/ltL5ttGBKd2X3uZVZuU8bRMKCZwtb7Hb/YXXYk4Sr7g9BE6pJEwfEpL_Uyp-A4kkN-hrqglEBR_wg

bag : /odom /scan_original /imu/data (Only gyro without accelerometer)

lua :

options = {
  map_builder = MAP_BUILDER,
  trajectory_builder = TRAJECTORY_BUILDER,
  map_frame = "map",
  tracking_frame = "base_link",
  published_frame = "base_link",
  odom_frame = "odom",
  provide_odom_frame = true,
  publish_frame_projected_to_2d = false,
  use_odometry = true,
  use_nav_sat = false,
  use_landmarks = false,
  num_laser_scans = 1,
  num_multi_echo_laser_scans = 0,
  num_subdivisions_per_laser_scan = 10,
  num_point_clouds = 0,
  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.,
}

MAP_BUILDER.use_trajectory_builder_2d = true
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.num_accumulated_range_data = 20
TRAJECTORY_BUILDER_2D.min_range = 0.0
TRAJECTORY_BUILDER_2D.max_range = 40
MAP_BUILDER.num_background_threads = 8
return options

When I run cartographer_bag_validate to validate bag.

rosrun cartographer_ros cartographer_rosbag_validate -bag_filename filtered.bag

E20211018 10:12:35.044036 33740 rosbag_validate_main.cc:351] frame_id "laser_link" on topic /scan_original has serialization time 1633678806.934814941 but sensor time 1633678806.356117553 differ
ing by -0.578697 s.                                                                                                                                                                               
W20211018 10:12:35.047132 33740 rosbag_validate_main.cc:353] frame_id "laser_link" on topic /scan_original has serialization time 1633678807.037678921 but sensor time 1633678806.934239409 differ
ing by -0.10344 s.                                                                                                                                                                                
W20211018 10:12:35.196517 33740 rosbag_validate_main.cc:103] frame_id imu time 1633678812064215183: IMU linear acceleration is 0 m/s^2, expected is [3, 30] m/s^2. (It should include gravity and 
be given in m/s^2.) linear_acceleration 0 0 0                                                                                                                                                     
W20211018 10:12:35.196602 33740 rosbag_validate_main.cc:103] frame_id imu time 1633678812069197893: IMU linear acceleration is 0 m/s^2, expected is [3, 30] m/s^2. (It should include gravity and 
be given in m/s^2.) linear_acceleration 0 0 0                                                                                                                                                     
W20211018 10:12:35.196619 33740 rosbag_validate_main.cc:103] frame_id imu time 1633678812074180126: IMU linear acceleration is 0 m/s^2, expected is [3, 30] m/s^2. (It should include gravity and 
be given in m/s^2.) linear_acceleration 0 0 0                                                                                                                                                     
E20211018 10:12:46.902880 33740 rosbag_validate_main.cc:366] Average IMU linear acceleration is 0 m/s^2, expected is [9.5, 10.5] m/s^2. Linear acceleration data should include gravity and be giv
en in m/s^2.                                                                                                                                                                                      
I20211018 10:12:46.904744 33740 rosbag_validate_main.cc:399] Time delta histogram for consecutive messages on topic "/imu/data" (frame_id: "imu"):                                                
Count: 78122  Min: 0.0045929  Max: 0.00531387  Mean: 0.00500077                                                                                                                                   
[0.004593, 0.004665)                            Count: 2 (0.0025601%)   Total: 2 (0.0025601%)                                                                                                     
[0.004665, 0.004737)                            Count: 1 (0.00128005%)  Total: 3 (0.00384015%)                                                                                                    
[0.004737, 0.004809)                            Count: 2 (0.0025601%)   Total: 5 (0.00640025%)                                                                                                    
[0.004809, 0.004881)                            Count: 2 (0.0025601%)   Total: 7 (0.00896034%)                                                                                                    
[0.004881, 0.004953)                            Count: 8 (0.0102404%)   Total: 15 (0.0192007%)                                                                                                    
[0.004953, 0.005025)       #################    Count: 65208 (83.4694%) Total: 65223 (83.4886%)
[0.005025, 0.005098)                     ###    Count: 12766 (16.3411%) Total: 77989 (99.8298%)
[0.005098, 0.005170)                            Count: 131 (0.167686%)  Total: 78120 (99.9974%)
[0.005170, 0.005242)                            Count: 0 (0%)   Total: 78120 (99.9974%)
[0.005242, 0.005314]                            Count: 2 (0.0025601%)   Total: 78122 (100%)
E20211018 10:12:46.905306 33740 rosbag_validate_main.cc:383] Point data (frame_id: "laser_link") has a large gap, largest is 0.578122 s, recommended is [0.0005, 0.05] s with no jitter.
I20211018 10:12:46.905506 33740 rosbag_validate_main.cc:399] Time delta histogram for consecutive messages on topic "/scan_original" (frame_id: "laser_link"):
Count: 3965  Min: 0.0947792  Max: 0.578122  Mean: 0.0999386
[0.094779, 0.143113)    ####################    Count: 3963 (99.9496%)  Total: 3963 (99.9496%)
[0.143113, 0.191448)                            Count: 0 (0%)   Total: 3963 (99.9496%)
[0.191448, 0.239782)                            Count: 1 (0.0252207%)   Total: 3964 (99.9748%)
[0.239782, 0.288116)                            Count: 0 (0%)   Total: 3964 (99.9748%)
[0.288116, 0.336451)                            Count: 0 (0%)   Total: 3964 (99.9748%)
[0.336451, 0.384785)                            Count: 0 (0%)   Total: 3964 (99.9748%)
[0.384785, 0.433119)                            Count: 0 (0%)   Total: 3964 (99.9748%)
[0.433119, 0.481453)                            Count: 0 (0%)   Total: 3964 (99.9748%)
[0.481453, 0.529788)                            Count: 0 (0%)   Total: 3964 (99.9748%)
[0.529788, 0.578122]                            Count: 1 (0.0252207%)   Total: 3965 (100%)
I20211018 10:12:46.905635 33740 rosbag_validate_main.cc:399] Time delta histogram for consecutive messages on topic "/odom" (frame_id: "odom"):
Count: 5947  Min: 0.0659156  Max: 0.0673916  Mean: 0.0666666
[0.065916, 0.066063)                            Count: 1 (0.0168152%)   Total: 1 (0.0168152%)
[0.066063, 0.066211)                            Count: 0 (0%)   Total: 1 (0.0168152%)
[0.066211, 0.066358)                            Count: 0 (0%)   Total: 1 (0.0168152%)
[0.066358, 0.066506)                            Count: 31 (0.521271%)   Total: 32 (0.538086%)

How to tune lidar's time for the message "Point data (frame_id: "laser_link") has a large gap, largest is 0.578122 s, recommended is [0.0005, 0.05] s with no jitter." ? I use standard arguments for rplidar S1

  <!-- rplidar -->
  <node name="rplidarNode"          pkg="rplidar_ros"  type="rplidarNode" output="screen">
    <param name="serial_port"         type="string" value="/dev/rplidar"/>  
    <param name="serial_baudrate"     type="int"    value="256000"/>
    <param name="frame_id"            type="string" value="laser_link"/>
    <param name="inverted"            type="bool"   value="false"/>
    <param name="angle_compensate"    type="bool"   value="true"/>
  </node>

Gmapping (black zone is forbidden zone , please skip it) gmapping

Cartographe cartographer r

eithwa commented 2 years ago

image image

If you can set the z-axis acceleration of imu to -9.8, it will be helpful to construct the map. https://gist.github.com/eithwa/2aeca51fc093a284d928cb3784ee2782

sai5555 commented 2 years ago

image image

If you can set the z-axis acceleration of imu to -9.8, it will be helpful to construct the map. https://gist.github.com/eithwa/2aeca51fc093a284d928cb3784ee2782

Hi Eithwa Thank your response quickly and good parameters. I find these key parameters using scan_matching and POSE_GRAPH.optimalization that improve map's accuracy.

By the way , I have other environment (office but no enclosed space) http://blackdragonyu.synology.me:5000/d/s/lv9mfG9Cdsdwq9T9xXH2juYBfRTKuPAh/XvL0cLltf0F9ncRmfqfoNeRZ96DF3FJG-x7wAB7u7AAk

withIMU.lua : Using IMU data (add -9.8 to imu's acceleration's z by flat_world_imu_node) imu_add_-9

woIMU.lua : without using IMU data

The following are created map by two lua file 1.withIMU.lua (add -9.8 acceleration cause map's skew..) cartographer_withIMU

2.woIMU.lua cartograph_woIMU

3.Gmapping gmapping

eithwa commented 2 years ago

image I changed some parameters https://gist.github.com/eithwa/2aeca51fc093a284d928cb3784ee2782

sai5555 commented 2 years ago

image I changed some parameters https://gist.github.com/eithwa/2aeca51fc093a284d928cb3784ee2782

Hi Eithwa Very thank you again. It is magic. I try your parameters can help us. I will study your optimal parameters. Besides , do you give comments for me about IMU's tune strategy about accelerometer.(IMU device is realsense D435i. ) The gryo's value is good but I dont know accelerometer's value how to tune for cartographer. Could cartographer also use accelerometer.x value besides z ? Imu's install position of robot is 0.4 m height from floor.

eithwa commented 2 years ago

image I think there is a problem with the angular velocity and modify it. When the terrain is flat, I think acceleration have little effect when constructing a 2d map. btw I'm sorry, it should be set to 9.8 in linear_acceleration.z image

sai5555 commented 2 years ago

image I think there is a problem with the angular velocity and modify it. When the terrain is flat, I think acceleration have little effect when constructing a 2d map. btw I'm sorry, it should be set to 9.8 in linear_acceleration.z image

Hi Eithwa I got it . I will set accelerometer.z value to 9.8. thanks. But I dont know why the angular_vel.z equal to -angular_vel.y in your picture ?

eithwa commented 2 years ago

When the robot turns, the angular velocity of the y axis changes, which I think is incorrect.

sai5555 commented 2 years ago

When the robot turns, the acceleration of the y axis changes, which I think is incorrect.

Thanks again. I found sloppy mistake of angular velocity from realsense's gyro data. I will correct it.