Skip to content

Ros2 port#211

Closed
gonzodepedro wants to merge 18 commits intodashing-develfrom
ros2-port
Closed

Ros2 port#211
gonzodepedro wants to merge 18 commits intodashing-develfrom
ros2-port

Conversation

@gonzodepedro
Copy link
Copy Markdown
Contributor

This PR brings together changes made by @vandanamandlik and @jacobperron.

vandanamandlik and others added 12 commits September 17, 2019 13:51
- Moved contents from "src/xacro/" folder to "xacro/" folder.
- Renamed scripts folder to resource folder.
- Modifed package.xml and setup.py according to ROS2 rules.
- Deleted CMakeLists.txt
- Modified all python scripts as per ros2 coding guidelines.
- Added substitution_args.py file, replacement for roslaunch's resolve_args() method,
  as it is not available in ROS2's ros2launch package.
  - Updated shebang line in all python scripts to use python3.
  - Resolved errors where some test cases were failing to find out some .xml files. (eg. include1.xml)
  - Added temporary workaround for rosgraph.names.load_mappings because rosgraph is not migrated to ROS2.
- Added some more details in README.md file.
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Gonzalo de Pedro <gonzalo@depedro.com.ar>
This was referenced Sep 17, 2019
@jacobperron jacobperron self-requested a review September 17, 2019 18:02
@gonzodepedro gonzodepedro self-assigned this Sep 17, 2019
@ros ros deleted a comment from gonzodepedro Sep 18, 2019
Copy link
Copy Markdown

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

I've got a lot of things to fix in here. They fall into a few main categories:

  1. Switch the license back to BSD everywhere
  2. Be very careful about changing " -> '; it matters in some places
  3. Get the dependencies correct
  4. Miscellaneous fixes

I may have more on a subsequent review, but these are the major things I saw to start with.

.travis.yml Outdated
python:
- "2.7"
- "3.5"
# - "3.5"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We've been generally trying to keep Python 3.5 support for older Debian. So I'd suggest re-enabling this.

.travis.yml Outdated
# - sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt/sources.list.d/ros-latest.list'
# - wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
# - sudo apt-get update
# - sudo apt-get install ros-indigo-catkin ros-indigo-roslaunch ros-indigo-rostest ros-indigo-roslint
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just kill off all of the commented lines above this.

.travis.yml Outdated
- sudo apt update && sudo apt install curl
- curl http://repo.ros2.org/repos.key | sudo apt-key add -
- sudo sh -c 'echo "deb [arch=amd64,arm64] http://repo.ros2.org/ubuntu/main `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
- export ROS_DISTRO=ardent # or ardent
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Definitely switch this to Dashing.

.travis.yml Outdated
- sudo -H python3 -m pip install -U setuptools

before_script:
# before_script:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You'll probably want to reenable the flake8 tests.

.travis.yml Outdated
# - make
# - make run_tests
# - catkin_test_results --all ./
# - sudo make install
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Kill off all of this commented-out code.

@@ -1,38 +1,29 @@
#!/usr/bin/env python3

# Copyright 2018 Open Source Robotics Foundation, Inc.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

BSD license.


for a_name in a_names:
writer.write(" %s=\"" % a_name)
writer.write(' %s=\"' % a_name)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We have to be careful here. I believe that we should get rid of the escape slash here.

writer.write(' %s=\"' % a_name)
xml.dom.minidom._write_data(writer, attrs[a_name].value)
writer.write("\"")
writer.write('\"')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think we need to get rid of the escape slash here as well.

@@ -0,0 +1,576 @@
#!/usr/bin/env python3

# Copyright 2018 Open Source Robotics Foundation, Inc.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

BSD license.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This comment is still open.



try:
from cStringIO import StringIO # Python 2.x
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove Python 2 compatibility.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This comment is still open.

setup.py Outdated
@@ -1,13 +1,37 @@
#!/usr/bin/env python
#!/usr/bin/env python3
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm not sure this #! line is needed, since it gets registered as a console script.

Signed-off-by: Gonzalo de Pedro <gonzalo@depedro.com.ar>
.travis.yml Outdated
- sudo -H python3 -m pip install -U setuptools

before_script:
before_script:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this should be indented.

README.md Outdated
@@ -0,0 +1,43 @@
This file describes the work done and steps to perform test on the xacro package.

"https://github.com/vandanamandlik/xacro/tree/ros2"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree with @clalancette's comment above regarding refactoring the README.md.
In any case, we shouldn't be pointing to a fork of this repo.

setup.py Outdated
keywords=['ROS'],
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
'License :: OSI Approved :: Apache Software License',
'License :: OSI Approved :: BSD License',

xacro/cli.py Outdated
@@ -0,0 +1,180 @@
#!/usr/bin/env python3
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think the shebang line is necessary since this isn't intended to be executed as a script.

xacro/color.py Outdated
@@ -1,4 +1,5 @@
#! /usr/bin/env python
#!/usr/bin/env python3
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Similar to my comment above, I think this line can be removed.

