Generating 2D occupancy map

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Generating 2D occupancy map

You Li
Hi,

I was trying to generating the 2D grid map using the .db file. Here is the commends I used:

$ roscore
$ rosrun rtabmap_ros rtabmap _database_path:=data_01.db
$ rosrun map_server map_saver map:=proj_map
$ rosservice call /publish_map 1 1 0

I got a result which is black. Which does not make sense. I remember previously, I can get a grid map which seems normal. Thus, I processed a previous data, the result is similar:


And here is the previous result:


Anybody has met this before?
Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Generating 2D occupancy map

matlabbe
Administrator
Hi,

Can you share the database? Not sure what do you mean by before, did you update rtabmap? Which version are you using?

cheers
Reply | Threaded
Open this post in threaded view
|

Re: Generating 2D occupancy map

You Li
Thanks for replying! Before means previously I could get the normal one :)
Here is my RTABMAP version:


Please use this data:
https://www.dropbox.com/s/ggkswqglqwo8aa0/01_floor_down_cart_clockwise.db?dl=0

Maybe by some reason I changed the config file that control the output of Occupancy grid map?
 

Thanks,
You Li
Reply | Threaded
Open this post in threaded view
|

Re: Generating 2D occupancy map

matlabbe
Administrator
Hi,

I think that it is because in hydro, the ceiling is considered as ground, which is not in indigo. The camera is tilted toward ceiling, not the ground, which causing problems to create the occupancy grid by projection (the camera should see the ground to add empty cells to map). Also the TF between the camera and the robot base is wrong (looks like too much tilted than in reality), as shown in the following picture:


This TF problem is also reflected in odometry, the whole map is tilted:


If you are using rgbd_odometry for odometry and you are always moving on a plane ground, you can set "Reg/Force3DoF" to true (in Hydro it was Odom/Force2D) to ignore roll/pitch/z odometry errors.

cheers
Reply | Threaded
Open this post in threaded view
|

Re: Generating 2D occupancy map

You Li
In reply to this post by matlabbe
Thanks Mathieu! I will try the setting, and make my kinect towards lower for tests.

So you obtained the similar result of occupancy grid map (i.e., the almost black one), if do not set "Reg/Force3DoF" to true?

I am using the Kinetic, I will follow your method first.

Cheers,
You Li
Reply | Threaded
Open this post in threaded view
|

Re: Generating 2D occupancy map

matlabbe
Administrator
Yes, the ceiling was detected like an obstacle, so everything is black. I could set "Grid/MaxObstacleHeight" to 0.1 (just to not be null) to filter the ceiling, but as the camera is not seeing the ground, no empty cells were still added. Note that odometry frame_id does not seem to be your robot base link (is it camera_link or kinect2 link?), or maybe there is a missing "z" TF between base_link and camera_link. Normally, if TF is ok and odometry/rtabmap's frame_id is set to base_link (or base_footprint), the ground in the point cloud should match the xy plane.

cheers
Reply | Threaded
Open this post in threaded view
|

Re: Generating 2D occupancy map

You Li
Thanks Mathieu! It works. I tuned the direction of Kinect to horizontal, and the generated occupancy map is good again. I will figure out the frames following your instructions later.

However, now an interesting thing occurs. My RTABMAP result is keeping drifting, no matter I used the RTABMAP software, or rgbd_mapping_kinect2.launch.

Here is the figure:


data:
https://www.dropbox.com/s/hgrkofu6xyj7z6d/161109-183357.db?dl=0

I am quite sure the Kinect is installed pretty horizontally (No significant tilt angle around the forward axis, but maybe slight angle around the lateral axis of the vehicle. I used the cart this time). Also, everything is the same as my previous configurations. I tried two laptops, reinstalled RTABMAP, but met the same problem. During the mapping process, I felt that there is a tilt angle (i.e., rotation around the forward direction) of the mapping result no matter how I tried to tune this tilt angle.

Maybe the physical structure inside the Kinect has been changed? If you met the issue, how would you deal with it, can I solve it by calibrating the device?

Thanks,
You Li
Reply | Threaded
Open this post in threaded view
|

Re: Generating 2D occupancy map

matlabbe
Administrator
Hi,

