Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert nodes to lifecycle nodes #561

Merged
merged 46 commits into from
Jan 4, 2024

Conversation

kei1107
Copy link
Contributor

@kei1107 kei1107 commented Dec 13, 2022


Basic Info

Info Please fill out this column
Ticket(s) this addresses #244
Primary OS tested on Ubuntu22 (docker)
Robotic platform tested on Turtlebot3 gazebo simulation
async_toolbox_lifecycle_x2.mp4

Description of contribution in a few bullet points

  • Convert AsynchronousSlamToolbox, SynchronousSlamToolbox, LocalizationSlamToolbox, LifelongSlamToolbox and MapAndLocalizationSlamToolbox to lifecycle node
  • Updated some classes to initialize with node_interface instead of using node ptr. Now, those classes can be generated by rclcpp_lifecycle::LifecyclNode in the same way as rclcpp::Node.
  • Update launch for lifecycle autotransition

Description of documentation updates required from your changes

  • AsynchronousSlamToolbox, SynchronousSlamToolbox, LocalizationSlamToolbox, LifelongSlamToolbox and MapAndLocalizationSlamToolbox are updated to LifecycleNode, so need to add that to decoment

Future work that may be required in bullet points

Copy link
Owner

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, a decent first stab.

Lots of thematic cleanup needed before I can more deeply dive into the Common changes made. In general:

  • Make sure to lint
  • Remove all duplicated functions who's role is only to pass particula things of a node to another version of the function, just use the NodeT
  • Use shared pointer of the NodeT, not passing by double references
  • Get parameters using the NodeT, not the interfaces

That should clean up about ~60% of the changes here and make this PR much more easily reviewable

include/slam_toolbox/laser_utils.hpp Outdated Show resolved Hide resolved
include/slam_toolbox/laser_utils.hpp Outdated Show resolved Hide resolved
include/slam_toolbox/loop_closure_assistant.hpp Outdated Show resolved Hide resolved
include/slam_toolbox/map_saver.hpp Outdated Show resolved Hide resolved
lib/karto_sdk/include/karto_sdk/Mapper.h Outdated Show resolved Hide resolved
solvers/ceres_solver.cpp Outdated Show resolved Hide resolved
solvers/ceres_solver.cpp Outdated Show resolved Hide resolved
src/experimental/slam_toolbox_lifelong.cpp Outdated Show resolved Hide resolved
@kei1107
Copy link
Contributor Author

kei1107 commented Dec 20, 2022

Hi, a decent first stab.

Lots of thematic cleanup needed before I can more deeply dive into the Common changes made. In general:

  • Make sure to lint
  • Remove all duplicated functions who's role is only to pass particula things of a node to another version of the function, just use the NodeT
  • Use shared pointer of the NodeT, not passing by double references
  • Get parameters using the NodeT, not the interfaces

That should clean up about ~60% of the changes here and make this PR much more easily reviewable

