-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Launch file migration guide #302
Conversation
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
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'm doing an auto-review, adding comments about things we may want to change and adding links to previous discussions.
As in `ROS1 <http://wiki.ros.org/roslaunch/XML/node>`__, it allows launching a new node. | ||
The following summarize the differences: | ||
|
||
* ``pkg`` attribute is now ``package``. |
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 tried using the same names as in the constructor:
https://github.com/ros2/launch_ros/blob/68337f836b9dfbf4bed2b9c3b3ae03d21570cf13/launch_ros/launch_ros/actions/node.py#L54-L67
I actually sometimes break that rule, when it was to verbose. For example:
node_name
,node_executable
,node_namespace
arename
,executable
andns
.
I think it's fine to change package
to pkg
too.
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.
Fine by me as well.
The following summarize the differences: | ||
|
||
* ``pkg`` attribute is now ``package``. | ||
* ``type`` attribute is now ``executable``. |
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.
In this case, I prefer not to change executable
. But I don't mind if we want to change to type
.
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 always thought type
was confusing, I think executable
makes more sense. Unless someone can explain why it is that way.
^^^^^ | ||
|
||
In ROS 2, there's no global parameters concept. | ||
Application using global parameters should be refactored. |
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 we should create a tutorial for that (sth like, Idioms for replacing global parameters
).
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.
Yeah, in general we've moved away from that, but we could still have a facility like this, using something like this node: https://github.com/ros2/demos/blob/f78dcc981cc783aad162e2a8530a7aa23c4fda21/demo_nodes_cpp/src/parameters/parameter_blackboard.cpp#L21
I think a tutorial for this would be good. But it's fine to just say here we don't have that so these tags don't necessarily make sense any longer.
* There is a new ``exec-in-package`` substitution. | ||
e.g.: ``$(exec-in-package <package_name> <exec_name>)`` | ||
* There is a new ``find-exec`` substitution. | ||
* ``anon`` hasn't an alternative at the moment. |
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.
There is not implementation in launch
.
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 create an issue to add that to launch (no need to be ROS specific I think)?
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.
* ``anon`` hasn't an alternative at the moment. | |
* ``anon`` has no alternative at the moment. |
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.
Type inference rules | ||
-------------------- | ||
|
||
The rules that were shown in ``Type inference rules`` subsection of ``param`` tag applies to any attribute. |
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.
We have some inconsistencies on how we are coercing types in different places of launch.
For example, Node
action use yaml for converting parameter, xml launch frontend has its own rules, and other actions do other things (e.g.:
https://github.com/ros2/launch/blob/15af530bd2a1d207849659615fbbdbb5a4daf4a5/launch/launch/actions/timer_action.py#L69-L72, and we're actually losing precision).
One problem of this, is that setting a parameter from a substitution looks different at setting it directly (see https://github.com/ros2/launch_ros/blob/68337f836b9dfbf4bed2b9c3b3ae03d21570cf13/test_launch_ros/test/test_launch_ros/frontend/test_node_frontend.py#L29-L53).
I was thinking in adding support of typed substitutions (they aren't performed always to str
). The benefits would be:
- Standardize code handling substitutions that are coerced to another type (bool, float, etc).
- In the cases were more than a type is possible (e.g.: parameters), if the user want to pass a parameter that is known to be an integer and the substitution is later coerced to a string, we could raise a substitution failure. Now, this is not possible. In that case, we will set a parameter of the wrong type, and the node that uses it may handle it correctly or not.
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 would need more convincing that typed substitutions make sense. We'd need special logic to then convert those typed substitutions to strings in many cases, which is basically what we're doing now.
I don't understand what it buys us, maybe you could give a concrete example where it would be better.
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'm not a big fan of typed substitutions either, but I do strongly believe we have to standardize type inference rules everywhere -- even during substitution.
@@ -0,0 +1,287 @@ | |||
Migrating ROS 1 launchfiles |
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.
"Migrating ROS 1 launch files to ROS 2"
Possibly add to the title for better description (it's obvious to someone already on the ROS 2 docs site that we're talking about ROS 2, but it might benefit searches from external search engines)
I think launch files is two words? I can't find anywhere in existing docs where it's combined
---------- | ||
|
||
A description of the ROS 2 launch system and its Python API can be found in `this tutorial<Launch-system>`. | ||
In this tutorial, will be described how to write XML launch files, which allow an easy migration from ROS 1. |
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.
There's variation among the existing tutorials, but I think only the first sentence here constitutes a "background". The second sentence is more of a summary/overview. I would rearrange (and rewrite for wordiness) like this (following the table of contents):
"This tutorial describes how to write XML launch files for an easy migration from ROS 1.
Background
A description of the ROS 2 launch system and its Python API can be found in this tutorial<Launch-system>
."
They aren't supported at the moment. | ||
|
||
New tags | ||
^^^^^^^^ |
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.
"New tags in ROS 2
-------------------------"
This should be at the same level as "Migrating tags from ROS 1 to ROS 2", because it's two different topics: old tags and new tags. Then every subtopic should be moved up a level
As in `ROS1 <http://wiki.ros.org/roslaunch/XML/node>`__, it allows launching a new node. | ||
The following summarize the differences: | ||
|
||
* ``pkg`` attribute is now ``package``. |
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.
Fine by me as well.
The following summarize the differences: | ||
|
||
* ``pkg`` attribute is now ``package``. | ||
* ``type`` attribute is now ``executable``. |
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 always thought type
was confusing, I think executable
makes more sense. Unless someone can explain why it is that way.
^^^^^ | ||
|
||
In ROS 2, there's no global parameters concept. | ||
Application using global parameters should be refactored. |
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.
Yeah, in general we've moved away from that, but we could still have a facility like this, using something like this node: https://github.com/ros2/demos/blob/f78dcc981cc783aad162e2a8530a7aa23c4fda21/demo_nodes_cpp/src/parameters/parameter_blackboard.cpp#L21
I think a tutorial for this would be good. But it's fine to just say here we don't have that so these tags don't necessarily make sense any longer.
This tag can only be used nested in a node tag. | ||
`ROS 1 reference <http://wiki.ros.org/roslaunch/XML/param>`__. | ||
|
||
* There is not ``type`` attribute. See type deduction rules below. |
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.
This might be a good feature to have in the future, since you might want to catch issues early by having launch evaluate the output of a command or something and assert it's an int or a float or something. It's usefulness is limited, however, as it doesn't scale to sets of parameters (e.g. yaml dictionary) very easily.
* There is a new ``exec-in-package`` substitution. | ||
e.g.: ``$(exec-in-package <package_name> <exec_name>)`` | ||
* There is a new ``find-exec`` substitution. | ||
* ``anon`` hasn't an alternative at the moment. |
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 create an issue to add that to launch (no need to be ROS specific I think)?
* There is a new ``exec-in-package`` substitution. | ||
e.g.: ``$(exec-in-package <package_name> <exec_name>)`` | ||
* There is a new ``find-exec`` substitution. | ||
* ``anon`` hasn't an alternative at the moment. |
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.
* ``anon`` hasn't an alternative at the moment. | |
* ``anon`` has no alternative at the moment. |
Type inference rules | ||
-------------------- | ||
|
||
The rules that were shown in ``Type inference rules`` subsection of ``param`` tag applies to any attribute. |
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 would need more convincing that typed substitutions make sense. We'd need special logic to then convert those typed substitutions to strings in many cases, which is basically what we're doing now.
I don't understand what it buys us, maybe you could give a concrete example where it would be better.
.. code-block:: xml | ||
|
||
<!--Setting a string value to an attribute expecting an int will raise an error.--> | ||
<tag1 int-attr="'1'"/> |
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 understand these examples, but I think it's confusing when first reading it. When you're using pseudo syntax, better to make it painfully obvious. Like consider using <made_up_tag1 attr-expecting-an-int="'1'">
.
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
@wjwwood @maryaB-osr I think I've addressed all your comments. |
@wjwwood @hidmic This PR, together with ros2/launch#291, ros2/launch#288, ros2/launch_ros#47, ros2/launch_ros#40, ros2/design#247, are the last changes that I'm planning to do related with XML launch files. I also opened a bunch issues in If you think something else have to be addressed now, please let me know. |
I missed your last review @maryaB-osr, I will address those comments too. |
Just a final proofread. I didn't realize you'd missed it either! |
Signed-off-by: ivanpauno <[email protected]>
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.
First pass. Punctuation use is inconsistent. Also, header layout does not follow a common pattern.
|
||
* `In ROS1 <http://wiki.ros.org/roslaunch/XML/param>`__ | ||
* Used for passing a parameter to a node | ||
* There's no global parameter concept in ROS 2. |
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.
@ivanpauno nit: for some sentences with have trailing periods, for some not. Should we standardize it? @maryaB-osr for feedback.
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 that the idea is that list items shouldn't end with a period, but I'm not sure.
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.
"Used for passing..." is not a complete sentence, so it shouldn't end with a period.
"There's no global..." is a complete sentence, so it should end with a period. Also it has a sentence following it, so they need to be separated.
I agree it looks odd though, having both in one list.
For now you can pick one standard, but make sure all the bullets follow the rule. So either:
- all ending with a period
- none ending with a period
- only complete sentences ending with a period (incomplete sentences are the ones starting with verbs like used, allows, etc.)
The first two will look the best, the last is technically grammatically correct
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 agree, added period in all the sentences.
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.
Thanks for the thorough explanation @maryaB-osr !
Parameter grouping | ||
~~~~~~~~~~~~~~~~~~ | ||
|
||
In ROS 2, param tags are allowed to be nested. |
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.
@ivanpauno consider:
In ROS 2, param tags are allowed to be nested. | |
In ROS 2, `<param/>` tags are allowed to be nested. |
instead.
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 prefer ``param``
than ``<param/>``
, but I can change the style if you think the second option is better.
let | ||
^^^ | ||
|
||
It's a replacement of ``arg`` tag with a value attribute. |
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.
@ivanpauno is it just that?
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.
Yes, I think it's exactly the same.
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.
Hmm it doesn't seem like it. In roslaunch
, <arg/>
was used to declare an argument or to set it upon an <include/>
. Here, <let/>
allows setting launch configurations which are superset of launch arguments. So, though it can be used to set launch arguments, that's not the only thing it is capable of.
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.
From http://wiki.ros.org/roslaunch/XML/arg.
<arg name="foo" value="bar" />
Declares foo with constant value. The value for foo cannot be overridden. This usage enables internal parameterization of a launch file without exposing that parameterization at higher levels.
The other two cases:
<arg name="foo" />
<arg name="foo" default="1" />
look exactly the same in ROS 1 and ROS 2.
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
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.
Final pass. Also, most tags have a bullet that says In ROS1
. When rendered, that's all you're going to see. I'd rather change it to something like Available in ROS1
, or anything else along those lines.
let | ||
^^^ | ||
|
||
It's a replacement of ``arg`` tag with a value attribute. |
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.
Hmm it doesn't seem like it. In roslaunch
, <arg/>
was used to declare an argument or to set it upon an <include/>
. Here, <let/>
allows setting launch configurations which are superset of launch arguments. So, though it can be used to set launch arguments, that's not the only thing it is capable of.
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
* The following attributes aren't available: ``machine``, ``respawn``, ``respawn_delay``, ``clear_params``. | ||
|
||
Example | ||
~~~~~~~ |
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.
@ivanpauno nit: when rendered, it's not obvious which headers belong to what section/subsection. Maybe lowering the header level?
Signed-off-by: ivanpauno <[email protected]>
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.
LGTM, but the comment about header levels still applies. Let's see how it renders at index.ros.org
https://index.ros.org/doc/ros2/Tutorials/Intra-Process-Communication/ use the same header levels. I will merge this as-is. If it looks confusing in |
Signed-off-by: ivanpauno <[email protected]>
Migration guide from ROS 1's roslaunch XML files to ROS 2's XML launch files.
This is a starting point, in order to discuss possible changes in the ROS 2's XML launch file format.
TODOs: