KevsRobots Learning Platform
By , Minute
A package bundles nodes together so they can be built, shared and run with ros2 run. Use the ROS2 pkg create command to create one.
cd /ros2
ros2 pkg create my_py_pkg --build-type ament_python --dependencies rclpy
cd my_py_pkg
This will create a new folder that includes the dependencies needed for this package (the rclpy library), as well as the files required to install this such as the setup.py file.
The package.xml file is also created. This contains the version, description, maintainer contact details as well as the licence type.
It also contains the dependencies for this package; the rclpy library we specified.
Let’s build the new package
colcon build
1 package had stderr output:
If you get an error message that says:
Summary: 1 package finished [3.60s] 1 package had stderr output: my_py_pkgThis is a warning from newer versions of Python’s
setuptools. We can fix it by installing a known good version:
- Install pip3 - from the docker terminal type:
sudo apt update && sudo apt install pip -y
- Downgrade setuptools - from the docker terminal type:
pip install setuptools==58.2.0This should fix the error; type
colcon buildagain to successfully build the package.
We need to fix the permissions to edit files in these folders, from within VSCode:
chmod 777 -R /ros2/my_py_pkg
<depend>rclpy</depend>:<depend>std_msgs</depend>
You can use the arrows ← → on your keyboard to navigate between lessons.
Comments