Common sources of pain - Queen-s-Aerospace-Design-Team/AeroSAE2027 GitHub Wiki

Building your ROS packages with colcon build

Every time you edit or create new ROS packages, you must build them using colcon build. Once again, ROS packages are held in the src directory under AeroSAE2027/ros_ws and colcon build will build all packages under the src directory from which you called it. Navigate to your ROS workspace directory and run:

cd ~/AeroSAE2027/ros_ws
colcon build

Now your packages are built and can then be 'sourced' with the command:

source install/setup.sh

OR

sros # an alias for 'source install/setup.sh'

Running a node

Follow the above steps to build packages. Make sure you've run source install/setup.bash. Then run ros2 run <package_name><executable_name>

Running a new terminal inside the Dev Container

If you'd like to open a new terminal that is inside the dev container, run this command

docker exec -it qadt-devcontainer zsh

You'll then see qadt -> ~/AeroSAE2027 indicating you're inside the dev container. Note you can also just click the + button in vscode to open a new terminal inside the container.

What's an executable name?

An executable name is the label you assign to a specific node. It does NOT necessarily match the node file name! It is set differently in Python and C++ packages.

Python Packages

Declared in the packages setup.py file, in the entry_points dictionary

entry_points={
    'console_scripts': [
        'my_node_name = my_package.my_file:main',
    ],
},

my_node_name is the executable name

C++ Packages

Declare in the packages CMakeLists.txt file

add_executable(my_node_name src/my_file.cpp)

install(TARGETS
  my_node_name
  DESTINATION lib/${PROJECT_NAME})

add_executable(my_node_name src/my_file.cpp) compiles my_file.cpp into an executable named my_node_name The install(...) block is what makes my_node_name actually discoverable by ros2 run. This step trips people up most, since the code compiles fine without it, but ros2 run comes back with "executable not found"