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

change how to get ros2 version #14063

Closed
wants to merge 9 commits into from
Closed

change how to get ros2 version #14063

wants to merge 9 commits into from

Conversation

stmoon
Copy link
Contributor

@stmoon stmoon commented Jan 30, 2020

Describe problem solved by this pull request

When I compile with rtps (ex. make px4_sitl_rtps), I found there is an error about ROS version like below.

In this case, I installed ros2 dashing by default method (ros-desktop)

Traceback (most recent call last):
  File "/usr/bin/rosversion", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3089, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3072, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3101, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 574, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 892, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 778, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'rospkg==1.2.3' distribution was not found and is required by the application
Traceback (most recent call last):
  File "/home/px4/firmware.rtps/Firmware.stmoon/msg/tools/generate_microRTPS_bridge.py", line 255, in <module>
    rosversion_out = subprocess.check_output(["rosversion", "-d"])
  File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['rosversion', '-d']' returned non-zero exit status 1.
[19/746] Generating git version header

Describe your solution

To check the ROS version in ROS2, ROS_DISTRO environment variable is used.

So, to solve it, I change how to check ros version. (rosversion -> ROS_DISTRO environment variable)

@stmoon stmoon changed the title change how to get ros2 version (rosverion -> ROS_DISTRO) change how to get ros2 version Jan 30, 2020
@dagar dagar requested a review from TSC21 January 31, 2020 03:45
@TSC21
Copy link
Member

TSC21 commented Feb 1, 2020

This does not solve the problem you have with using rosversion and the solution you propose is redundant (it tries to run rosversion even after you set the Python var by checking the env var - you use one or another). I also have Dashing installed from deb list and I don't get the above problem, so I recommend you to check what is the problem on your side before trying to turn around it.

@stmoon
Copy link
Contributor Author

stmoon commented Feb 1, 2020

@TSC21 Thank you so much :-)

Actually, for the test, I just install ros-dashing-desktop using apt in ubuntu. and I found the error.
In addition, some people had the same problems (https://answers.ros.org/question/33769/how-to-get-ros-version/). a guy recommends the usage of ROS_DISTRO environment variable for ROS2.

After your comment, I checked my system installed python-rospkg already for rosversion command. I think it is installed by ros-dashing-deskto. However, it still has same problem.

Now, I found python3-rospkg should be installed for the rosversion working. However, I couldn't find any comments or documents. I hope that python3-rospkg should be added in the necessary package list to avoid same mistake for other guys, if ROS_DISTRO is not used.

@LorenzMeier
Copy link
Member

Can we get to a conclusion here?

ros2_distro = args.ros2_distro
else:
raise
ros2_distro = os.environ.get('ROS_DISTRO')
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 please add a check that makes sure that makes sure that the ROS_DISTRO that is set is not a ROS 1 distro? Can be done on the next line. Otherwise, the rest of the process will fail. Thanks.

@stmoon
Copy link
Contributor Author

stmoon commented Mar 15, 2020

Thank you for good comments.

I update the code according to your comments.
However, I found there is some error when I compile the code.
And, I found it is related to the version check for the libfastrtps.
And, I push request (#14393) (it is not perfect. could you give me some idea?)

Thanks

@TSC21
Copy link
Member

TSC21 commented Mar 15, 2020

Thank you for good comments.

I update the code according to your comments.
However, I found there is some error when I compile the code.
And, I found it is related to the version check for the libfastrtps.
And, I push request (#14393) (it is not perfect. could you give me some idea?)

Thanks

From a first look I think it can be improved, yes. Thanks

@TSC21
Copy link
Member

TSC21 commented Mar 15, 2020

@stmoon commit d5712f0 seemed to have broken the PR (CI is failing in multiple places for Github actions). Can you please issue a new PR with a single commit that brings the change? Thanks!

@stmoon
Copy link
Contributor Author

stmoon commented Mar 15, 2020

@TSC21 , I make new PR to replace the broken PR (#14394). Thanks.

@stmoon stmoon closed this Apr 4, 2020
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.

3 participants