It is better, but it will be easier if you set a proper height for the camera in your TF, so that the points on the ground match the xy plane in RVIZ. This adjustment can be done without rtabmap, just show up the current point cloud from kinect2 in RVIZ and adjust rotation/height of TF and/or the camera physically.

As mentioned in my previous post, setting "Reg/Force3DoF" to true will remove any z errors.

cheers
Reply | Threaded
Open this post in threaded view
|

Re: Generating 2D occupancy map

You Li
Hi Mathieu,

Thanks a lot. I will do this today.
Which .launch file you use in the RTABMAP software (which one do I need to revise)?

I will first revise the rgbd_mapping_kinect2.launch file, and implement the mapping from commends in terminal.

Best regards,
You Li
Reply | Threaded
Open this post in threaded view
|

Re: Generating 2D occupancy map

matlabbe
Administrator
If you use rgbd_mapping_kinect2.launch, set "Reg/Force3DoF" to true under rtabmap and rgbd_odometry nodes.
Reply | Threaded
Open this post in threaded view
|

Re: Generating 2D occupancy map

You Li
Thanks! Set "Reg/Force3DoF" to true make it way better.


If we would like to set the "Reg/Force3DoF" when we use the rtabmap software, which file do I need to modify?

Thanks,
You Li
Reply | Threaded
Open this post in threaded view
|

Re: Generating 2D occupancy map

matlabbe
Administrator
Do you mean the standalone software? If so, open Preferences->Advanced->Motion Estimation->check "Force 2D transform".

Reply | Threaded
Open this post in threaded view
|

Re: Generating 2D occupancy map

You Li
This post was updated on .
Thanks Mathieu. Yes, it is the standalone software. That works. It is great to find the Advanced settings in the Preferences. :-)

Now I have two questions:

(1)
I am now trying to save the data when using the rgbd_mapping_kinect2.launch. Here are the commands:

1st terminal:
$ roslaunch kinect2_bridge kinect2_bridge.launch publish_tf:=true

2nd terminal:
$ roslaunch rtabmap_ros rgbd_mapping_kinect2_horizontal.launch

rgbd_mapping_kinect2_horizontal.launch

3rd terminal:
$ roslaunch rtabmap_ros data_recorder.launch   frame_id:=kinect2_base_link  subscribe_depth:=true rgb_topic:=kinect2/hd/image_color_rect rgb_info_topic:=kinect2/hd/camera_info depth_topic:=kinect2/hd/image_depth_rect rgb_image_transport:=compressed depth_image_transport:=compressed output_path:=/home/app16/out.db

It saved the out.db data. However, when I used the standalone RTABMAP software to load the .db file, the data is not shown. Is the commends I used proper for saving the db data?

(2)
Meanwhile, I tried to save the data in rosbag, and convert it to .db. I changed the commend in the 3rd terminal to (the other two terminal kept the same):
$ rosbag record -O slam_kinect  /tf /kinect2/hd/image_depth_rect/compressed   /kinect2/hd/camera_info /kinect2/hd/image_color_rect/compressed /kinect2/hd/image_mono_rect/compressed /scan /scan_kinect /rtabmap/odom_local_map   /rtabmap/labels  /rtabmap/scan_map /rtabmap/octomap_empty_space   /rtabmap/odom_info /rtabmap/local_path   /rtabmap/goal_reached   /rtabmap/octomap_proj /rtabmap/info  /rtabmap/move_base/goal   /rtabmap/grid_map /rtabmap/goal_out  /rtabmap/octomap_full   /rtabmap/odom_last_frame /rtabmap/move_base/cancel   /rtabmap/proj_map /rtabmap/mapGraph  /rtabmap/octomap_binary  /rtabmap/octomap_cloud /rtabmap/mapData  /rtabmap/cloud_map /rtabmap/cloud_ground /rtabmap/cloud_obstacles  /rtabmap/odom /scanmatch_odom /rtabmap/octomap_occupied_space /rtabmap/proj_map

Here is the .bag file recorded:
https://www.dropbox.com/s/e8pdp2mdg6ptf5b/slam_kinect.bag?dl=0

Then tried to convert the data:
$ roscore

