-
Notifications
You must be signed in to change notification settings - Fork 91
Autostarting lifecycle nodes and example launch file demo #430
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
277d95c
autostarting lifecycle nodes and example
SteveMacenski e49ed4c
fix linting
SteveMacenski c41cdcc
fix linting
SteveMacenski cc3449e
removing an unused variable
SteveMacenski e60458a
initializing a member client as none like sub
SteveMacenski cfc9b53
completing auto-start feature for composition nodes
SteveMacenski fa0e741
linting
SteveMacenski f836f4b
final linting fix
SteveMacenski 5d97fd8
Resolving issue with StateTransition messages
SteveMacenski 5e6bdb9
removing Node's autostart
SteveMacenski 92997ae
Fixing lifecyclenode type
SteveMacenski 656b96e
update docstring
SteveMacenski 2daab8d
adding in composable lifecycle node
SteveMacenski ed8a18f
Adding docstring
SteveMacenski 281035a
require autostart non-None
SteveMacenski a487b95
remove unused imports
SteveMacenski 0f7b4a1
review comments continued
SteveMacenski 04914a4
is lifecycle node and autostart to lifecycle-only classes
SteveMacenski d125a69
final bits
SteveMacenski 7b4fd4a
whoops, remove the Avatar-inspired printout
SteveMacenski e03c8b2
finish linting
SteveMacenski 06006f1
review fix
SteveMacenski 3b672f5
remove old import
SteveMacenski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Copyright 2024 Open Navigation LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Launch a lifecycle talker and a lifecycle listener.""" | ||
|
|
||
| import os | ||
| import sys | ||
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) # noqa | ||
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', 'launch')) # noqa | ||
|
|
||
| import launch # noqa: E402 | ||
| import launch.actions # noqa: E402 | ||
| import launch.events # noqa: E402 | ||
|
|
||
| import launch_ros.actions # noqa: E402 | ||
| import launch_ros.events # noqa: E402 | ||
| import launch_ros.events.lifecycle # noqa: E402 | ||
|
|
||
|
|
||
| def main(argv=sys.argv[1:]): | ||
| ld = launch.LaunchDescription() | ||
| talker_node = launch_ros.actions.LifecycleNode( | ||
| name='talker', | ||
| namespace='', | ||
| package='lifecycle', | ||
| executable='lifecycle_talker', | ||
| output='screen', | ||
| autostart=True) | ||
| listener_node = launch_ros.actions.LifecycleNode( | ||
| name='listener', | ||
| namespace='', | ||
| package='lifecycle', | ||
| executable='lifecycle_listener', | ||
| output='screen', | ||
| autostart=True) | ||
| ld.add_action(talker_node) | ||
| ld.add_action(listener_node) | ||
| ls = launch.LaunchService(argv=argv) | ||
| ls.include_launch_description(ld) | ||
| return ls.run() | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() |
63 changes: 63 additions & 0 deletions
63
launch_ros/examples/lifecycle_component_autostart_pub_sub_launch.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # Copyright 2024 Open Navigation LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Launch a lifecycle talker and a lifecycle listener.""" | ||
|
|
||
| import sys | ||
|
|
||
| import launch # noqa: E402 | ||
|
|
||
| from launch_ros.actions import ComposableNodeContainer, LoadComposableNodes | ||
| from launch_ros.descriptions import ComposableLifecycleNode | ||
|
|
||
|
|
||
| def main(argv=sys.argv[1:]): | ||
| ld = launch.LaunchDescription() | ||
|
|
||
| # Can autostart from the container | ||
| container = ComposableNodeContainer( | ||
| name='lifecycle_component_container', | ||
| namespace='', | ||
| package='rclcpp_components', | ||
| executable='component_container', | ||
| composable_node_descriptions=[ | ||
| ComposableLifecycleNode( | ||
| package='composition', | ||
| plugin='composition::Listener', | ||
| name='listener', | ||
| autostart=True), | ||
| ] | ||
| ) | ||
|
|
||
| # ... and also from an external loader | ||
| loader = LoadComposableNodes( | ||
| target_container='lifecycle_component_container', | ||
| composable_node_descriptions=[ | ||
| ComposableLifecycleNode( | ||
| package='composition', | ||
| plugin='composition::Talker', | ||
| name='talker', | ||
| autostart=True), | ||
| ], | ||
| ) | ||
|
|
||
| ld.add_action(container) | ||
| ld.add_action(loader) | ||
| ls = launch.LaunchService(argv=argv) | ||
| ls.include_launch_description(ld) | ||
| return ls.run() | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.