cartographer-project / cartographer_ros

Provides ROS integration for Cartographer.
Apache License 2.0
1.66k stars 1.21k forks source link

moving to 3d from 2d failing #1147

Closed dan9thsense closed 5 years ago

dan9thsense commented 5 years ago

I have been successfully using cartographer in 2d with a 2d lidar and am now moving to 3d. I am generating the point cloud with a +- 15 vertical degrees, 360 horizontal degrees lidar and using the same IMU as for 2d. I am able to get good results using the example 3d bag files in the repository. However, when I use my own data, no walls get formed. Also, the robot is localized correctly within the point cloud, but when the robot moves, the point cloud moves instead of the robot. The transform generated by cartographer from map -> base_link shows only very small translations. The rotation, however, is correct.

Here is the output from rosbag_validate: rosrun cartographer_ros cartographer_rosbag_validate -bag_filename X1_3_level.bag I0104 19:35:44.983836 28213 rosbag_validate_main.cc:398] Time delta histogram for consecutive messages on topic "/X1/imu/data" (frame_id: "X1/base_link"): Count: 5066 Min: 0.020000 Max: 0.020000 Mean: 0.019999 I0104 19:35:44.984140 28213 rosbag_validate_main.cc:398] Time delta histogram for consecutive messages on topic "/X1/points" (frame_id: "X1/front_laser"): Count: 1519 Min: 0.064000 Max: 0.069000 Mean: 0.066668 [0.064000, 0.064500) Count: 2 (0.131666%) Total: 2 (0.131666%) [0.064500, 0.065000) # Count: 104 (6.846610%) Total: 106 (6.978275%) [0.065000, 0.065500) Count: 0 (0.000000%) Total: 106 (6.978275%) [0.065500, 0.066000) Count: 0 (0.000000%) Total: 106 (6.978275%) [0.066000, 0.066500) ####### Count: 542 (35.681370%) Total: 648 (42.659645%) [0.066500, 0.067000) Count: 0 (0.000000%) Total: 648 (42.659645%) [0.067000, 0.067500) ######## Count: 629 (41.408821%) Total: 1277 (84.068466%) [0.067500, 0.068000) Count: 0 (0.000000%) Total: 1277 (84.068466%) [0.068000, 0.068500) ### Count: 234 (15.404872%) Total: 1511 (99.473335%) [0.068500, 0.069000] Count: 8 (0.526662%) Total: 1519 (100.000000%)

The IMU and 3d lidar are nearly co-located, so to keep things simple, I just publish static transforms from them both (X1/imu_link and X1/front_lidar) to X1/base_link. I also publish a static transform from X1/base_link to base_link which is the published frame specified in the lua file.

Here is a link to a google drive folder that contains the bag file as well as the static transforms file, the launch file, and the lua file that I am using. These files are all added to the standard cartographer_ros cloned repository.

Here is what I do: roscore rosparam set use_sim_time true roslaunch cartographer_ros static_transform_publisher_X1_base_link__X1_imu_link.launch roslaunch cartographer_ros subt_X1_3d_cartographer.launch rosrun rviz rviz (then load the cartographer 3d demo .rviz file from within rviz) cd to bag files folder rosbag play --clock X1_3_level.bag

Here is the initial location. The map and base_link tf markers are on top of each other (as expected) and are in the correct location and the point cloud looks good rviz_screenshot_3d_cartographer0

As the robot moves, the point cloud moves too. The overall location of the map and base_link tf markers are correct with respect to the point cloud, but they remain on top of one another. This suggests to me that no mapping is happening. Also, there are no walls showing up like they do with the 3d example data from the repo. rviz_screenshot_3d_cartographer1

Moving farther, same thing. Note that the rotation of the tf markers are correct. rviz_screenshot_3d_cartographer2

We arrive on the other side of the field. The point cloud is correct with respect to the robot location, but our map and base_link markers remain on top of each other. rviz_screenshot_3d_cartographer3

dan9thsense commented 5 years ago

Solved by changing TRAJECTORY_BUILDER_3D.num_accumulated_range_data = 160 to TRAJECTORY_BUILDER_3D.num_accumulated_range_data = 1

Duke-Allen commented 5 years ago

@dan9thsense 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?

dan9thsense commented 5 years ago

Are you able to get the example code and bag files from the cartographer repository to work? That is an important first step.

Duke-Allen commented 5 years ago

@dan9thsense Thanks for your reply. I am sorry that I am not sure what your mean. I have been running 2D cartographer successfully with a lidar. Now I am moving to 3D. But the result built by my 3D cartographer did differ with the real movement. I am not know what the problem is. I checked my urdf, but I did not find error(may be I did't find out). Do you know how to solve it?

dan9thsense commented 5 years ago

I don't know how to help you more. Look at the bag file examples provided in the source code repository and try to get those to work. I was able to solve the problem by changing

TRAJECTORY_BUILDER_3D.num_accumulated_range_data = 160 to TRAJECTORY_BUILDER_3D.num_accumulated_range_data = 1

Duke-Allen commented 5 years ago

Thanks for your reply. I will try it again.