Tutorial——Beginner Level 1
1. Installing and Configuring Your ROS Environment
2. Navigating the ROS Filesystem
$ rospack find roscpp
$ roscd roscpp
$ rosls roscpp
# rospack = ros + pack(age)
# roscd = ros + cd
# rosls = ros + ls
3. Creating a ROS Package
a catkin Package consist of :
- package.xml. That package.xml file provides meta information about the package.
- CMakeLists.txt. There can be no more than one package in each folder.
This means no nested packages nor multiple packages sharing the same directory. Most simplest package’s instructure might be like this:
my_package/
CMakeLists.txt
package.xml
A trivial workspace might look like this:
workspace_folder/ -- WORKSPACE
src/ -- SOURCE SPACE
CMakeLists.txt -- 'Toplevel' CMake file, provided by catkin
package_1/
CMakeLists.txt -- CMakeLists.txt file for package_1
package.xml -- Package manifest for package_1
...
package_n/
CMakeLists.txt -- CMakeLists.txt file for package_n
package.xml -- Package manifest for package_n
catkin_create_pkg
$ cd catkin_ws/src
catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
# catkin_create_pkg <package_name> [depend1] [depend2] [depend3]
$ cd ../catkin_ws
$ catkin_make
$ . ~/catkin_ws/devel/setup.bash
When using catkin_create_pkg earlier, a few package dependencies were provided. These first-order dependencies can now be reviewed with the rospack tool.
$ rospack depends1 beginner_tutorials
std_msgs
rospy
roscpp
# 初次使用会报错,会建议你 sudo rosdep init
如果使用了proxy网络代理
# sudo rosdep init will report error
# rosdep init ERROR: cannot download default sources list from
# 需要sudo使用 -E 来保留 环境变量配置 ,如之前设置过的 export http_proxy=x:y
$ sudo -E rosdep init
$ rosdep update
$ rospack depends1 beginner_tutorials # 可得到上述相应依赖包
$ roscd beginner_tutorials
$ vi package.xml
<package>