ROS学习总结


ROS:Robot Operating System,机器人操作系统

第 1 章 ROS概述与环境搭建

1、Linux基础命令

➢cd 命令
• 语法:cd <目录路径>
• 功能:改变工作目录。若没有指定“目录路径”,则回到用户的主目录 。
➢ pwd 命令
• 语法:pwd
• 功能:此命令显示出当前工作目录的绝对路径。
在这里插入图片描述
➢ mkdir命令
• 语法:mkdir [选项] <目录名称>
• 功能:创建一个目录。
➢ ls 命令
• 语法:ls [选项] [目录名称…]
• 功能:列出目录的内容。
在这里插入图片描述
➢ touch命令
• 语法:touch [选项] [文件名称…]
• 功能:改变文件或目录时间。
在这里插入图片描述
➢ mv命令
• 语法:mv [选项] <源文件或目录> <目地文件或目录>
• 功能:为文件或目录改名或将文件由一个目录移入另一个目录中。
➢ cp命令
• 语法:cp [选项] <源文件名称或目录名称> <目的文件名称或目录名称>
• 功能:把给出的一个文件或目录拷贝到另一文件或目录中,或者把多个源文件复制到目标目录中。
在这里插入图片描述
➢ rm命令
• 语法:rm [选项] <文件名称或目录名称…>
• 功能:该命令的功能为删除一个目录中的一个或多个文件或目录,它也可以将某个目录及其下
的所有文件及子目录均删除。对于链接文件,只是删除了链接,原有文件均保持不变。
在这里插入图片描述
➢ sudo命令
• 语法:sudo [选项>][指令]
• 功能:以其他身份来执行指令。
在这里插入图片描述
在这里插入图片描述
##2、ROS安装步骤

  1. 添加ROS软件源
    $ sudo sh -c ‘echo “deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main” > /etc/apt/sources.list.d/ros-latest.list’
  2. 添加密钥
    $ sudo apt-key adv --keyserver ‘hkp://keyserver.ubuntu.com:80’ --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
  3. 安装ROS
    $ sudo apt update
    $ sudo apt install ros-melodic-desktop-full
    4.初始化rosdep
    $ sudo rosdep init
    $ rosdep update
  4. 设置环境变量
    $ echo “source /opt/ros/melodic/setup.bash” >> ~/.bashrc
    $ source ~/.bashrc
  5. 安装rosinstall
    $ sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

安装完成
安装目录,默认在/opt/ros路径下
在这里插入图片描述

  1. 启动ROS Master: $ roscore
  2. 启动小海龟仿真器 :$ rosrun turtlesim turtlesim_node
  3. 启动海龟控制节点:$ rosrun turtlesim turtle_teleop_key
    使用roscore命令启动ROS Master启动海龟仿真器节点
    启动海龟控制节点

第 2 章 ROS通信核心概念

1、ROS中的核心概念

1.1节点与节点管理器

◼ 节点(Node) —— 执行单元
⚫ 执行具体任务的进程、独立运行的可执行文件;
⚫ 不同节点可使用不同的编程语言,可分布式运行
在不同的主机;
⚫ 节点在系统中的名称必须是唯一的。
◼ 节点管理器 (ROS Master) —— 控制中心
⚫ 为节点提供命名和注册服务;
⚫ 跟踪和记录话题/服务通信,辅助节点相互查找、
建立连接;
⚫ 提供参数服务器,节点使用此服务器存储和检索
运行时的参数。
在这里插入图片描述

2、话题通信

◼ 话题(Topic)—— 异步通信机制
⚫ 节点间用来传输数据的重要总线;
⚫ 使用发布/订阅模型,数据由发布者传输到订阅者,同一个话题的订阅者或发布者可以不唯一。
◼ 消息(Message)—— 话题数据
⚫ 具有一定的类型和数据结构,包括ROS提供的标准类型和用户自定义类型;
⚫ 使用编程语言无关的.msg文件定义,编译过程中生成对应的代码文件。
在这里插入图片描述

3、服务通信

◼ 服务(Service) —— 同步通信机制
⚫ 使用客户端/服务器(C/S)模型,客户端发送请求数据,服务器完成
处理后返回应答数据;
⚫ 使用编程语言无关的.srv文件定义请求和应答数据结构,编译过程中
生成对应的代码文件
在这里插入图片描述

3.1话题 vs 服务

在这里插入图片描述

4、参数

◼ 参数(Parameter) —— 全局共享字典
⚫ 可通过网络访问的共享、多变量字典;
⚫ 节点使用此服务器来存储和检索运行时的参数;
⚫ 适合存储静态、非二进制的配置参数,不适合存储动态配置的数据。
参数模型(全局字典)
参数模型(全局字典)

5、文件系统

◼ 功能包(Package)
⚫ ROS软件中的基本单元,包含节点源码、配置文件、数据定义等
◼ 功能包清单(Package manifest)
⚫ 记录功能包的基本信息,包含作者信息、许可信息、依赖选项、编译标志等
◼ 元功能包(Meta Packages)
⚫ 组织多个用于同一目的功能包
在这里插入图片描述

6、ROS命令行工具的使用

常用命令
• rostopic
• rosservice
• rosnode
• rosparam
• rosmsg
• rossrv
在这里插入图片描述
使用rqt_graph可视化工具查看系统中运行的计算图
在这里插入图片描述
在这里插入图片描述

5、ROS命令行工具的使用

工作空间(workspace)是一个存放工程开发
相关文件的文件夹。
• src:代码空间(Source Space)
• build:编译空间(Build Space)
• devel:开发空间(Development Space)
• install:安装空间(Install Space)
catkin编译系统下的工作空间结构
catkin编译系统下的工作空间结构
创建工作空间

$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
$ catkin_init_workspace

编译工作空间

$ cd ~/catkin_ws/
$ catkin_make

设置环境变量

$ source devel/setup.bash

检查环境变量

$ echo $ROS_PACKAGE_PATH

在这里插入图片描述

5.1创建功能包

检查环境变量

$ catkin_create_pkg <package_name> [depend1] [depend2] [depend3]
创建功能包
$ cd ~/catkin_ws/src
$ catkin_create_pkg test_pkg std_msgs rospy roscpp
$ cd ~/catkin_ws
编译功能包
$ catkin_make
$ source ~/catkin_ws/devel/setup.bash

同一个工作空间下,不允许存在同名功能包
不同工作空间下,允许存在同名功能包

6、发布者Publisher的编程实现

在这里插入图片描述
创建功能包

$ cd ~/catkin_ws/src
$ catkin_create_pkg learning_topic roscpp rospy std_msgs geometry_msgs turtlesim

在这里插入图片描述
如何实现一个发布者
• 初始化ROS节点;
• 向ROS Master注册节点信息,
包括发布的话题名和话题中
的消息类型;
• 创建消息数据;
• 按照一定频率循环发布消息。
velocity_publisher.cpp
/**

  • 该例程将发布turtle1/cmd_vel话题,消息类型geometry_msgs::Twist
    */
#include <ros/ros.h>
#include <geometry_msgs/Twist.h>

