ROS探究(一)建立项目

tzy@ubuntu:~$ mkdir -p ROS_Example/catkin_ws/src
tzy@ubuntu:~$ cd ROS_Example/catkin_ws/
tzy@ubuntu:~/ROS_Example/catkin_ws$ catkin_make

以上命令等价于

cd ~/catkin_ws
cd src
catkin_init_workspace
cd ..
mkdir build
cd build
cmake ../src -DCMAKE_INSTALL_PREFIX=../install -DCATKIN_DEVEL_PREFIX=../devel
make

 

catkin_ws目录下会生成以下三个文件夹

tzy@ubuntu:~/ROS_Example/catkin_ws$ ls  

build devel src

src下的CMakeLists是软链接

tzy@ubuntu:~/ROS_Example/catkin_ws$ ll src/CMakeLists.txt
lrwxrwxrwx 1 tzy tzy 50 Oct 27 17:10 src/CMakeLists.txt -> /opt/ros/kinetic/share/catkin/cmake/toplevel.cmake

 

tzy@ubuntu:~/ROS_Example/catkin_ws$ source devel/setup.bash

要保证工作区被安装脚本正确覆盖,需确定ROS_PACKAGE_PATH环境变量包含你当前的工作空间目录:


tzy@ubuntu:~/ROS_Example/catkin_ws$ echo $ROS_PACKAGE_PATH
/home/tzy/ROS_Example/catkin_ws/src:/opt/ros/kinetic/share

 

现在使用catkin_create_pkg命令创建一个名为beginner_tutorials的新软件包,这个软件包依赖于std_msgs、roscpp和rospy这3个包

tzy@ubuntu:~/ROS_Example/catkin_ws$ catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
Created file beginner_tutorials/CMakeLists.txt
Created file beginner_tutorials/package.xml
Created folder beginner_tutorials/include/beginner_tutorials
Created folder beginner_tutorials/src
Successfully created files in /home/tzy/ROS_Example/catkin_ws/beginner_tutorials. Please adjust the values in package.xml.

std_msgs对于ROS来说也是一个软件包,可以用操作软件包的命令进行查看

tzy@ubuntu:~/ROS_Example/catkin_ws$ rosls std_msgs/
cmake msg package.xml

tzy@ubuntu:~/Desktop$ roscd std_msgs
tzy@ubuntu:/opt/ros/kinetic/share/std_msgs$ ls
cmake msg package.xml

std_msgs包对应的原始代码链接

GitHub - ros/std_msgs: Contains minimal messages of primitive data types and multiarrays. Intended for quick prototyping, not production use.

 

上一篇:反汇编


下一篇:2021-10-28