ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This might be of some help: ROS2 Foxy, Creating a Workspace, 'Overlay'

You might try removing all of the build artifacts and rebuilding.

  1. Open a new terminal.
  2. Navigate to your workspace: cd ~/ros2_ws
  3. Remove everything except for the source code (src/): rm -rf ./build/ ./install/ ./log/
  4. Source the ROS2 setup.bash: source /opt/ros/foxy/setup.bash # In Bash, "source" is the same as '.' which corresponds to the "SH" shell (its predecessor)
  5. Use Colcon to rebuild the project: colcon build
  6. You should now have fresh directories in your workspace. Running ls should show... build/ install/ log/ src/.
  7. Source your project's specific Setup.bash file: source ./install/setup.bash. For information on this see my link above.
  8. You should now be able to run a module or launch file. ros2 run my_pkg node_in_pkg

Be sure to run that project-specific setup.bash!

When you source the base setup script (source /opt/ros/foxy/setup.bash) your current terminal session only knows about the pre-installed ROS2 packages and such located in /opt/ros/foxy/<blah>.

You need to make it aware of your package for you to be able to make use of it. That is done by sourcing your own setup script (source ros2_ws/install/setup.bash).