introlab / rtabmap_ros

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

Could we change odometry parameters on runtime (e.g., enabling Odometry panel in rtabmapviz)? #281

Open matlabbe opened 5 years ago

matlabbe commented 5 years ago

Option 1) There could be a refactoring to do on how RTAB-Map's parameters are handled. For example, instead of putting them all in global namespace, we may avoid this by using get_parameters and set_parameters services. These services would be called for rtabmap and odometry nodes separately. In Preferences dialog, we would have to check how we would handle shared parameters between rtabmap and odometry. For example, if Vis/ parameters differ between rtabmap and odometry nodes, what we do? We adjust the PreferencesDialog if we want to change rtabmap or odometry parameters, probably by asking when opening Preferences which node we want to get/set parameters.

Option 2) Keep rtabmapviz only for rtabmap parameters. Use dynamic_reconfigure for Odometry? We may have to generate dynamically the cfg file in order to use parameters from Parameters.h. The only issue I have is the min/max values of the parameters, which may be general for the first iteration. To make min/max more specific, we would have to refactor Parameters.h to set them.

mattiasmar commented 2 months ago

Is this feature enabled? Can one update rtabmap parameters dynamically using ros2 messages now? If yes, how?

matlabbe commented 2 months ago

For rtabmap node, you can update parameters directly with set_parameters ros service. Under the hood, the RTAB-Map's parameters will be handled: https://github.com/introlab/rtabmap_ros/blob/57dd787a589ab40c75b43f1ed72084858440f107/rtabmap_slam/src/CoreWrapper.cpp#L855-L911

For odometry nodes, there is also a set_parameters that exists like all ros2 nodes, but updating the parameters after the node is initialized won't change anything (we didn't set any specific callback on that service). Note that even in standalone application, we don't support changing odometry parameters after it is initialized. The Odometry object has to be recreated as it cannot be reconfigured after being constructed: https://github.com/introlab/rtabmap/blob/master/corelib/include/rtabmap/core/Odometry.h

Under ROS2, an option 3 could be to keep in cache the parameters set on initialization, and when set_parameters is called, we re-initialized from zero the node by re-creating a new Odometry: https://github.com/introlab/rtabmap_ros/blob/57dd787a589ab40c75b43f1ed72084858440f107/rtabmap_odom/src/OdometryROS.cpp#L348

Note however that it is exactly like re-launching the node with different parameters.