- You can create a ROS2 package with the following command.
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
# For C++ project
ros2 pkg create --build-type ament_cmake --node-name <node_name> <package_name>
# For Python project
ros2 pkg create --build-type ament_python --node-name <node_name> <package_name>
- Build the package
cd ~/ros2_ws
colcon build --packages-select <package_name>
source install/setup.bash
- Run the package
ros2 run <node_name> <package_name>