[0b8ad82]

  • Fixed with ament_cpplint, ament_uncrustify. but, there are also other divergences where I didn't make the changes in this PR (* : below). Sorry if my linter setting are wrong. Please let me know if I need to fix it.
  • Updated to remove duplicate functions and use node templates of shared pointer. And, Get parameters was updated to use NodeT. (Some functions that don't have node template use the interfaces to get parameters.)

I'm very sory to bother you. Please check when you have time. 🙏


(*)details
  • This also occurs in other files.
$ ament_uncrustify src/laser_utils.cpp 
Code style divergence in file 'src/laser_utils.cpp':

--- src/laser_utils.cpp
+++ src/laser_utils.cpp.uncrustify
@@ -101,2 +101,4 @@
-  laser->SetOffsetPose(karto::Pose2(laser_pose_.transform.translation.x,
-    laser_pose_.transform.translation.y, mountingYaw));
+  laser->SetOffsetPose(
+    karto::Pose2(
+      laser_pose_.transform.translation.x,
+      laser_pose_.transform.translation.y, mountingYaw));
@@ -111 +113,3 @@
-  if (std::fabs(angular_range - 2.0 * M_PI) < (scan_.angle_increment - (std::numeric_limits<float>::epsilon() * 2.0f*M_PI))) {
+  if (std::fabs(angular_range - 2.0 * M_PI) <
+    (scan_.angle_increment - (std::numeric_limits<float>::epsilon() * 2.0f * M_PI)))
+  {
@@ -117 +121,3 @@
-  if (angular_range > 6.10865 /*350 deg*/ && std::round(angular_range / scan_.angle_increment) + 1 == scan_.ranges.size()) {
+  if (angular_range > 6.10865 /*350 deg*/ &&
+    std::round(angular_range / scan_.angle_increment) + 1 == scan_.ranges.size())
+  {

1 files with code style divergence

include/slam_toolbox/laser_utils.hpp Outdated Show resolved Hide resolved
include/slam_toolbox/slam_toolbox_common.hpp Outdated Show resolved Hide resolved
include/slam_toolbox/visualization_utils.hpp Outdated Show resolved Hide resolved
solvers/ceres_solver.hpp Outdated Show resolved Hide resolved
Copy link
Owner

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting much closer!

src/experimental/slam_toolbox_map_and_localization.cpp Outdated Show resolved Hide resolved
src/experimental/slam_toolbox_map_and_localization.cpp Outdated Show resolved Hide resolved
src/slam_toolbox_sync.cpp Show resolved Hide resolved
src/slam_toolbox_sync.cpp Outdated Show resolved Hide resolved
src/loop_closure_assistant.cpp Outdated Show resolved Hide resolved
src/slam_toolbox_common.cpp Outdated Show resolved Hide resolved
src/slam_toolbox_common.cpp Outdated Show resolved Hide resolved
src/slam_toolbox_common.cpp Outdated Show resolved Hide resolved
src/slam_toolbox_common.cpp Outdated Show resolved Hide resolved
src/slam_toolbox_common.cpp Outdated Show resolved Hide resolved
Copy link
Owner

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, this looks good to me. I'll need to inquire with a 2nd opinion since this is such a large and sweeping number of changes and reorganizations

launch/lifelong_launch.py Show resolved Hide resolved
@rscova
Copy link

rscova commented Sep 8, 2023

I have tested it with ROS2 Humble for several weeks and works fine. I know other people who have been using it in its projects for some months without any problem. It's fully compatible with nav2 as the standard slam_toolbox. I haven't found any bug or reason to not accept the pull request.

@SteveMacenski
Copy link
Owner

As noted, needs a second detailed technical review to make sure there aren't any subtle issues. At this point, also needs to resolve a merge conflict.

I'll post on Nav2 Slack to see if someone can provide a review

@AntoBrandi
Copy link
Contributor

I've been using this one along with ROS 2 Components and it is working perfectly.

Just some considerations:

@AntoBrandi
Copy link
Contributor

AntoBrandi commented Nov 27, 2023

Another consideration:

When using the lifecycle implementation and starting rviz with the SlamToolbox plugin, it crashes. Specifically here:

while (rclcpp::ok()) {
auto parameters = parameters_client->get_parameters(
{"paused_new_measurements", "interactive_mode"});
paused_measure = parameters[0].as_bool();
interactive = parameters[1].as_bool();

As the nodes will start in the Unconfigured state the parameters are not yet declared and so the get_parameters fails and Rviz crashes

We might change to something like this:

while (rclcpp::ok()) {
    if(parameters_client->has_parameter("paused_new_measurements") && 
       parameters_client->has_parameter("interactive_mode"))
    {
      auto parameters = parameters_client->get_parameters(
        {"paused_new_measurements", "interactive_mode"});
      paused_measure = parameters[0].as_bool();
      interactive = parameters[1].as_bool();

      bool oldState = _check1->blockSignals(true);
      _check1->setChecked(interactive);
      _check1->blockSignals(oldState);

      oldState = _check2->blockSignals(true);
      _check2->setChecked(!paused_measure);
      _check2->blockSignals(oldState);
    }

    r.sleep();
  }

@SteveMacenski
Copy link
Owner

Those are all good points.

On the bond bits: The lifecycle manager does not require bond connections, there's a parameter for it. With that said, if you want to use the same manager instance as the rest of Nav2, then it does. Otherwise, you can have a second instance of it for just localization nodes which don't use it and that works fine. But having that options seems great.

On stack memory changes - good catch. I suppose we can move that into the node itself, I didn't test that but I don't see why it wouldn't work.

On rviz: Makes sense. I'd add a log there so people knew what was going on during that period, but a good solution

- Lifecycle support for 'use_map_server' parameter
- updated to get namespace at initialization in map_server
Copy link
Contributor

@AntoBrandi AntoBrandi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of logging the status of the panel, anyway this commit won't fix the RViz crash. It is due to the get_parameters function being called with unexisting parameters

https://github.com/kei1107/slam_toolbox/blob/f8236475206fbf8eb3550d04c087ba6078133df0/rviz_plugin/slam_toolbox_rviz_plugin.cpp#L558

First it should be checked whether the parameters exists, and then call the get_parameters function.

@kei1107
Copy link
Contributor Author

kei1107 commented Dec 1, 2023

@AntoBrandi
I had completely missed the bug about the rviz_plugin. Thanks for the info!

This commit appears to fix the Rviz crash in my humble envirionment.
I checked SyncParametersClient::get_parameters and was able to set a timeout, so my code specifies a timeout of 1s. That way, when slam_toolbox is not activated, an empty vector is returned after 1s. ( See video get_parameters_with_timeout.mp4 )

get_parameters_with_timeout.mp4

I also checked the method you suggested (has_parameter).
Looking at the implementation of SyncParametersClient::has_parameter, SyncParametersClient::list_parameter is executed without timeout. This caused the has_parameter to wait forever without completing. (See video has_parameter_without_timeout )

This test diff
diff --git a/rviz_plugin/slam_toolbox_rviz_plugin.cpp b/rviz_plugin/slam_toolbox_rviz_plugin.cpp
index d04d0b3..ee7bc54 100644
--- a/rviz_plugin/slam_toolbox_rviz_plugin.cpp
+++ b/rviz_plugin/slam_toolbox_rviz_plugin.cpp
@@ -555,17 +555,14 @@ void SlamToolboxPlugin::updateCheckStateIfExternalChange()
     std::make_shared<rclcpp::SyncParametersClient>(node, "slam_toolbox");
 
   while (rclcpp::ok()) {
-    auto parameters = parameters_client->get_parameters(
-      {"paused_new_measurements", "interactive_mode"}, std::chrono::seconds(1));
-    if (parameters.empty()) {
-      RCLCPP_INFO_ONCE(
-        ros_node_->get_logger(),
-        "Waiting for the slam_toolbox node configuration.");
-    } else {
+    if(parameters_client->has_parameter("paused_new_measurements") &&
+       parameters_client->has_parameter("interactive_mode"))
+    {
       RCLCPP_INFO_ONCE(
         ros_node_->get_logger(),
         "Start the slam_toolbox node state check.");
-
+      auto parameters = parameters_client->get_parameters(
+        {"paused_new_measurements", "interactive_mode"});
       paused_measure = parameters[0].as_bool();
       interactive = parameters[1].as_bool();
 
@@ -576,7 +573,12 @@ void SlamToolboxPlugin::updateCheckStateIfExternalChange()
       oldState = _check2->blockSignals(true);
       _check2->setChecked(!paused_measure);
       _check2->blockSignals(oldState);
+    } else {
+      RCLCPP_INFO_ONCE(
+        ros_node_->get_logger(),
+        "Waiting for the slam_toolbox node configuration.");
     }
+
     r.sleep();
   }
 }
has_parameters_without_timeout.mp4

@kei1107
Copy link
Contributor Author

kei1107 commented Dec 2, 2023

On stack memory changes...
Even in the latest original ros2 branch, component nodes are not started with slam_toolbox_XXX_node.cpp, so not only stack memory changes but also configure and loadPoseGraphByParams are not executed. Therefore, slam_toolbox will not work.
This PR can handle stack memory change, but it might be better to fix it in another PR.

$ git log -n1
commit 03d1b49655875f861a9c914930ea23f5213c1864 (HEAD, upstream/ros2)
Author: Antonio Brandi <[email protected]>
Date:   Tue Nov 21 17:16:44 2023 +0100

    added support for ROS 2 Components (#652)
$ git remote show -n upstream | grep URL
  Fetch URL: https://github.com/SteveMacenski/slam_toolbox
  Push  URL: https://github.com/SteveMacenski/slam_toolbox
$ ros2 component standalone slam_toolbox slam_toolbox::SynchronousSlamToolbox 
[INFO] [1701489462.818720130] [standalone_container_ba793c8c6c7a]: Load Library: /home/ubuntu/dev_ws/install/slam_toolbox/lib/libsync_slam_toolbox.so
[INFO] [1701489462.831510908] [standalone_container_ba793c8c6c7a]: Found class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::SynchronousSlamToolbox>
[INFO] [1701489462.831530769] [standalone_container_ba793c8c6c7a]: Instantiate class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::SynchronousSlamToolbox>
$ ros2 node info /slam_toolbox 
/slam_toolbox
  Subscribers:
    /parameter_events: rcl_interfaces/msg/ParameterEvent
  Publishers:
    /parameter_events: rcl_interfaces/msg/ParameterEvent
    /rosout: rcl_interfaces/msg/Log
  Service Servers:
    /slam_toolbox/clear_queue: slam_toolbox/srv/ClearQueue
    /slam_toolbox/describe_parameters: rcl_interfaces/srv/DescribeParameters
    /slam_toolbox/get_parameter_types: rcl_interfaces/srv/GetParameterTypes
    /slam_toolbox/get_parameters: rcl_interfaces/srv/GetParameters
    /slam_toolbox/list_parameters: rcl_interfaces/srv/ListParameters
    /slam_toolbox/set_parameters: rcl_interfaces/srv/SetParameters
    /slam_toolbox/set_parameters_atomically: rcl_interfaces/srv/SetParametersAtomically
  Service Clients:

  Action Servers:

  Action Clients:

In lifecycle nodes, the stack memory changes will work if not via components.
( Node using stack size... log is output )

$ ros2 launch slam_toolbox online_sync_launch.py 
...
[sync_slam_toolbox_node-1] [INFO] [1701493561.608445099] [slam_toolbox]: Node using stack size 40000000
[sync_slam_toolbox_node-1] [INFO] [1701493561.839430087] [slam_toolbox]: Configuring
[sync_slam_toolbox_node-1] [INFO] [1701493561.853614399] [slam_toolbox]: Using solver plugin solver_plugins::CeresSolver
[sync_slam_toolbox_node-1] [INFO] [1701493561.853864764] [slam_toolbox]: CeresSolver: Using SCHUR_JACOBI preconditioner.
[INFO] [launch.user]: [LifecycleLaunch] Slamtoolbox node is activating.
[sync_slam_toolbox_node-1] [INFO] [1701493561.862764516] [slam_toolbox]: Activating
...

@SteveMacenski
Copy link
Owner

SteveMacenski commented Dec 6, 2023

It looks like you may have just done that anyway?

Its been a hot minute since I looked at this in detail and given several of you have commented that you've been using this, I'm more open this week / next to look at this is critical detail to get this merged in before the end of the year. A couple of pre-questions:

@kei1107 are you done with changes and/or is this ready for final review? Did you handle all of the component issues here as well fully (and tested working)? How did you test the stack expansion?

Sorry for the delay here, sometimes certain things slip through the cracks and this certainly was one of those things until now

@kei1107
Copy link
Contributor Author

kei1107 commented Dec 6, 2023

@SteveMacenski

The stack memory change was easy to handle, so it was handled at the same time the conflicts were fixed. 👍

commit: [27ace6d]

  • Update stack memory changes to be executed within the constructor of the SlamToolbox class.
    • stack_size_to_use parameter has been set to the READ ONLY parameter.
  • Test : I checked with the log ( Node using stack size...) in the following command. Additionally, I confirmed that mapping and localization can be done using turtlebot3_gazebo with slam_toolbox::SynchronousSlamToolbox.
  • Edit: Additional Test: I checked /proc/[pid]/limits.
$ ros2 component standalone slam_toolbox slam_toolbox::SynchronousSlamToolbox --parameter stack_size_to_use:=12345678
[INFO] [1701826099.450789437] [standalone_container_d4684c27f8dc]: Load Library: /home/ubuntu/dev_ws/install/slam_toolbox/lib/libsync_slam_toolbox.so
[INFO] [1701826099.460284390] [standalone_container_d4684c27f8dc]: Found class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::SynchronousSlamToolbox>
[INFO] [1701826099.460304346] [standalone_container_d4684c27f8dc]: Instantiate class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::SynchronousSlamToolbox>
[INFO] [1701826099.464084151] [slam_toolbox]: Node using stack size 12345678
^C[INFO] [1701826102.484434728] [rclcpp]: signal_handler(signum=2)
$ ros2 component standalone slam_toolbox slam_toolbox::AsynchronousSlamToolbox --parameter stack_size_to_use:=12345678
[INFO] [1701826108.762787636] [standalone_container_15cede2b20f1]: Load Library: /home/ubuntu/dev_ws/install/slam_toolbox/lib/libasync_slam_toolbox.so
[INFO] [1701826108.771860425] [standalone_container_15cede2b20f1]: Found class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::AsynchronousSlamToolbox>
[INFO] [1701826108.771882183] [standalone_container_15cede2b20f1]: Instantiate class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::AsynchronousSlamToolbox>
[INFO] [1701826108.776211866] [slam_toolbox]: Node using stack size 12345678
^C[INFO] [1701826109.720144695] [rclcpp]: signal_handler(signum=2)
$ ros2 component standalone slam_toolbox slam_toolbox::LocalizationSlamToolbox --parameter stack_size_to_use:=12345678
[INFO] [1701826126.962188975] [standalone_container_239ae5d6a0fb]: Load Library: /home/ubuntu/dev_ws/install/slam_toolbox/lib/liblocalization_slam_toolbox.so
[INFO] [1701826126.972350827] [standalone_container_239ae5d6a0fb]: Found class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::LocalizationSlamToolbox>
[INFO] [1701826126.972386504] [standalone_container_239ae5d6a0fb]: Instantiate class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::LocalizationSlamToolbox>
[INFO] [1701826126.976728370] [slam_toolbox]: Node using stack size 12345678
^C[INFO] [1701826128.333306099] [rclcpp]: signal_handler(signum=2)
$ ros2 component standalone slam_toolbox slam_toolbox::LifelongSlamToolbox --parameter stack_size_to_use:=12345678
[INFO] [1701826141.685357673] [standalone_container_1bacce7fafa6]: Load Library: /home/ubuntu/dev_ws/install/slam_toolbox/lib/liblifelong_slam_toolbox.so
[INFO] [1701826141.694593315] [standalone_container_1bacce7fafa6]: Found class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::LifelongSlamToolbox>
[INFO] [1701826141.694612232] [standalone_container_1bacce7fafa6]: Instantiate class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::LifelongSlamToolbox>
[INFO] [1701826141.699040444] [slam_toolbox]: Node using stack size 12345678
[WARN] [1701826141.699062907] [slam_toolbox]: Lifelong mapping mode in SLAM Toolbox is considered experimental and should be understood before proceeding. Please visit: https://github.com/SteveMacenski/slam_toolbox/wiki/Experimental-Lifelong-Mapping-Node for more information.
^C[INFO] [1701826143.986663969] [rclcpp]: signal_handler(signum=2)
$ ros2 component standalone slam_toolbox slam_toolbox::MapAndLocalizationSlamToolbox --parameter stack_size_to_use:=12345678
[INFO] [1701826161.831423628] [standalone_container_283a50e8a3cd]: Load Library: /home/ubuntu/dev_ws/install/slam_toolbox/lib/libmap_and_localization_slam_toolbox.so
[INFO] [1701826161.846489319] [standalone_container_283a50e8a3cd]: Found class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::LocalizationSlamToolbox>
[INFO] [1701826161.846515435] [standalone_container_283a50e8a3cd]: Found class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::MapAndLocalizationSlamToolbox>
[INFO] [1701826161.846520753] [standalone_container_283a50e8a3cd]: Instantiate class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::MapAndLocalizationSlamToolbox>
[INFO] [1701826161.850950065] [slam_toolbox]: Node using stack size 12345678
^C[INFO] [1701826164.780755563] [rclcpp]: signal_handler(signum=2)

Edit: Additional Test:

#terminal1
$ ros2 component standalone slam_toolbox slam_toolbox::SynchronousSlamToolbox --parameter stack_size_to_use:=12345678
[INFO] [1701861313.941864284] [standalone_container_0d29b2901c04]: Load Library: /home/ubuntu/dev_ws/install/slam_toolbox/lib/libsync_slam_toolbox.so
[INFO] [1701861313.951494930] [standalone_container_0d29b2901c04]: Found class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::SynchronousSlamToolbox>
[INFO] [1701861313.951518738] [standalone_container_0d29b2901c04]: Instantiate class: rclcpp_components::NodeFactoryTemplate<slam_toolbox::SynchronousSlamToolbox>
[INFO] [1701861313.954739030] [slam_toolbox]: Node using stack size 12345678

#terminal2 
$ ps -ef | grep component_container
ubuntu       969     968  0 11:15 pts/0    00:00:00 /opt/ros/humble/lib/rclcpp_components/component_container --ros-args -r __node:=standalone_container_0d29b2901c04
ubuntu      1001     726  0 11:15 pts/2    00:00:00 grep --color=auto component_container
$ cat /proc/969/limits 
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            12345678             unlimited            bytes     
Max core file size        unlimited            unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             unlimited            unlimited            processes 
Max open files            1048576              1048576              files     
Max locked memory         8388608              8388608              bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       62766                62766                signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us        

  • On the bond bits
    • Not supported yet. Just adding createBond and deleteBond is possible right away. I should be able to update and test (with nav2_lifecycle_manager) within a few days, should I add them?

There is no other work remaining.

@AntoBrandi
Copy link
Contributor

After testing it I can confirm that the latest changes did the trick! Good job 👍

@kei1107
Copy link
Contributor Author

kei1107 commented Dec 8, 2023

@SteveMacenski

All changes have been completed.

Diffs : [319607f...21e9e6b]


Bond bits

Added use_lifecycle_manager node parameter and launch parameter.
When the launch parameter of use_lifecycle_manager is true, the event handlers for lifecycle transition in launch are disabled. Also, the parameter is passed in slam_toolbox to create the bond connection on activation.

$ ros2 launch slam_toolbox online_sync_launch.py -s
Arguments (pass arguments as '<name>:=<value>'):

    'autostart':
        Automatically startup the slamtoolbox. Ignored when use_lifecycle_manager is true.
        (default: 'true')

    'use_lifecycle_manager':
        Enable bond connection duaring node activation
        (default: 'false')

    'use_sim_time':
        Use simulation/Gazebo clock
        (default: 'true')

    'slam_params_file':
        Full path to the ROS2 parameters file to use for the slam_toolbox node
        (default: '/home/ubuntu/dev_ws/install/slam_toolbox/share/slam_toolbox/config/mapper_params_online_sync.yaml')

Test

#Enable bond connection, Disable the event handlers of lifecycle transition.
$ ros2 launch slam_toolbox online_sync_launch.py use_lifecycle_manager:=true
#Start lifecycle manager
$ ros2 run nav2_lifecycle_manager lifecycle_manager --ros-args -p node_names:=["slam_toolbox"] -p autostart:=true

#Startup
$ ros2 service call /lifecycle_manager/manage_nodes nav2_msgs/srv/ManageLifecycleNodes "command: 0"
#Reset
$ ros2 service call /lifecycle_manager/manage_nodes nav2_msgs/srv/ManageLifecycleNodes "command: 3"
use_lifecycle_manager.mp4

@SteveMacenski
Copy link
Owner

OK great. I will try very hard to get this a review next week, but it might happen over the holidays. I'm going to commit to getting this in before EOY

Copy link
Owner

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, there are some utils in Nav2 that could have made this more ergonomic, but I don't see an issue as written. Has this been tested with Nav2's default bringup with slam:=True to trigger this launch file (and work fine)?

If so, I'd be ready to merge shortly

rviz_plugin/slam_toolbox_rviz_plugin.cpp Outdated Show resolved Hide resolved
launch/lifelong_launch.py Outdated Show resolved Hide resolved
launch/lifelong_launch.py Outdated Show resolved Hide resolved
@kei1107
Copy link
Contributor Author

kei1107 commented Jan 4, 2024

@SteveMacenski
Thanks for your review! 😄

Has this been tested with Nav2's default bringup with slam:=True to trigger this launch file (and work fine)?

I just tested it and confirmed it works fine. 👍 ( I had to pass map parameter )

$ ros2 launch nav2_bringup bringup_launch.py slam:=True use_sim_time:=True map:=dummy.yaml
log : no map parameter
$ ros2 launch nav2_bringup bringup_launch.py slam:=True use_sim_time:=True 
[INFO] [launch]: All log files can be found below /home/ubuntu/.ros/log/2024-01-04-02-57-55-395185-c6ea82625ecd-10363
[INFO] [launch]: Default logging verbosity is set to INFO
[ERROR] [launch]: Caught exception in launch (see debug for traceback): Included launch description missing required argument 'map' (description: 'Full path to map yaml file to load'), given: [slam, use_sim_time]

※ 2x speed

slam_toolbox_via_nav2_bringup.mp4

Copy link
Owner

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved -- anything else we should consider before merging?

@kei1107
Copy link
Contributor Author

kei1107 commented Jan 4, 2024

Thanks. As far as I know, everything else is fine.

@SteveMacenski SteveMacenski merged commit de13553 into SteveMacenski:ros2 Jan 4, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants