ROS

How to make workspace and package in ros

SagalU 2022. 3. 31. 20:21

Caution: This manual assumes that the ros is installed in your ubuntu machine and ROS environment is sourced to get access to ROS functions.

command of the below shall be executed or added in your ~/.bashrc

source /opt/ros/noetic/setup.bash

 

 

1. Make a directory for workspace and its source directory

for example)

mkdir -p ~/catkin_ws/src

 

2. Change directory to the source directory and initialize it

The command is "catkin_init_workspace"

It makes symbolic link pointing to "/opt/ros/noetic/share/catkin/cmake/toplevel.cmake".

for example)

cd ~/catkin_ws/src

catkin_init_workspace

 

3. Change directory to the workspace directory and build the workspace.

The command is "catkin_make"

It generate default configurations and directories

for example)

cd ~/catkin_ws

catkin_make

 

4. Source the setup file in the "devel" directory.

If the workspace may be used frequently, the snippet shall be added in your ~/.bashrc

for example 1)

source ~/catkin_ws/devel/setup.bash

for example 2)

echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc

source ~/.bashrc

 

5. Make a package in the source directory

The command is "catkin_create_pkg package_name [dependency1] [dependency2] ....."

It makes project directory with name of package_name and default CMake script and xml file in it.

 

for example)

cd ~/catkin_ws/src

catkin_create_pkg mypkg1 roscpp std_msgs action_lib actionlib_msgs