Skip to content

Make lifecycle demo automatically exit when done#558

Merged
sloretz merged 1 commit intomasterfrom
sloretz__lifecycle__exit_demo_when_done
Apr 8, 2022
Merged

Make lifecycle demo automatically exit when done#558
sloretz merged 1 commit intomasterfrom
sloretz__lifecycle__exit_demo_when_done

Conversation

@sloretz
Copy link
Copy Markdown
Contributor

@sloretz sloretz commented Apr 7, 2022

Fixes #504

This makes the lifecyle demo automatically exit when it's completed. First this PR fixes a bug in lifecycle_service_client where it's stuck waiting for the future to complete forever because of ros2/rclcpp#1916. Next this PR adds a Shutdown action to the on_exit argument of the lifecycle_service_client Node so that when it shuts down the other nodes are killed too.

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@sloretz sloretz requested a review from mjeronimo April 7, 2022 22:15
@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Apr 7, 2022

CI (build: --packages-up-to lifecycle test: --packages-select lifecycle)

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@sloretz sloretz merged commit 0cf803e into master Apr 8, 2022
@delete-merged-branch delete-merged-branch bot deleted the sloretz__lifecycle__exit_demo_when_done branch April 8, 2022 16:01
std::bind(callee_script, lc_client));
auto wake_exec = std::async(
std::launch::async,
std::bind(wake_executor, script, std::ref(exe)));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would say this is unnecessarily complicated. I would instead move the callee_script into a one-off timer with zero duration.

Or better yet, run the executor's spin in a separate thread (use std::async if you like) and do the callee_script here in the main thread, then when that function is done cancel the executor and "join" the thread it was using to spin in.

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.

[lifecycle demo] Launch script doesn't exit

3 participants