ROS/ROS2Foxy

The command syntax for creating a new package in ROS 2

leohycho 2022. 5. 4. 14:30

source /opt/ros/foxy/setup.bash

 

mkdir -p my_ws/src

cd ~my_ws/src

 

ros2 pkg create --build-type ament_python <my_package>

ros2 pkg create --build-type ament_python --node-name <my_node> <my_package>

ros2 pkg create --build-type ament_python <my_package> --dependencies <rclpy> <my_interfaces>

 

ros2 pkg create --build-type ament_cmake <my_package>

ros2 pkg create --build-type ament_cmake --node-name <my_node> <my_package>

 

cd ~/my_ws

 

colcon build

colcon build --packages-select my_package

colcon build --symlink-install

colcon build --symlink-install --packages-select <my_package>

 

source /opt/ros/foxy/setup.bash && source ~/my_ws/install/local_setup.bash

 

ros2 run <my_package> <my_node>

ros2 launch <my_package> <my_launch>

 

rosdep install -i --from-path src --rosdistro foxy -y

 

source /usr/share/colcon_cd/function/colcon_cd.sh

export _colcon_cd_root=~/my_ws

 

gedit ~/.bashrc

source ~/.bashrc