if s == '$(cwd)':
# TODO This is Temporary fix to return cwd() for 'find xacro' command.
# We can use resolve_args() when rospkg will be migrated to ROS2.
if s == '$(cwd)' or s == '$(find xacro)':
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess this temporary fix isn't necessary since we're using ament to find packages now in substitution_args.py.

from rospkg.common import ResourceNotFound
return substitution_args.resolve_args(s, context=substitution_args_context, resolve_anon=False)
# TODO use following when roslaunch will be fully migrated to ROS2.
# from roslaunch import substitution_args
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure what's needed exactly to resolve this TODO, but I don't think depending on launch is an appropriate solution. It looks like substitution_args from roslaunch is already replicated in xacro, so maybe we can remove this TODO.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree


import yaml

from ament_index_python.packages import get_package_prefix
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Following a discussion on a separate thread (kazuki0824#1 (comment)), I think it's better to default to using get_package_share_directory().

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agreed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree. It is in PR #212

Copy link
Copy Markdown

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

This round of review still has a lot of comments (some still remaining from last time), but this is looking a lot better.

README.md Outdated
@@ -0,0 +1,43 @@
This file describes the work done and steps to perform test on the xacro package.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This comment is still open.


import yaml

from ament_index_python.packages import get_package_prefix
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agreed.



try:
from cStringIO import StringIO # Python 2.x
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This comment is still open.



def _eval_optenv(name, default=''):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This should probably get a pydoc comment.



def _eval_dirname(filename):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This could use a pydoc comment.



def convert_value(value, type_):
"""
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The indentation on this method is weird compared to the other ones in this file (and in this whole codebase). Fix this to be 4 spaces like the rest.

Signed-off-by: Gonzalo de Pedro <gonzalo@depedro.com.ar>
Copy link
Copy Markdown

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

There are still quite a few comments left-over from my last review. Please go through all of the open comments and address them.

resource/xacro Outdated
@@ -1,4 +1,4 @@
#! /usr/bin/env python

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit: remove empty line at the top.

@rhaschke rhaschke mentioned this pull request Sep 25, 2019
@rhaschke
Copy link
Copy Markdown
Contributor

As I already pointed out in #203 (comment), I suggest to split this huge PR into independent components:

  • Porting to ROS2. This essentially includes:
    • Port to colcon and apply required adaptions to setup.py, package.xml, etc.
    • Adapt Travis config appropriately.
    • Provide substitution args in a similar fashion as in ROS1.
      @jacobperron and @gonzodepedro have done some preliminary work into this direction.
      But there are more catkin and ROS1 artifacts in the source code.
    • Make all the unit tests pass.

The first three points were nicely prepared by @vandanamandlik, @jacobperron, and @gonzodepedro. I'm working on the remaining issues (see #213).

The following improvments are independent from the ROS2 porting:

  • Formatting improvements to comply with flake8 and pep257
  • General source cleanup: Remove legacy processing. Remove python2 support.
    I plan to do this cleanup for Noetic. These changes should be ported to ROS2 then.

As the present PR is a mixture of the first two items, I suggest to close it here and continue on #213.
@gonzodepedro, @clalancette do you agree?

Signed-off-by: Gonzalo de Pedro <gonzalo@depedro.com.ar>
@clalancette
Copy link
Copy Markdown

@gonzodepedro, @clalancette do you agree?

Only sort of. While I agree with the general principle, the ROS 2 ports have been sitting long enough and we've done enough iterations with this PR that I think it would be a waste now to throw this away. I'd much rather port your travis fixes into this PR and complete it here.

Signed-off-by: Gonzalo de Pedro <gonzalo@depedro.com.ar>
@rhaschke
Copy link
Copy Markdown
Contributor

@clalancette, my motivation is primarily separation of concerns: The ROS2 port is a rather small fraction of this PR and should be decoupled from the python linting.
I'm not aiming to throw away the work done here on linting. Rather, I would like to resume this thread after having realized the basic ROS2 port.

@rhaschke
Copy link
Copy Markdown
Contributor

Currently, this PR has a lot of unit test failures and nobody yet worked on this. So far, work focused on fixing flake8 and pep257 issues, which doesn't help us in porting to ROS2.
In #213, I am focusing on the latter...

Signed-off-by: Gonzalo de Pedro <gonzalo@depedro.com.ar>
Signed-off-by: Gonzalo de Pedro <gonzalo@depedro.com.ar>
@rhaschke
Copy link
Copy Markdown
Contributor

Unfortunately, when rebasing #203 or #210 to latest melodic-devel, all changes to melodic-devel were overwritten, i.e. this PR lost some recent changes to melodic-devel.
Probably, it's faster to automatically redo the formatting changes than figuring out what is missing...

@rhaschke
Copy link
Copy Markdown
Contributor

Manually transferred formatting changes (90fb2af)

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.

6 participants