introlab / rtabmap_ros

RTAB-Map's ROS package.
http://wiki.ros.org/rtabmap_ros
BSD 3-Clause "New" or "Revised" License
957 stars 556 forks source link

How can I save the published user data in rtabmap database to use them for visualization in localization mode? #749

Open SahanGura opened 2 years ago

SahanGura commented 2 years ago

I am trying to generate a map of the environment with markers for visualization. I followed the wifi signal publishing method and successfully implemented visualizing arrows in some poses of the trajectory. However, I need to save all the marker locations in the rtabmap database as I need these markers with the map to run the robot in the localization mode. But it seems the markers are not saved in the rtabmap database. How can I solve this?

matlabbe commented 2 years ago

First you should make sure that user data are saved in the database during mapping (based on this example):

$ rtabmap-info demo_wifi.db

[...]

Info:

Path:               demo_wifi.db
Version:            0.12.0
Sessions:           1
Total odometry length:53.355396 m
Total time:         203.178632s
LTM:                193 nodes and 18897 words (dim=64 type=32F)
WM:                 142 nodes and 17755 words
Global graph:       193 poses and 284 links
Optimized graph:    0 poses (x=284->0, y=0->0, z=0->0)
Maps in graph:      0/1 []
Ground truth:       0 poses
GPS:                0 poses
Links:
  Neighbor:         282
  GlobalClosure:    2
  LocalSpaceClosure:0
  LocalTimeClosure: 0
  UserClosure:      0
  VirtualClosure:   0
  NeighborMerged:   0
  PosePrior:        0
  Landmark:         0
  Gravity:          0

Database size:      67 MB
Nodes size:         26 KB   (0.04%)
Links size:         27 KB   (0.04%)
RGB Images size:    12 MB   (18.06%)
Depth Images size:  23 MB   (34.65%)
Calibrations size:  13 KB   (0.02%)
Grids size:         3 MB    (5.21%)
Scans size:         0 Bytes (0.00%)
User data size:     2 KB    (0.00%)
Dictionary size:    5 MB    (7.84%)
Features size:      19 MB   (28.15%)
Statistics size:    433 KB  (0.64%)
Other (indexing, unused):3 MB   (5.35%)

If you have user data in the map, the line User data size: 2 KB won't be 0 bytes.

EDIT: Just tried the same example in localization mode:

$ roslaunch rtabmap_ros rtabmap.launch database_path:=~/Downloads/demo_wifi.db rtabmapviz:=false rviz:=true localization:=true
$ rosrun rtabmap_ros wifi_signal_sub
$ rviz
$ rosservice call /rtabmap/publish_map 1 1 0

Screenshot from 2022-05-09 14-11-46