int main(int argc, char **argv)
{
   // ROS节点初始化
   ros::init(argc, argv, "velocity_publisher");

   // 创建节点句柄
   ros::NodeHandle n;

   // 创建一个Publisher,发布名为/turtle1/cmd_vel的topic,消息类型为geometry_msgs::Twist,队列长度10
   ros::Publisher turtle_vel_pub = n.advertise<geometry_msgs::Twist>("/turtle1/cmd_vel", 10);

   // 设置循环的频率
   ros::Rate loop_rate(10);

   int count = 0;
   while (ros::ok())
   {
       // 初始化geometry_msgs::Twist类型的消息
   	geometry_msgs::Twist vel_msg;
   	vel_msg.linear.x = 0.5;
   	vel_msg.angular.z = 0.2;

       // 发布消息
   	turtle_vel_pub.publish(vel_msg);
   	ROS_INFO("Publsh turtle velocity command[%0.2f m/s, %0.2f rad/s]", 
   			vel_msg.linear.x, vel_msg.angular.z);

       // 按照循环频率延时
       loop_rate.sleep();
   }

   return 0;
}

配置发布者代码编译规则在这里插入图片描述

add_executable(velocity_publisher src/velocity_publisher.cpp)
target_link_libraries(velocity_publisher ${catkin_LIBRARIES})

编译并运行发布者

$ cd ~/catkin_ws
$ catkin_make
$ source devel/setup.bash
$ roscore
$ rosrun turtlesim turtlesim_node
$ rosrun learning_topic velocity_publishe

在这里插入图片描述

7、订阅者Subscriber的编程实现

在这里插入图片描述
如何实现一个订阅者
• 初始化ROS节点;
• 订阅需要的话题;
• 循环等待话题消息,接收到
消息后进入回调函数;
• 在回调函数中完成消息处理。
pose_subscriber.cpp

/**
* 该例程将订阅/turtle1/pose话题,消息类型turtlesim::Pose
*/

#include <ros/ros.h>
#include "turtlesim/Pose.h"

// 接收到订阅的消息后,会进入消息回调函数
void poseCallback(const turtlesim::Pose::ConstPtr& msg)
{
   // 将接收到的消息打印出来
   ROS_INFO("Turtle pose: x:%0.6f, y:%0.6f", msg->x, msg->y);
}

int main(int argc, char **argv)
{
   // 初始化ROS节点
   ros::init(argc, argv, "pose_subscriber");

   // 创建节点句柄
   ros::NodeHandle n;

   // 创建一个Subscriber,订阅名为/turtle1/pose的topic,注册回调函数poseCallback
   ros::Subscriber pose_sub = n.subscribe("/turtle1/pose", 10, poseCallback);

   // 循环等待回调函数
   ros::spin();

   return 0;
}

配置订阅者代码编译规则
在这里插入图片描述

add_executable(pose_subscriber src/pose_subscriber.cpp)
target_link_libraries(pose_subscriber ${catkin_LIBRARIES})

8、话题消息的定义与使用

在这里插入图片描述

7.1自定义话题消息

如何自定义话题消息

string name
uint8 sex
uint8 age
uint8 unknown = 0
uint8 male = 1
uint8 female = 2

➢ 定义msg文件;
➢ 在package.xml中添加功能包依赖
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>
➢ 在CMakeLists.txt添加编译选项
• find_package( …… message_generation)
• add_message_files(FILES Person.msg)
generate_messages(DEPENDENCIES std_msgs)
• catkin_package(…… message_runtime)
➢ 编译生成语言相关文件

8、ROS中常用的数据类型

最近用这些数据类型总是会忘,写记录方便查询

1.geometry_msgs::Point

float64 x
float64 y
float64 z

2.geometry_msgs::Point32

float32 x
float32 y
float32 z

### 3.geometry_msgs::PointStamped
```javascript
Header header
	uint32 seq
	time stamp
	string frame_id

Point point
	float64 x
	float64 y
	float64 z

4.geometry_msgs::Pose

Point position
	float64 x
	float64 y
	float64 z
	
Quaternion orientation
	float64 x
	float64 y
	float64 z
	float64 w

5.geometry_msgs::Pose2D

float64 x
float64 y
float64 theta

6.geometry_msgs::PoseArray

Header header
	uint32 seq
	time stamp
	string frame_id

Pose[] poses
	Point position
		float64 x
		float64 y
		float64 z
	Quaternion orientation
		float64 x
		float64 y
		float64 z
		float64 w

7.geometry_msgs::PoseStamped

Header header
	uint32 seq
	time stamp(int32 )
	string frame_id
	
Pose pose
	Point position
		float64 x
		float64 y
		float64 z
	Quaternion orientation
		float64 x
		float64 y
		float64 z
		float64 w

PoseStamped 数据类型
在这里插入图片描述
geometry_msgs/Quaternion类型的’oreintation’,而oreintation包含四个float64的变量x,y,z,w,quaterion中文四元数,是一个用来表示方向的东西.四元数的缺点是不很形象,不熟的人很难直接通过四元数在脑海里构想出机器人目前到底是个什么朝向.我们一般用欧拉角表示方向时,一共有三个数roll,pitch,yaw,比较直观,但是欧拉角表示方向时会遇到一个叫Gimbal Lock(万向锁)的尴尬问题,所以ROS里统一用四元数表示方向.ROS当然提供了一些API把四元数转换成欧拉角或者旋转矩阵之类的,但是在储存pose的时候,都统一用四元数储存

8.geometry_msgs::PoseWithCovariance

# This represents a pose in free space with uncertainty.
Pose pose
	Point position
		float64 x
		float64 y
		float64 z
	Quaternion orientation
		float64 x
		float64 y
		float64 z
		float64 w

float64[36] covariance

9.geometry_msgs::PoseWithCovarianceStamped

Header header
	uint32 seq
	time stamp
	string frame_id
	
PoseWithCovariance pose
	Pose pose
		Point position
			float64 x
			float64 y
			float64 z
		Quaternion orientation
			float64 x
			float64 y
			float64 z
			float64 w
	float64[36] covariance

10.geometry_msgs::Quaternion

float64 x
float64 y
float64 z
float64 w

### 11.geometry_msgs::QuaternionStamped
```javascript
Header header
	uint32 seq
	time stamp
	string frame_id
	
Quaternion quaternion
	float64 x
	float64 y
	float64 z
	float64 w

12.geometry_msgs::Transform

Vector3 translation
	float64 x
	float64 y
	float64 z
	
Quaternion rotation
	float64 x
	float64 y
	float64 z
	float64 w

13.geometry_msgs::TransformStamped

Header header
	uint32 seq
	time stamp
	string frame_id
	
string child_frame_id # the frame id of the child frame

Transform transform
	Vector3 translation
		float64 x
		float64 y
		float64 z
		
	Quaternion rotation
		float64 x
		float64 y
		float64 z
		float64 w

14.nav_msgs::Odometry

std_msgs/Header header
	uint32 seq
	time stamp			//时间戳
	string frame_id		//父坐标系:位姿估计的坐标系
string child_frame_id	//子坐标系
geometry_msgs/PoseWithCovariance pose	//base_footprint在odom下的位姿
	geometry_msgs/Pose pose
		geometry_msgs/Point position
			float64 x
			float64 y
			float64 z
		geometry_msgs/Quaternion orientation
			float64 x
			float64 y
			float64 z
			float64 w
	float64[36] covariance	
geometry_msgs/TwistWithCovariance twist		//速度=线速度+角速度
	geometry_msgs/Twist twist
		geometry_msgs/Vector3 linear
			float64 x
			float64 y
			float64 z
		geometry_msgs/Vector3 angular
			float64 x
			float64 y
			float64 z
	float64[36] covariance

第 7 章 机器人导航(仿真)

导航是机器人系统中最重要的模块之一,比如现在较为流行的服务型室内机器人,就是依赖于机器人导航来实现室内自主移动的,本章主要就是介绍仿真环境下的导航实现,主要内容有:

导航相关概念
导航实现:机器人建图(SLAM)、地图服务、定位、路径规划…以可视化操作为主。
导航消息:了解地图、里程计、雷达、摄像头等相关消息格式。
预期达成的学习目标:

了解导航模块中的组成部分以及相关概念
能够在仿真环境下独立完成机器人导航
案例演示:
SLAM建图
在这里插入图片描述
定位
在这里插入图片描述

导航实现
在这里插入图片描述

7.1 概述

1.概念

在ROS中机器人导航(Navigation)由多个功能包组合实现,ROS 中又称之为导航功能包集,关于导航模块,官方介绍如下:

一个二维导航堆栈,它接收来自里程计、传感器流和目标姿态的信息,并输出发送到移动底盘的安全速度命令。
机器人是如何实现导航的呢?或换言之,机器人是如何从 A 点移动到 B 点呢?ROS 官方为了提供了一张导航功能包集的图示,该图中囊括了 ROS 导航的一些关键技术:
在这里插入图片描述
假定我们已经以特定方式配置机器人,导航功能包集将使其可以运动。上图概述了这种配置方式。白色的部分是必须且已实现的组件,灰色的部分是可选且已实现的组件,蓝色的部分是必须为每一个机器人平台创建的组件。

总结下来,涉及的关键技术有如下五点:

全局地图

自身定位

路径规划

运动控制

环境感知

机器人导航实现与无人驾驶类似,关键技术也是由上述五点组成,只是无人驾驶是基于室外的,而我们当前介绍的机器人导航更多是基于室内的。

1.全局地图

在现实生活中,当我们需要实现导航时,可能会首先参考一张全局性质的地图,然后根据地图来确定自身的位置、目的地位置,并且也会根据地图显示来规划一条大致的路线… 对于机器人导航而言,也是如此,在机器人导航中地图是一个重要的组成元素,当然如果要使用地图,首先需要绘制地图。关于地图建模技术不断涌现,这其中有一门称之为 SLAM 的理论脱颖而出:

SLAM(simultaneous localization and mapping),也称为CML (Concurrent Mapping and Localization), 即时定位与地图构建,或并发建图与定位。SLAM问题可以描述为: 机器人在未知环境中从一个未知位置开始移动,在移动过程中根据位置估计和地图进行自身定位,同时在自身定位的基础上建造增量式地图,以绘制出外部环境的完全地图。

在 ROS 中,较为常用的 SLAM 实现也比较多,比如: gmapping、hector_slam、cartographer、rgbdslam、ORB_SLAM …

当然如果要完成 SLAM ,机器人必须要具备感知外界环境的能力,尤其是要具备获取周围环境深度信息的能力。感知的实现需要依赖于传感器,比如: 激光雷达、摄像头、RGB-D摄像头…

SLAM 可以用于地图生成,而生成的地图还需要被保存以待后续使用,在 ROS 中保存地图的功能包是 map_server

另外注意: SLAM 虽然是机器人导航的重要技术之一,但是 二者并不等价,确切的讲,SLAM 只是实现地图构建和即时定位。

2.自身定位

导航伊始和导航过程中,机器人都需要确定当前自身的位置,如果在室外,那么 GPS 是一个不错的选择,而如果室内、隧道、地下或一些特殊的屏蔽 GPS 信号的区域,由于 GPS 信号弱化甚至完全不可用,那么就必须另辟蹊径了,比如前面的 SLAM 就可以实现自身定位,除此之外,ROS 中还提供了一个用于定位的功能包: amcl

amcl(adaptiveMonteCarloLocalization)自适应的蒙特卡洛定位,是用于2D移动机器人的概率定位系统。它实现了自适应(或KLD采样)蒙特卡洛定位方法,该方法使用粒子过滤器根据已知地图跟踪机器人的姿态。

3.路径规划

导航就是机器人从A点运动至B点的过程,在这一过程中,机器人需要根据目标位置计算全局运动路线,并且在运动过程中,还需要时时根据出现的一些动态障碍物调整运动路线,直至到达目标点,该过程就称之为路径规划。在 ROS 中提供了 move_base 包来实现路径规则,该功能包主要由两大规划器组成:

全局路径规划(gloable_planner)

根据给定的目标点和全局地图实现总体的路径规划,使用 Dijkstra 或 A* 算法进行全局路径规划,计算最优路线,作为全局路线

本地时时规划(local_planner)

在实际导航过程中,机器人可能无法按照给定的全局最优路线运行,比如:机器人在运行中,可能会随时出现一定的障碍物… 本地规划的作用就是使用一定算法(Dynamic Window Approaches) 来实现障碍物的规避,并选取当前最优路径以尽量符合全局最优路径

全局路径规划与本地路径规划是相对的,全局路径规划侧重于全局、宏观实现,而本地路径规划侧重与当前、微观实现。

4.运动控制

导航功能包集假定它可以通过话题"cmd_vel"发布geometry_msgs/Twist类型的消息,这个消息基于机器人的基座坐标系,它传递的是运动命令。这意味着必须有一个节点订阅"cmd_vel"话题, 将该话题上的速度命令转换为电机命令并发送。

5.环境感知

感知周围环境信息,比如: 摄像头、激光雷达、编码器…,摄像头、激光雷达可以用于感知外界环境的深度信息,编码器可以感知电机的转速信息,进而可以获取速度信息并生成里程计信息。

在导航功能包集中,环境感知也是一重要模块实现,它为其他模块提供了支持。其他模块诸如: SLAM、amcl、move_base 都需要依赖于环境感知。

7.2 导航实现

本节内容主要介绍导航的完整性实现,旨在掌握机器人导航的基本流程,该章涉及的主要内容如下:

SLAM建图(选用较为常见的gmapping)

地图服务(可以保存和重现地图)

机器人定位

路径规划

上述流程介绍完毕,还会对功能进一步集成实现探索式的SLAM建图。

准备工作

请先安装相关的ROS功能包:

安装 gmapping 包(用于构建地图):sudo apt install ros-<ROS版本>-gmapping

安装地图服务包(用于保存与读取地图):sudo apt install ros-<ROS版本>-map-server

安装 navigation 包(用于定位以及路径规划):sudo apt install ros-<ROS版本>-navigation

新建功能包,并导入依赖: gmapping map_server amcl move_base

7.2.4 导航实现04_路径规划

毋庸置疑的,路径规划是导航中的核心功能之一,在ROS的导航功能包集navigation中提供了 move_base 功能包,用于实现此功能。

1、move_base简介

move_base 功能包提供了基于动作(action)的路径规划实现,move_base 可以根据给定的目标点,控制机器人底盘运动至目标位置,并且在运动过程中会连续反馈机器人自身的姿态与目标点的状态信息。如前所述(7.1)move_base主要由全局路径规划与本地路径规划组成。
在这里插入图片描述

move_base已经被集成到了navigation包,navigation安装前面也有介绍,命令如下:

sudo apt install ros-<ROS版本>-navigation

2、 配置move_base参数

前面介绍配置代价地图相关的参数时就应注意到,我们若配置路径规划参数那么首先就需要先配置一下move_base相关的参数,因为在move_base中有多种路径规划器算法可选,我们需要告诉move_base路径规划器使用哪种算法。一般来说,全局路径的规划插件包括:

·navfn:ROS中比较旧的代码实现了dijkstra和A*全局规划算法。

·global_planner:重新实现了Dijkstra和A*全局规划算法,可以看作navfn的改进版。

·parrot_planner:一种简单的算法实现全局路径规划算法。

局部路径的规划插件包括:

·base_local_planner:实现了Trajectory Rollout和DWA两种局部规划算法。

·dwa_local_planner:实现了DWA局部规划算法,可以看作是base_local_planner的改进版本。

当前上面这些插件只是官方实现的,我们也可以来实现自己的规划算法,以插件的形式包含进move_base,这样就可以来改进这些路径规划算法了。我们可以根据move_base的launch文件来看看也就明白配置哪个文件了:
在这里插入图片描述
move_base_params.yaml,配置文件内容如下:

#FileName: move_base_params.yaml

#Copyright: 2016-2018 ROS小课堂www.corvin.cn

#Author: corvin

#Description:

# move_base软件包的通用配置参数,现在依次解释每个参数意义:

#   shutdown_costmaps:当move_base在不活动状态时,是否关掉costmap.

#   controller_frequency:向底盘控制移动话题cmd_vel发送命令的频率.

#   controller_patience:在空间清理操作执行前,控制器花多长时间等有效控制下发.

#   planner_frequency:全局规划操作的执行频率.如果设置为0.0,则全局规划器仅

#       在接收到新的目标点或者局部规划器报告路径堵塞时才会重新执行规划操作.

#   planner_patience:在空间清理操作执行前,留给规划器多长时间来找出一条有效规划.

#   oscillation_timeout:执行修复机制前,允许振荡的时长.

#   oscillation_distance:来回运动在多大距离以上不会被认为是振荡.

#   base_local_planner:指定用于move_base的局部规划器插件名称.

#   base_global_planner:指定用于move_base的全局规划器插件名称.

#History:

# 20180726: initial this comment.
#
shutdown_costmaps: false

controller_frequency: 5.0
controller_patience: 3.0

planner_frequency: 1.0
planner_patience: 5.0

oscillation_timeout: 8.0
oscillation_distance: 0.3

base_local_planner: "dwa_local_planner/DWAPlannerROS"

base_global_planner: "global_planner/GlobalPlanner"

下面来依次解释下各参数的意义:

·shutdown_costmaps:当move_base在不活动状态时,是否关掉costmap.

·controller_frequency:向底盘控制移动话题cmd_vel发送命令的频率.

·controller_patience:在空间清理操作执行前,控制器花多长时间等有效控制下发.

·planner_frequency:全局规划操作的执行频率.如果设置为0.0,则全局规划器仅在接收到新的目标点或者局部规划器报告路径堵塞时才会重新执行规划操作.

·planner_patience:在空间清理操作执行前,留给规划器多长时间来找出一条有效规划.

·oscillation_timeout:执行修复机制前,允许振荡的时长.

·oscillation_distance:来回运动在多大距离以上不会被认为是振荡.

·base_local_planner:指定用于move_base的局部规划器名称.

·base_global_planner:指定用于move_base的全局规划器插件名称.

3 配置全局路径参数

我们在进行全局路径规划时,需要由外部来告知目标点。同时还需要知道全局代价地图,因为在路径规划时需要避开代价高的危险区域,不然规划的路径就撞到墙上了。

我们这里仍然只需要配置好global_planner规划器的参数即可。我们在stdr_move_base的config目录中创建global_planner_params.yaml文件,文件内容如下:

GlobalPlanner:

  allow_unknown: false

  default_tolerance: 0.2

  visualize_potential: false

  use_dijkstra: true

  use_quadratic: true

  use_grid_path: false

  old_navfn_behavior: false

  lethal_cost: 253
  
  neutral_cost: 50
  
  cost_factor: 3.0
  
  publish_potential: true
  
  orientation_mode: 0
  
  orientation_window_size: 1

下面来依次解释下各参数意义:

allow_unknown:是否允许规划器规划穿过未知区域的路径,只设计该参数为true还不行,还要在costmap_commons_params.yaml中设置track_unknown_space参数也为true才行。

default_tolerance:当设置的目的地被障碍物占据时,需要以该参数为半径寻找到最近的点作为新目的地点.

visualize_potential:是否显示从PointCloud2计算得到的势区域.

use_dijkstra:设置为true,将使用dijkstra算法,否则使用A*算法.

use_quadratic:设置为true,将使用二次函数近似函数,否则使用更加简单的计算方式,这样节省硬件计算资源.

use_grid_path:如果设置为true,则会规划一条沿着网格边界的路径,偏向于直线穿越网格,否则将使用梯度下降算法,路径更为光滑点.

old_navfn_behavior:若在某些情况下,想让global_planner完全复制navfn的功能,那就设置为true,但是需要注意navfn是非常旧的ROS系统中使用的,现在已经都用global_planner代替navfn了,所以不建议设置为true.

lethal_cost:致命代价值,默认是设置为253,可以动态来配置该参数.

neutral_cost:中等代价值,默认设置是50,可以动态配置该参数.

cost_factor:代价地图与每个代价值相乘的因子.

publish_potential:是否发布costmap的势函数.

orientation_mode:如何设置每个点的方向(None = 0,Forward = 1,Interpolate = 2,ForwardThenInterpolate = 3,Backward = 4,Leftward = 5,Rightward = 6)(可动态重新配置)

orientation_window_size:根据orientation_mode指定的位置积分来得到使用窗口的方向.默认值1,可以动态重新配置.

3 、配置局部路径规划参数

局部路径规划参数相当重要,因为它是直接控制机器人的移动底盘运动的插件,它负责来向移动底盘的/cmd_vel话题中发布控制命令。机器人移动的效果好不好,这个局部路径规划可是影响最大的。

在这里我们使用dwa_local_planner,它是一个能够驱动底盘移动的控制器,该控制器连接了路径规划器和机器人.使用地图,规划器产生从起点到目标点的运动轨迹,在移动时,规划器在机器人周围产生一个函数,用网格地图表示。控制器的工作就是利用这个函数来确定发送给机器人的速度dx, dy, dtheta

DWA算法的基本思想

1.在机器人控制空间离散采样(dx, dy, dtheta)

2.对每一个采样的速度进行前向模拟,看看在当前状态下,使用该采样速度移动一小段时间后会发生什么.

3.评价前向模拟得到的每个轨迹,是否接近障碍物,是否接近目标,是否接近全局路径以及速度等等.舍弃非法路径

4.选择得分最高的路径,发送对应的速度给底座

DWA与Trajectory Rollout的区别主要是在机器人的控制空间采样差异.Trajectory Rollout采样点来源于整个前向模拟阶段所有可用速度集合,而DWA采样点仅仅来源于一个模拟步骤中的可用速度集合.这意味着相比之下DWA是一种更加有效算法,因为其使用了更小采样空间;然而对于低加速度的机器人来说可能Trajectory Rollout更好, 因为DWA不能对常加速度做前向模拟。

我们需要在stdr_move_base下的config目录中创建dwa_local_planner_params.yaml文件,该配置文件的内容如下:

DWAPlannerROS:

# Robot Configuration Parameters - stdr robot

  acc_lim_x: 0.3  # maximum is theoretically 2.0

  acc_lim_y: 0.0  # diff drive robot

  acc_lim_th: 0.3

 

  max_trans_vel: 0.3 #choose slightly less than the base's capability

  min_trans_vel: 0.1 #this is the min trans velocity when there is negligible rotational velocity

 

  max_vel_x: 0.3

  min_vel_x: -0.1

  max_vel_y: 0.0  #diff drive robot,don't need set vel_y

  min_vel_y: 0.0

 

  max_rot_vel: 0.5  #choose slightly less than the base's capability

  min_rot_vel: 0.1  #this is the min angular velocity when there is negligible translational velocity

 

# Goal Tolerance Parameters

  yaw_goal_tolerance: 0.1  # 0.1 rad = 5.7 degree

  xy_goal_tolerance: 0.12

  latch_xy_goal_tolerance: false


# Forward Simulation Parameters

  sim_time: 2.0    # 1.7

  sim_granularity: 0.025

  vx_samples: 6    # default 3

  vy_samples: 1    # diff drive robot, there is only one sample

  vth_samples: 20  # 20

  controller_frequency: 5.0

 

# Trajectory Scoring Parameters

  path_distance_bias: 90.0      # 32.0

  goal_distance_bias: 24.0      # 24.0

  occdist_scale: 0.3            # 0.01

  forward_point_distance: 0.325 # 0.325

  stop_time_buffer: 0.2         # 0.2

  scaling_speed: 0.20           # 0.25

  max_scaling_factor: 0.2       # 0.2

  publish_cost_grid: false

 

# Oscillation Prevention Parameters

  oscillation_reset_dist: 0.05  # default 0.05


# Global Plan Parameters

  prune_plan: false
  

下面来依次解释下各参数的意义:

acc_lim_x:x方向的加速度绝对值

acc_lim_y:y方向的加速度绝对值,该值只有全向移动的机器人才需配置.

acc_lim_th:旋转加速度的绝对值.

max_trans_vel:平移速度最大值绝对值

min_trans_vel:平移速度最小值的绝对值

max_vel_x:x方向最大速度的绝对值

min_vel_x:x方向最小值绝对值,如果为负值表示可以后退.

max_vel_y:y方向最大速度的绝对值.

min_vel_y:y方向最小速度的绝对值.

max_rot_vel:最大旋转速度的绝对值.

min_rot_vel:最小旋转速度的绝对值.

yaw_goal_tolerance:到达目标点时偏行角允许的误差,单位弧度.

xy_goal_tolerance:到达目标点时,在xy平面内与目标点的距离误差.

latch_xy_goal_tolerance:设置为true,如果到达容错距离内,机器人就会原地旋转,即使转动是会跑出容错距离外.

sim_time:向前仿真轨迹的时间.

sim_granularity:步长,轨迹上采样点之间的距离,轨迹上点的密集程度.

vx_samples:x方向速度空间的采样点数.

vy_samples:y方向速度空间采样点数.

vth_samples:旋转方向的速度空间采样点数.

controller_frequency:发送给底盘控制移动指令的频率.

path_distance_bias:定义控制器与给定路径接近程度的权重.

goal_distance_bias:定义控制器与局部目标点的接近程度的权重.

occdist_scale:定义控制器躲避障碍物的程度.

stop_time_buffer:为防止碰撞,机器人必须提前停止的时间长度.

scaling_speed:启动机器人底盘的速度.

max_scaling_factor:最大缩放参数.

publish_cost_grid:是否发布规划器在规划路径时的代价网格.如果设置为true,那么就会在~/cost_cloud话题上发布sensor_msgs/PointCloud2类型消息.

oscillation_reset_dist:机器人运动多远距离才会重置振荡标记.

prune_plan:机器人前进是是否清除身后1m外的轨迹

move_base参数(二)

7.2.5 move_base参数(二)

本文分析move base 的配置文件,从配置文件设置的角度,可以更清晰的把握move base对于costmap2D,global planner,local planner的调用关系。
这里采用turtlebot_navigation package 为例:

<launch>
  <include file="$(find turtlebot_navigation)/launch/includes/velocity_smoother.launch.xml"/>
  <include file="$(find turtlebot_navigation)/launch/includes/safety_controller.launch.xml"/>

  <arg name="odom_frame_id"   default="odom"/>
  <arg name="base_frame_id"   default="base_footprint"/>
  <arg name="global_frame_id" default="map"/>
  <arg name="odom_topic" default="odom" />
  <arg name="laser_topic" default="scan" />
  <arg name="custom_param_file" default="$(find turtlebot_navigation)/param/dummy.yaml"/>
  <!-- 以下部分是move base调用,需要配置的文件:包括全局地图,局部地图,全局planner,局部planner -->
  <node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen">
    <rosparam file="$(find turtlebot_navigation)/param/costmap_common_params.yaml" command="load" ns="global_costmap" />
    <rosparam file="$(find turtlebot_navigation)/param/costmap_common_params.yaml" command="load" ns="local_costmap" />   
    <rosparam file="$(find turtlebot_navigation)/param/local_costmap_params.yaml" command="load" />   
    <rosparam file="$(find turtlebot_navigation)/param/global_costmap_params.yaml" command="load" />
    <rosparam file="$(find turtlebot_navigation)/param/dwa_local_planner_params.yaml" command="load" />
    <rosparam file="$(find turtlebot_navigation)/param/move_base_params.yaml" command="load" />
    <rosparam file="$(find turtlebot_navigation)/param/global_planner_params.yaml" command="load" />
    <rosparam file="$(find turtlebot_navigation)/param/navfn_global_planner_params.yaml" command="load" />
    <!-- external params file that could be loaded into the move_base namespace -->
    <rosparam file="$(arg custom_param_file)" command="load" />

    <!-- reset frame_id parameters using user input data -->
    <param name="global_costmap/global_frame" value="$(arg global_frame_id)"/>
    <param name="global_costmap/robot_base_frame" value="$(arg base_frame_id)"/>
    <param name="local_costmap/global_frame" value="$(arg odom_frame_id)"/>
    <param name="local_costmap/robot_base_frame" value="$(arg base_frame_id)"/>
    <param name="DWAPlannerROS/global_frame_id" value="$(arg odom_frame_id)"/>

    <remap from="cmd_vel" to="navigation_velocity_smoother/raw_cmd_vel"/>
    <remap from="odom" to="$(arg odom_topic)"/>
    <remap from="scan" to="$(arg laser_topic)"/>
  </node>
</launch>

从上面的配置上来可以看到以下内容,这些都是关于地图的配置:

/param/costmap_common_params.yaml" command=“load” ns=“global_costmap”
/param/costmap_common_params.yaml" command=“load” ns=“local_costmap”
/param/local_costmap_params.yaml" command=“load”
/param/global_costmap_params.yaml" command=“load”

地图配置,首先是采用了一个costmap_common_params.yaml文件配置了一些公共的参数:

max_obstacle_height: 0.60  # assume something like an arm is mounted on top of the robot

# Obstacle Cost Shaping (http://wiki.ros.org/costmap_2d/hydro/inflation)
robot_radius: 0.20  # distance a circular robot should be clear of the obstacle (kobuki: 0.18)
# footprint: [[x0, y0], [x1, y1], ... [xn, yn]]  # if the robot is not circular

map_type: voxel

obstacle_layer:
  enabled:              true
  max_obstacle_height:  0.6
  origin_z:             0.0
  z_resolution:         0.2
  z_voxels:             2
  unknown_threshold:    15
  mark_threshold:       0
  combination_method:   1
  track_unknown_space:  true    #true needed for disabling global path planning through unknown space
  obstacle_range: 2.5
  raytrace_range: 3.0
  origin_z: 0.0
  z_resolution: 0.2
  z_voxels: 2
  publish_voxel_map: false
  observation_sources:  scan bump
  scan:
    data_type: LaserScan
    topic: scan
    marking: true
    clearing: true
    min_obstacle_height: 0.25
    max_obstacle_height: 0.35
  bump:
    data_type: PointCloud2
    topic: mobile_base/sensors/bumper_pointcloud
    marking: true
    clearing: false
    min_obstacle_height: 0.0
    max_obstacle_height: 0.15
  # for debugging only, let's you see the entire voxel grid

#cost_scaling_factor and inflation_radius were now moved to the inflation_layer ns
inflation_layer:
  enabled:              true
  cost_scaling_factor:  5.0  # exponential rate at which the obstacle cost drops off (default: 10)
  inflation_radius:     0.5  # max. distance from an obstacle at which costs are incurred for planning paths.

static_layer:
  enabled:              true

然后分别设定global map 和local map:

global_costmap:
   global_frame: /map
   robot_base_frame: /base_footprint
   update_frequency: 1.0
   publish_frequency: 0.5
   static_map: true
   transform_tolerance: 0.5
   <!-- global map引入了以下三层,经融合构成了master map,用于global planner-->
   plugins:
     - {name: static_layer,            type: "costmap_2d::StaticLayer"}
     - {name: obstacle_layer,          type: "costmap_2d::VoxelLayer"}
     - {name: inflation_layer,         type: "costmap_2d::InflationLayer"}
local_costmap:
   global_frame: odom
   robot_base_frame: /base_footprint
   update_frequency: 5.0
   publish_frequency: 2.0
   static_map: false
   rolling_window: true
   width: 4.0
   height: 4.0
   resolution: 0.05
   transform_tolerance: 0.5
   <!-- local map引入了以下两层,经融合构成了master map,用于局部planner-->
   plugins:
    - {name: obstacle_layer,      type: "costmap_2d::VoxelLayer"}
    - {name: inflation_layer,     type: "costmap_2d::InflationLayer"}

然后是planner的配置:

/param/move_base_params.yaml" command=“load”

/param/global_planner_params.yaml" command=“load”
/param/navfn_global_planner_params.yaml" command=“load”

/param/dwa_local_planner_params.yaml" command=“load”

文件move_base_params.yaml 内容

shutdown_costmaps: false

controller_frequency: 5.0
controller_patience: 3.0


planner_frequency: 1.0
planner_patience: 5.0

oscillation_timeout: 10.0
oscillation_distance: 0.2

# local planner - default is trajectory rollout
base_local_planner: "dwa_local_planner/DWAPlannerROS"
<!--这里配置了local planner为dwa_local_planner -->
<!--这里配置了global planner为navfn/NavfnROS -->
base_global_planner: "navfn/NavfnROS" #alternatives: global_planner/GlobalPlanner, carrot_planner/CarrotPlanner

对于global planner,可以采用以下三种实现之一:

“navfn/NavfnROS”,“global_planner/GlobalPlanner”,“carrot_planner/CarrotPlanner”

然后来看global planner的配置:

GlobalPlanner:                                  # Also see: http://wiki.ros.org/global_planner
  old_navfn_behavior: false                     # Exactly mirror behavior of navfn, use defaults for other boolean parameters, default false
  use_quadratic: true                           # Use the quadratic approximation of the potential. Otherwise, use a simpler calculation, default true
  use_dijkstra: true                            # Use dijkstra's algorithm. Otherwise, A*, default true
  use_grid_path: false                          # Create a path that follows the grid boundaries. Otherwise, use a gradient descent method, default false

  allow_unknown: true                           # Allow planner to plan through unknown space, default true
                                                #Needs to have track_unknown_space: true in the obstacle / voxel layer (in costmap_commons_param) to work
  planner_window_x: 0.0                         # default 0.0
  planner_window_y: 0.0                         # default 0.0
  default_tolerance: 0.0                        # If goal in obstacle, plan to the closest point in radius default_tolerance, default 0.0

  publish_scale: 100                            # Scale by which the published potential gets multiplied, default 100
  planner_costmap_publish_frequency: 0.0        # default 0.0

  lethal_cost: 253                              # default 253
  neutral_cost: 50                              # default 50
  cost_factor: 3.0                              # Factor to multiply each cost from costmap by, default 3.0
  publish_potential: true                       # Publish Potential Costmap (this is not like the navfn pointcloud2 potential), default true

对于local planner ,有以下两种选择:

“trajectory rollout”,“dwa_local_planner/DWAPlannerROS”

以下配置了DWAPlannerROS :

DWAPlannerROS:

# Robot Configuration Parameters - Kobuki
  max_vel_x: 0.5  # 0.55
  min_vel_x: 0.0

  max_vel_y: 0.0  # diff drive robot
  min_vel_y: 0.0  # diff drive robot

  max_trans_vel: 0.5 # choose slightly less than the base's capability
  min_trans_vel: 0.1  # this is the min trans velocity when there is negligible rotational velocity
  trans_stopped_vel: 0.1

  # Warning!
  #   do not set min_trans_vel to 0.0 otherwise dwa will always think translational velocities
  #   are non-negligible and small in place rotational velocities will be created.

  max_rot_vel: 5.0  # choose slightly less than the base's capability
  min_rot_vel: 0.4  # this is the min angular velocity when there is negligible translational velocity
  rot_stopped_vel: 0.4

  acc_lim_x: 1.0 # maximum is theoretically 2.0, but we
  acc_lim_theta: 2.0
  acc_lim_y: 0.0      # diff drive robot

# Goal Tolerance Parameters
  yaw_goal_tolerance: 0.3  # 0.05
  xy_goal_tolerance: 0.15  # 0.10
  # latch_xy_goal_tolerance: false

# Forward Simulation Parameters
  sim_time: 1.0       # 1.7
  vx_samples: 6       # 3
  vy_samples: 1       # diff drive robot, there is only one sample
  vtheta_samples: 20  # 20

# Trajectory Scoring Parameters
  path_distance_bias: 64.0      # 32.0   - weighting for how much it should stick to the global path plan
  goal_distance_bias: 24.0      # 24.0   - wighting for how much it should attempt to reach its goal
  occdist_scale: 0.5            # 0.01   - weighting for how much the controller should avoid obstacles
  forward_point_distance: 0.325 # 0.325  - how far along to place an additional scoring point
  stop_time_buffer: 0.2         # 0.2    - amount of time a robot must stop in before colliding for a valid traj.
  scaling_speed: 0.25           # 0.25   - absolute velocity at which to start scaling the robot's footprint
  max_scaling_factor: 0.2       # 0.2    - how much to scale the robot's footprint when at speed.

# Oscillation Prevention Parameters
  oscillation_reset_dist: 0.05  # 0.05   - how far to travel before resetting oscillation flags

# Debugging
  publish_traj_pc : true
  publish_cost_grid_pc: true
  global_frame_id: odom


# Differential-drive robot configuration - necessary?
#  holonomic_robot: false

7.2.6 ROS SLAM 导航参数配置日常总结

move_base,主要包含cost_map、planner,其中 cost_map 又包含了

local_cost_map、global_cost_map, planner 又包含,local_planner、global_planner

local_planner: 是本地躲避障碍物的路径规划。

global_planner:是全局路径规划。

相关专业名词解释

1.max_trans_vel:最大平移速度限定值

max_rot_vel min_rot_vel 旋转的速度限定值

acc_lim_x acc_lim_theta(消耗时间) acc_lim_y 加速度限定值


路径规划(local_planner、global_planner):

1.base_global_planner:全局路径规划

2.base_local_planner:局部路径规划

3.planner_frequency:算路频率,全局规划操作的执行频率.如果设置为0.0,则全局规划器仅

在接收到新的目标点或者局部规划器报告路径堵塞时才会重新执行规划操作.

4.controller_frequency:向底盘控制移动话题cmd_vel发送命令的频率.

5.planner_patience:规划路径最大容忍时间

6.controller_patience:在空间清理操作执行前,控制器花多长时间等有效控制下发

7.max_planning_retries:最大规划路径的重复次数,-1表示无限次

8.conservative_reset_dist:清除机制的参数,决定清除多远处的障碍

9.recovery_behavior_enabled:是否启动恢复机制

10.clearing_rotation_allowed:是否启动旋转的恢复,必须是9在使能的基础上才能、

生效

11.shutdown_costmaps:当move_base bu 不在活动的状态下是否需要关闭move_base node

的costmap(是laser将扫描的数据转换为2D网格地图)

12.oscillation_timeout:震荡超时,超过则底层进行异常处理

13.oscillation_distance:震荡距离

14.restor_defaults:恢复默认值


base_local_planner: 本地规划器base_local_planner的主要作用是根据规划的全局路径,计算发布给机器人的速度指令

controller_frequency:更新规划的频率,建议3~5

max_vel_x:最大线速度,单位m/s。Create的turtlebot限制速度为0.5m/s,一般建议室内在0.3m/s以内。

min_vel_x:最小线速度,单位同上。

max_vel_y,min_vel_y:不知道是什么速度,官方解释差速轮驱动这两个值为0。个人理解应该对于两个差速轮,只有x方向的一个线速度。而像麦克纳姆轮多个轮,可以有y方向的线速度

max_vel_theta: 最大角速度,单位rad/s。这个值不要设置太高。默认1.0rad/s。

min_vel_theta:最小角速度,单位rad/s。默认-1.0rad/s。(上面两个速度我的rbx1包中竟然没有)

min_in_place_vel_theta:原地旋转角速度的最小值,单位rad/s,默认0.5rad/s。

escape_vel:逃逸速度,单位m/s默认-0.1m/s。为什么叫逃逸速度呢?反正这个速度是反转,姑且算是‘逃逸’速度吧。

acc_lim_x:x方向的最大线速度的加速度,单位m/s2。默认2.5m/s2。

acc_lim_y:同上,只是y方向的加速度。故对于两轮差速驱动,该值为0。

acc_lim_theta:角速度加速度限值,单位rad/s2。默认为3.2rad/s2。

holonomic_robot:全方向机器人。对于两轮差速,该值为false。

yaw_goal_tolerance:允许机器人缩到目标的方向(弧度)偏差,该值设置小可能导致机器人接近目标振荡。默认为0.1。

xy_goal_tolerance:允许机器人所到目标的坐标(以米为单位)偏差,该值过小可能导致机器人在目标位置附近不断调整到精确的目标位置。默认为0.1。

latch_xy_goal_tolerance:目标坐标偏差锁存,如果上锁,机器人到达过坐标后只进行简单的方向调整,即使在公差外。默认为false。

pdist_scale:(path distance)地图单元格的路径距离系数,默认为0.6。决定有多接近路径。

gdist_scale:(goal distance)地图单元格两点距离的系数,默认为0.6。决定有多接近局部目标。

occdist_scale:沿障碍物轨迹最大距离系数

cost = pdist_scale * (distance to path from the endpoint of the trajectory in map cells or meters depending on the meter_scoring parameter) + gdist_scale * (distance to local goal from the endpoint of the trajectory in map cells or meters depending on the meter_scoring parameter) + occdist_scale * (maximum obstacle cost along the trajectory in obstacle cost (0-254))

meter_scoring: true 以米为单位

heading_lookahead:原地旋转时向前看多少米,默认0.35

heading_scoring: 通过机器人航向计算还是通过路径计算距离,默认false heading_scoring_timestep: 航向计算距离时,沿着模拟轨迹向前看的时间,默认0.8

occdist_scale:控制器应该避开障碍物的的轻易程度,默认0.1

oscillation_reset_dist: 在振荡标志被清零前,机器人必须在出行多远。默认0.05.

publish_cost_grid_pc:是否使用cost_grid发布。如果为true,在/ cost_cloud话题生成sensor_msgs/ PointCloud2。

prune_plan: 设置为true,机器人行走1m后,结束动作。

sim_time: 模拟轨迹的时间,默认1.0s

sim_granularity: 给定轨迹的步长,默认0.025米

angular_sim_granularity: 给定角度轨迹的弧长,默认0.025弧度

vx_samples: x方向速度的样本数,默认为8

vy_samples: y方向速度的样本数,两轮差速为0.

vtheta_samples: 角速度的样本数,默认为20

dwa:是否使用动态窗口方法(DWA),或者是否使用轨迹。默认为true

simple_attractor: false 不知道是什么作用

7.3导航相关消息

7.3.1导航之地图

地图相关的消息主要有两个:
nav_msgs/MapMetaData
地图元数据,包括地图的宽度、高度、分辨率等。
nav_msgs/OccupancyGrid
地图栅格数据,一般会在rviz中以图形化的方式显示。

1.nav_msgs/MapMetaData

调用rosmsg info nav_msgs/MapMetaData显示消息内容如下:

time map_load_time
float32 resolution #地图分辨率
uint32 width #地图宽度
uint32 height #地图高度
geometry_msgs/Pose origin #地图位姿数据
  geometry_msgs/Point position
    float64 x
    float64 y
    float64 z
  geometry_msgs/Quaternion orientation
    float64 x
    float64 y
    float64 z
    float64 w
2.nav_msgs/OccupancyGrid

调用 rosmsg info nav_msgs/OccupancyGrid显示消息内容如下:

std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
#--- 地图元数据
nav_msgs/MapMetaData info
  time map_load_time
  float32 resolution
  uint32 width
  uint32 height
  geometry_msgs/Pose origin
    geometry_msgs/Point position
      float64 x
      float64 y
      float64 z
    geometry_msgs/Quaternion orientation
      float64 x
      float64 y
      float64 z
      float64 w
#--- 地图内容数据,数组长度 = width * height
int8[] data

7.3.2 导航之里程计

里程计相关消息是:nav_msgs/Odometry,调用rosmsg info nav_msgs/Odometry 显示消息内容如下:

std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
string child_frame_id
geometry_msgs/PoseWithCovariance pose
  geometry_msgs/Pose pose #里程计位姿
    geometry_msgs/Point position
      float64 x
      float64 y
      float64 z
    geometry_msgs/Quaternion orientation
      float64 x
      float64 y
      float64 z
      float64 w
  float64[36] covariance
geometry_msgs/TwistWithCovariance twist
  geometry_msgs/Twist twist #速度
    geometry_msgs/Vector3 linear
      float64 x
      float64 y
      float64 z
    geometry_msgs/Vector3 angular
      float64 x
      float64 y
      float64 z    
  # 协方差矩阵
  float64[36] covariance

7.3.3 导航之坐标变换

坐标变换相关消息是: tf/tfMessage,调用rosmsg info tf/tfMessage 显示消息内容如下:

geometry_msgs/TransformStamped[] transforms #包含了多个坐标系相对关系数据的数组
  std_msgs/Header header
    uint32 seq
    time stamp
    string frame_id
  string child_frame_id
  geometry_msgs/Transform transform
    geometry_msgs/Vector3 translation
      float64 x
      float64 y
      float64 z
    geometry_msgs/Quaternion rotation
      float64 x
      float64 y
      float64 z
      float64 w

7.3.4 导航之定位

定位相关消息是:geometry_msgs/PoseArray,调用rosmsg info geometry_msgs/PoseArray显示消息内容如下:

std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
geometry_msgs/Pose[] poses #预估的点位姿组成的数组
  geometry_msgs/Point position
    float64 x
    float64 y
    float64 z
  geometry_msgs/Quaternion orientation
    float64 x
    float64 y
    float64 z
    float64 w

7.3.5 导航之目标点与路径规划

目标点相关消息是:move_base_msgs/MoveBaseActionGoal,调用rosmsg info move_base_msgs/MoveBaseActionGoal显示消息内容如下:

std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
actionlib_msgs/GoalID goal_id
  time stamp
  string id
move_base_msgs/MoveBaseGoal goal
  geometry_msgs/PoseStamped target_pose
    std_msgs/Header header
      uint32 seq
      time stamp
      string frame_id
    geometry_msgs/Pose pose #目标点位姿
      geometry_msgs/Point position
        float64 x
        float64 y
        float64 z
      geometry_msgs/Quaternion orientation
        float64 x
        float64 y
        float64 z
        float64 w

路径规划相关消息是:nav_msgs/Path,调用rosmsg info nav_msgs/Path显示消息内容如下:

std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
geometry_msgs/PoseStamped[] poses #由一系列点组成的数组
  std_msgs/Header header
    uint32 seq
    time stamp
    string frame_id
  geometry_msgs/Pose pose
    geometry_msgs/Point position
      float64 x
      float64 y
      float64 z
    geometry_msgs/Quaternion orientation
      float64 x
      float64 y
      float64 z
      float64 w

7.3.6 导航之激光雷达

激光雷达相关消息是:sensor_msgs/LaserScan,调用rosmsg info sensor_msgs/LaserScan显示消息内容如下:

std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
float32 angle_min #起始扫描角度(rad)
float32 angle_max #终止扫描角度(rad)
float32 angle_increment #测量值之间的角距离(rad)
float32 time_increment #测量间隔时间(s)
float32 scan_time #扫描间隔时间(s)
float32 range_min #最小有效距离值(m)
float32 range_max #最大有效距离值(m)
float32[] ranges #一个周期的扫描数据
float32[] intensities #扫描强度数据,如果设备不支持强度数据,该数组为空

7.3.7 导航之相机

深度相机相关消息有:sensor_msgs/Image、sensor_msgs/CompressedImage、sensor_msgs/PointCloud2

sensor_msgs/Image 对应的一般的图像数据,sensor_msgs/CompressedImage 对应压缩后的图像数据,sensor_msgs/PointCloud2 对应的是点云数据(带有深度信息的图像数据)。

调用rosmsg info sensor_msgs/Image显示消息内容如下:

std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
uint32 height #高度
uint32 width  #宽度
string encoding #编码格式:RGBYUV等
uint8 is_bigendian #图像大小端存储模式
uint32 step #一行图像数据的字节数,作为步进参数
uint8[] data #图像数据,长度等于 step * height

调用rosmsg info sensor_msgs/CompressedImage显示消息内容如下:

std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
string format #压缩编码格式(jpeg、png、bmp)
uint8[] data #压缩后的数据

调用rosmsg info sensor_msgs/PointCloud2显示消息内容如下:

std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
uint32 height #高度
uint32 width  #宽度
sensor_msgs/PointField[] fields #每个点的数据类型
  uint8 INT8=1
  uint8 UINT8=2
  uint8 INT16=3
  uint8 UINT16=4
  uint8 INT32=5
  uint8 UINT32=6
  uint8 FLOAT32=7
  uint8 FLOAT64=8
  string name
  uint32 offset
  uint8 datatype
  uint32 count
bool is_bigendian #图像大小端存储模式
uint32 point_step #单点的数据字节步长
uint32 row_step   #一行数据的字节步长
uint8[] data      #存储点云的数组,总长度为 row_step * height
bool is_dense     #是否有无效点

8 dwa_planner vs. base_local_planner

The dwa_local_planner supports velocity constraints specified in x,y, and theta while the base_local_planner only supports constraints specified in x and theta. There is some support for y velocities, but users are limited to a pre-specified list of valid y velocity commands. This makes the dwa_local_planner a better choice for robots that are holonomic or pseudo-holonomic because it allows for better sampling of the velocity space.

The dwa_local_planner is essentially a re-write of the base_local_planner’s DWA (Dynamic Window Approach) option. The code is, in my opinion, a lot cleaner and easier to understand, particularly in the way that trajectories are simulated. I believe that much of the overlapping code between the two packages is factored out and shared. However, its true that there is some more work that could be done to pull out common functionality. For applications that use the DWA approach for local planning, the dwa_local_planner is probaly the best choice.

Robots with low acceleration limits may wish to use Trajectory Rollout over DWA. This option is only available through the base_local_planner package. Documentation on the differences between Trajectory Rollout and DWA is available here.

Both the base_local_planner and dwa_local_planner packages are actively maintained and stable though no new features are planned for either at the moment. As of the electric release, both planners can be tuned via dynamic_reconfigure.

linkComments
Does this remain true? Both maintained.

“The groovy release of ROS includes a new implementation of the dwa_local_planner package. The implementation attempts to be more modular, to allow easier creation of custom local planners while reusing a lot of code.” http://wiki.ros.org/base_local_planne

  • 5
    点赞
  • 49
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cyb_cqu

您的鼓励,是我持续创作的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值