ROS(Robot Operating System)是一个机器人软件平台,它具备类似操作系统的功能,但却不是真正的操作系统,需要运行在Linux系统下,最能支持ROS运行的便是Ubuntu系统。
我们需要先安装Ubuntu系统(最好不在虚拟机下运行Ubuntu),通过在终端里输指令来下载ROS以及其相关软件包(需联网)。
该教程将以在U盘上安装ROS为例来安装ROS,引导初学者从零入门ROS,以运行小海龟的例子来练习使用ROS,了解其基本概念。
一、 ROS在U盘上的安装方法
1.将Linux-Ubuntu系统安装到U盘:
https://jingyan.baidu.com/article/a681b0de099c0d3b184346a2.html
2.ROS的安装:
https://www.cnblogs.com/liu-fa/p/5779206.html
二、 ROS试用练习
按照以下提示和命令来试用ROS:
Create workspace, the folder locates in ~/catkin_ws/src.
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
$ catkin_init_workspace
There is not function package in the folder, only the CMakelist.txt in it.
Next, we need to compile the workspace with the command below.
$ cd ~/catkin_ws
$ catkin_make
Use the command ls, we can see the new folders.
Use this to complete configuration.
$ source devel/setup.bash
Create ROS function package.
$ cd ~/catkin_ws/src
$ catkin_create_pkg chapter2_tutorials std_msgs roscpp
Compile ROS function package.
$ cd ~/catkin_ws/
$ catkin_make //You must run the command $ catkin_make in the workspace rather than in other folders.
Use ROS nodes.
Run ROS core file.
$ roscore
Open another terminal and continue.
$ rosrun turtlesim turtlesim_node //Launch a new node(turtle).
Appear a window, open another terminal and continue.
$ rosnode list
$ rosnode info /turtlesim //To see many information about debuging procedure.
$ rostopic bw -h //To see the detailed information of the parameter about rostopic tool.
$ rosrun turtlesim turtle_teleop_key //Use this node to move turtle with arrow.
Open another terminal and continue.
$ rostopic list
$ rostopic echo /turtle1/cmd_vel //To browse the information from nodes.
$ rostopic type /turtle1/cmd_vel //Message type.
$ rosmsg show geometry_msgs/Twist
Control the turtle.
$ rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -1 -- '{linear: {x: 20,y: 0.0,z: 0.0},angular: {x: 0.0,y: 0.0,z: 4.7}}'
You can see the turtle move for a while.
Run the RViz.
$ rosrun rviz rviz -d `rospack find rbx1_nav`/sim.rviz
Open another terminal.
$ roscore
Open another terminal.
$ rosrun rviz rviz -d `rospack find rbx1_nav`/sim.rviz
You can see the RViz simulator.
Run this command.
$ rostopic pub /cmd_vel geometry_msgs/Twist -r 10 '{linear: {x: 0.2, y: 0, z: 0}, angular: {x: 0, y: 0, z: 0.5}}'
The robot move along a circle.
三、代码下载
1. 创建节点时所用的cpp代码下载网址: