-
Notifications
You must be signed in to change notification settings - Fork 331
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 launch files to new style #262
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just convention, but please put .launch.py
at the end of the file names (so rename them). Otherwise the ros2 launch
command will not tab complete them. This is done to differentiate them from normal python scripts.
launch.actions.ExecuteProcess( | ||
cmd=[ | ||
ExecutableInPackage(package='robot_state_publisher', executable_name='robot_state_publisher'), | ||
os.path.join( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put a TODO comment here to use a substitution to find this file rather than using ament_index_python
directly. I haven't implemented the substitution yet, but it is planned.
def generate_launch_description(): | ||
return LaunchDescription([ | ||
launch.actions.ExecuteProcess( | ||
cmd=[ExecutableInPackage(package='dummy_map_server', executable_name='dummy_map_server')], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are ROS nodes (I think they are) then you should use launch_ros.actions.Node
instead.
def generate_launch_description(): | ||
return LaunchDescription([ | ||
launch.actions.ExecuteProcess( | ||
cmd=[ExecutableInPackage(package='lifecycle', executable='lifecycle_talker')], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can/should use the launch_ros.actions.LifecycleNode
action for the lifecycle_talker
and lifecycle_listener
instead and the launch_ros.actions.Node
for the lifecycle_service_client
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can launch_ros.actions.LifecycleNode
be used on regular rclcpp Nodes ?
If it doesn't make sense to do so, we should likely not use it for the listener as it is a "regular node" AFAICT:
class LifecycleListener : public rclcpp::Node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is not an actual lifecycle node then it will work, but it will have unnecessary overhead and if someone attempts to make launch change its state that will fail).
So I'd say you're right we should use Node
on the confusingly name :p lifecycle_listener
.
60f2f80
to
deef9fc
Compare
Addressed comments (that's a lot cleaner!). Feel free to wait until after bouncy release as this is low priority |
# limitations under the License. | ||
|
||
from launch import LaunchDescription | ||
from launch_ros.actions import Node, LifecycleNode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I don't know if these files are linted automatically but we usually import in alphabetical order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And one import per line. So this should be split into two lines.
in dummy_robot_bringup and lifecycle
deef9fc
to
adcf3a7
Compare
Once this is merged, the dummy-robot-demo wiki page will need to be updated to refer to the new filename. The lifecycle launch is not currently referenced in the lifecycle wiki page, but probably should be. |
Let's merge this and @ironmig can you deploy the wiki changes and then link them here? I'll test them on linux, macOS, and Windows (at least from source and x86). |
I think there was a reason for not mentioning the launchfiles in the wiki page. I think they were even considered for removal after the ardent release. |
I checked out the wiki changes, and they work on my machine(s), thanks! |
Follow-up PR at #277 |
What about the https://github.com/ros2/launch/blob/master/launch_ros/examples/lifecycle_pub_sub_launch.py I noticed that it is written in old style, but the wiki cites it as a valid example: I'm trying to understand how to modify it, but without success |
Would you be able to rephrase your question? I'm not sure that I've understood it. The launch file you referenced is using the new-style launch, not the legacy launch. |
If I try to adapt it to my lifecycle node I get an error about |
it's likely you're using an older version of launch (Ardent, perhaps) that doesn't include the new-style launch (it was released in Bouncy). If that's not the case, please ask a question on answers.ros.org and we can troubleshoot there rather than on this PR |
I'm using the launch file available in the master branch and it is exactly the same as the file that I linked here |
@Myzhar please ask your question on ROS answers using the "ros2" tag and providing a description containing:
Commenting on a closed PR with little context makes it hard for the community to see your question and help you solve your issue. Thanks! |
in dummy_robot_bringup and lifecycle (addreses #249)