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

Launch file migration guide #302

Merged
merged 15 commits into from
Aug 27, 2019
Merged

Launch file migration guide #302

merged 15 commits into from
Aug 27, 2019

Conversation

ivanpauno
Copy link
Member

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:

  • Add examples of each tag.
  • Add a toy example.
  • Add a cheatsheet.
  • Reference ROS 2's XML launch format design document (when it gets merged).

@ivanpauno ivanpauno added enhancement New feature or request in progress labels Jul 23, 2019
@ivanpauno ivanpauno self-assigned this Jul 23, 2019
Signed-off-by: ivanpauno <[email protected]>
Signed-off-by: ivanpauno <[email protected]>
Copy link
Member Author

@ivanpauno ivanpauno left a 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``.
Copy link
Member Author

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 are name, executable and ns.

I think it's fine to change package to pkg too.

Copy link
Member

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``.
Copy link
Member Author

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.

Copy link
Member

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.

source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
^^^^^

In ROS 2, there's no global parameters concept.
Application using global parameters should be refactored.
Copy link
Member Author

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).

Copy link
Member

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.

source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
* 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.
Copy link
Member Author

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.

Copy link
Member

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)?

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* ``anon`` hasn't an alternative at the moment.
* ``anon`` has no alternative at the moment.

Copy link
Member Author

Choose a reason for hiding this comment

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

source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
Type inference rules
--------------------

The rules that were shown in ``Type inference rules`` subsection of ``param`` tag applies to any attribute.
Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Contributor

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
Copy link
Contributor

@maryaB-osr maryaB-osr Jul 24, 2019

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.
Copy link
Contributor

@maryaB-osr maryaB-osr Jul 24, 2019

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
^^^^^^^^
Copy link
Contributor

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``.
Copy link
Member

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``.
Copy link
Member

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.

source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
^^^^^

In ROS 2, there's no global parameters concept.
Application using global parameters should be refactored.
Copy link
Member

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.
Copy link
Member

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.

source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
* 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.
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* ``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.
Copy link
Member

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'"/>
Copy link
Member

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]>
@ivanpauno
Copy link
Member Author

@wjwwood @maryaB-osr I think I've addressed all your comments.

@ivanpauno
Copy link
Member Author

@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 launch and launch_ros repos, describing possible future improvements (and I will probably open a couple more).

If you think something else have to be addressed now, please let me know.

@ivanpauno
Copy link
Member Author

@wjwwood @maryaB-osr I think I've addressed all your comments.

I missed your last review @maryaB-osr, I will address those comments too.

@maryaB-osr
Copy link
Contributor

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!

@maryaB-osr maryaB-osr closed this Jul 26, 2019
@ivanpauno ivanpauno reopened this Jul 26, 2019
@ivanpauno ivanpauno requested a review from wjwwood July 30, 2019 13:59
Copy link
Contributor

@hidmic hidmic left a 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.
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

@ivanpauno consider:

Suggested change
In ROS 2, param tags are allowed to be nested.
In ROS 2, `<param/>` tags are allowed to be nested.

instead.

Copy link
Member Author

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.

source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
let
^^^

It's a replacement of ``arg`` tag with a value attribute.
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

@hidmic hidmic left a 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.

source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
let
^^^

It's a replacement of ``arg`` tag with a value attribute.
Copy link
Contributor

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.

source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
source/Tutorials/Launch-files-migration-guide.rst Outdated Show resolved Hide resolved
* The following attributes aren't available: ``machine``, ``respawn``, ``respawn_delay``, ``clear_params``.

Example
~~~~~~~
Copy link
Contributor

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?

Copy link
Contributor

@hidmic hidmic left a 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

@ivanpauno
Copy link
Member Author

ivanpauno commented Aug 27, 2019

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 tried some other ways of organizing the sections, but I didn't like them much.

I will merge this as-is. If it looks confusing in index.ros.org, we can improve header style in a follow-up PR.

@ivanpauno ivanpauno merged commit b5e3177 into master Aug 27, 2019
@delete-merged-branch delete-merged-branch bot deleted the ivanpauno/roslaunch-migration branch August 27, 2019 12:37
prajakta-gokhale pushed a commit to aws-ros-dev/ros2_documentation that referenced this pull request Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request in review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants