ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

ros2 launch not working after source my package

asked 2020-04-21 13:15:58 -0500

robopo gravatar image

updated 2022-02-09 14:40:05 -0500

clyde gravatar image

Honestly I do not know what is happeing on the background therefore I'm not able to solve it.

First of all I run my foxy (latest dev) on raspberry pi 3, successfully compiled. Everything works.

I open a new terminal and

source ~/ros2_foxy/install/setup.bash

Now I'm able to run following command

ros2 launch

It says that I didn't provide arguments but it works.

Then I go to my workspace and run the build:

cd ~/my_workspace
colcon build

A now when I do :

source ./install/setup.bash

OR

source ./install/local_setup.bash

Then ros2 launch is not known command:

Failed to load entry point 'launch': No module named 'launch.launch_description_sources'
Traceback (most recent call last):
  File "/home/pi/ros2_foxy/install/ros2cli/bin/ros2", line 11, in <module>
    load_entry_point('ros2cli', 'console_scripts', 'ros2')()
  File "/home/pi/ros2_foxy/build/ros2cli/ros2cli/cli.py", line 43, in main
    required=False, argv=argv)
  File "/home/pi/ros2_foxy/build/ros2cli/ros2cli/command/__init__.py", line 236, in add_subparsers_on_demand
    extension = command_extensions[name]
KeyError: 'launch'

And it is not in the list of ros2 commands anymore:

lttng module version >=2.10.7 required, found 2.10.6
Failed to load entry point 'test': No module named 'launch.actions'
Failed to load entry point 'launch': No module named 'launch.launch_description_sources'
usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ...

ros2 is an extensible command-line tool for ROS 2.

optional arguments:
  -h, --help            show this help message and exit

Commands:
  action     Various action related sub-commands
  bag        Various rosbag related sub-commands
  component  Various component related sub-commands
  daemon     Various daemon related sub-commands
  doctor     Check ROS setup and other potential issues
  interface  Show information about ROS interfaces
  lifecycle  Various lifecycle related sub-commands
  multicast  Various multicast related sub-commands
  node       Various node related sub-commands
  param      Various param related sub-commands
  pkg        Various package related sub-commands
  run        Run a package specific executable
  security   Various security related sub-commands
  service    Various service related sub-commands
  topic      Various topic related sub-commands
  trace      Trace ROS nodes to get information on their execution
  wtf        Use `wtf` as alias to `doctor`

  Call `ros2 <command> -h` for more detailed usage.

What went wrong? Is there any docs? What I'm doing wrong? Please help.

edit retag flag offensive close merge delete

Comments

Seeing the same issue, launch was working for me previously and then stopped with this bug

I am also no longer able to run test

If i restart my computer then it does find the launch package.

Running source ./install/setup.bash seems to cause the issue.

drewbeller gravatar image drewbeller  ( 2022-02-08 18:13:36 -0500 )edit

@drewbeller Please do not post answers that are not actually answers. I've converted your answer to a comment. If you have a new question, please open a new question. Thanks!

https://wiki.ros.org/Support

jarvisschultz gravatar image jarvisschultz  ( 2022-02-11 08:47:24 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2022-02-09 19:05:02 -0500

ChuiV gravatar image

You'll want to use the local_setup.bash instead of setup.bash when you source your own workspace.

I may be paraphrasing here, and I'm sure somebody could explain the differences better than I. But from my experience, setup.bash will replace/overwrite anything you've already sourced, and local_setup.bash will pre-pend to what you've already sourced.

So in your case, you setup.bash'd your foxy build (note that if it was in /opt/ros/foxy instead of ~/ros2_foxy/install, it may work as you expected), which puts the ros2 stuff into your environment. Then you go and setup.bash your workspace, which clears out sourcing ~/ros2_foxy/install, tries to source /opt/ros/foxy (which isn't there) then sources your workspace on top. The result is that you only have your own workspace in your environment. No ros2.

edit flag offensive delete link more

Comments

running . install/local_setup.bash instead of . install/setup.bash does not fix the problem for me.

They both lead to the same result of launch no longer being found

drewbeller gravatar image drewbeller  ( 2022-02-14 16:24:07 -0500 )edit

I'm also sourcing my ROS environment from source /opt/ros/foxy/setup.bash. From a clean unbuilt workspace (i.e., just src package folders), the steps I'm running are:

  1. source /opt/ros/foxy/setup.bash
  2. cd ~/path_to/dev_ws
  3. colcon build
  4. . install/local_setup.bash

The launch command is found and listed after running ros2 -h after steps 1-3, but not found after step 4

drewbeller gravatar image drewbeller  ( 2022-02-14 17:06:49 -0500 )edit
0

answered 2022-02-14 18:03:50 -0500

drewbeller gravatar image

The ultimate issue for me was keeping my launch folders in a directory named /launch/.

It looks like that caused conflicts with the ros2 action, changing that and then doing a clean build resolved the issue for me

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2020-04-21 13:15:58 -0500

Seen: 4,065 times

Last updated: Feb 14 '22