$ roslaunch rtabmap_ros data_recorder.launch   frame_id:=kinect2_base_link  subscribe_depth:=true rgb_topic:=kinect2/hd/image_color_rect rgb_info_topic:=kinect2/hd/camera_info depth_topic:=kinect2/hd/image_depth_rect rgb_image_transport:=compressed depth_image_transport:=compressed output_path:=/home/app16/out.db

$ rosbag play --clock slam.bag

It was the same, the data could not be shown in the RTABMAP software. Here is an error that was shown when I run the conveting:



Then, I changed "data_recorder.launch" to "data_recorder_1.launch" by adding some frame relationship, and run it again:
$ roslaunch rtabmap_ros data_recorder_1.launch  subscribe_depth:=true  frame_id:=kinect2_base_link  rgb_topic:=kinect2/hd/image_color_rect rgb_info_topic:=kinect2/hd/camera_info depth_topic:=kinect2/hd/image_depth_rect rgb_image_transport:=compressed depth_image_transport:=compressed output_path:=/home/app16/bag.db

$ rosbag play --clock slam.bag

This time the error information is:


However, when I check the frame informaiton, my .bag file has the depth data, but does not have the depth frame:


Thanks,
You Li
Reply | Threaded
Open this post in threaded view
|

Re: Generating 2D occupancy map

matlabbe
Administrator
Hi,

Normally when you run the commands of your two first terminals, the resulting database in ~/.ros/rtabmap.db contains already all recorded data (at map update rate 1 Hz):
$ roslaunch kinect2_bridge kinect2_bridge.launch publish_tf:=true
$ roslaunch rtabmap_ros rgbd_mapping_kinect2_horizontal.launch 

If you want to record raw data at higher update rate (e.g. camera frame rate 30 Hz), you may use data_recorder.launch. In the way you use it, only RGB and depth images are saved, no odometry. You don't even need to start rgbd_mapping_kinect2_horizontal.launch. It is why if you open that database in RTAB-Map standalone it shows nothing (poses are not saved in the database). However, you can replay it in the standalone like an input source (like if it was a raw kinect data recording), see Preferences -> Source -> Database.
$ roslaunch kinect2_bridge kinect2_bridge.launch publish_tf:=true 
$ roslaunch rtabmap_ros data_recorder.launch   frame_id:=kinect2_base_link  subscribe_depth:=true rgb_topic:=kinect2/hd/image_color_rect rgb_info_topic:=kinect2/hd/camera_info depth_topic:=kinect2/hd/image_depth_rect rgb_image_transport:=compressed depth_image_transport:=compressed output_path:=/home/app16/out.db 

To save poses in the recorded database (at odometry update rate), you must add "subscribe_odometry:=true odom_topic:=/rtabmap/odom". Here you need to start rgbd_mapping_kinect2_horizontal.launch to get odometry computed:
$ roslaunch kinect2_bridge kinect2_bridge.launch publish_tf:=true 
$ roslaunch rtabmap_ros rgbd_mapping_kinect2_horizontal.launch 
$ roslaunch rtabmap_ros data_recorder.launch   frame_id:=kinect2_base_link  subscribe_depth:=true rgb_topic:=kinect2/hd/image_color_rect rgb_info_topic:=kinect2/hd/camera_info depth_topic:=kinect2/hd/image_depth_rect rgb_image_transport:=compressed depth_image_transport:=compressed subscribe_odometry:=true odom_topic:=/rtabmap/odom output_path:=/home/app16/out.db 
Note that recording like this, you only need rgbd_odomerty node from rgbd_mapping_kinect2_horizontal.launch, rtabmap node is not required.

cheers,
Mathieu
Reply | Threaded
Open this post in threaded view
|

Re: Generating 2D occupancy map

You Li
Hi Mathieu,

Many thanks for the detailed description. Based on your instruction, I have got the data with odometry.

Also, after adding the odometry, I successfully obtained the .db file by
$ roslaunch rtabmap_ros data_recorder.launch   frame_id:=kinect2_base_link  subscribe_depth:=true rgb_topic:=kinect2/hd/image_color_rect rgb_info_topic:=kinect2/hd/camera_info depth_topic:=kinect2/hd/image_depth_rect rgb_image_transport:=compressed depth_image_transport:=compressed subscribe_odometry:=true odom_topic:=/rtabmap/odom output_path:=/home/app16/out.db

$ rosbag play --clock slam_kinect.bag

Cheers,
You Li