安装 跟着官方的安装指引来就行了.安装前要先确定自己的ros版本和ubuntu版本.这二者是一一对应的.
http://wiki.ros.org/ROS/Installation
主要是package源换成https://blog.csdn.net/shenghuaijing3314/article/details/76222385这篇文章中提到的中科大的镜像地址. 用官网的源,下载速度超慢.我的本机是带翻墙的,但是虚拟机里的ubuntu不能翻墙,不知道要怎么设置.
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
Navigating the ROS Filesystem
http://wiki.ros.org/ROS/Tutorials/NavigatingTheFilesystem
基本就是描述一下ros的一些bash怎么用.
Quick Overview of Filesystem Concepts
- Packages: Packages are the software organization unit of ROS code. Each package can contain libraries, executables, scripts, or other artifacts.
- Manifests (package.xml): A manifest is a description of a package. It serves to define dependencies between packages and to capture meta information about the package like version, maintainer, license, etc...
命令行工具
- rospack
- roscd
- rosls
Note that roscd, like other ROS tools, will only find ROS packages that are within the directories listed in your ROS_PACKAGE_PATH. To see what is in your ROS_PACKAGE_PATH, type:
echo $ROS_PACKAGE_PATH
Creating a ROS Package
What makes up a catkin Package?
- package.xml
- CMakeLists.txt
- Each package must have its own folder 不支持嵌套
最简单的package结构如下
my_package/
CMakeLists.txt
package.xml
推荐使用workspace创建package。结构如下
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
Creating a catkin Package
http://wiki.ros.org/catkin/Tutorials/create_a_workspace
首先一此链接里的操作创建一个catkin_ws/src目录.然后执行catkin_make。
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make
The catkin_make command is a convenience tool for working with catkin workspaces. Running it the first time in your workspace, it will create a CMakeLists.txt link in your 'src' folder. Additionally, if you look in your current directory you should now have a 'build' and 'devel' folder. Inside the 'devel' folder you can see that there are now several setup.*sh files. Sourcing any of these files will overlay this workspace on top of your environment
类似于生成makefile文件之类的.
使用catkin_create_pkg beginner_tutorials std_msgs rospy roscpp创建一个package
# You should have created this in the Creating a Workspace Tutorial
$ cd ~/catkin_ws/src
$ catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
# This is an example, do not try to run this
# catkin_create_pkg <package_name> [depend1] [depend2] [depend3]
$ cd ~/catkin_ws
$ catkin_make
查看package依赖
rospack depends1 beginner_tutorials
roscd beginner_tutorials
cat package.xml
package.xml里描述了依赖信息等.
依赖的包可能又有自己的依赖,比如
rospack depends1 rospy
genpy
roscpp
rosgraph
rosgraph_msgs
roslib
std_msgs
rospack depends可以显示所有嵌套的依赖
$ rospack depends beginner_tutorials
cpp_common
rostime
roscpp_traits
roscpp_serialization
catkin
genmsg
genpy
message_runtime
gencpp
geneus
gennodejs
genlisp
message_generation
rosbuild
rosconsole
std_msgs
rosgraph_msgs
xmlrpcpp
roscpp
rosgraph
ros_environment
rospack
roslib
rospy
Customizing Your Package
描述一下package.xml各个tag的功能.
- description tag
- maintainer tags
- license tags
- dependencies tags
- build_depend
- buildtool_depend
- exec_depend
- test_depend
<buildtool_depend>catkin</buildtool_depend>
#编译时依赖
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
#运行时依赖
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>