turtlebot3中没有使用速度平滑,但是本人在用turtlebot3跑导航时会出现急停的现象,所以为了解决这个问题,本人在turtlebot3中添加速度平滑处理功能
以下是本人的相关代码及设置
velocity_smoother.launch.xml 文件(按照官网的文件写的,注意文件路径)
<launch>
<arg name="node_name" default="velocity_smoother"/>
<arg name="nodelet_manager_name" default="nodelet_manager"/>
<arg name="config_file" default="$(find turtlebot3_navigation)/param/standalone.yaml"/>
<arg name="raw_cmd_vel_topic" default="raw_cmd_vel"/>
<arg name="smooth_cmd_vel_topic" default="smooth_cmd_vel"/>
<arg name="robot_cmd_vel_topic" default="robot_cmd_vel"/>
<arg name="odom_topic" default="odom"/>
<node pkg="nodelet" type="nodelet" name="$(arg node_name)"
args="load yocs_velocity_smoother/VelocitySmootherNodelet $(arg nodelet_manager_name)">
<!-- parameters -->
<rosparam file="$(arg config_file)" command="load"/>
<!-- velocity commands I/O -->
<remap from="$(arg node_name)/raw_cmd_vel" to="$(arg raw_cmd_vel_topic)"/>
<remap from="$(arg node_name)/smooth_cmd_vel" to="$(arg smooth_cmd_vel_topic)"/>
<!-- Robot velocity feedbacks -->
<remap from="$(arg node_name)/robot_cmd_vel" to="$(arg robot_cmd_vel_topic)"/>
<remap from="$(arg node_name)/odometry" to="$(arg odom_topic)"/>
</node>
</launch>
smoothrt.yaml 文件(文件存放位置要和上面 .xml 文件里面的路径相同:turtlebot3_navigation/param/standalone.yaml):
# Default parameters used by the yocs_velocity_smoother module.
# This isn't used by minimal.launch per se, rather by everything
# which runs on top.
# Mandatory parameters
speed_lim_v: 0.8
speed_lim_w: 5.4
accel_lim_v: 1.0 # maximum is actually 2.0, but we push it down to be smooth
accel_lim_w: 2.0
# Optional parameters
frequency: 20.0
decel_factor: 1.5
# Robot velocity feedback type:
# 0 - none (default)
# 1 - odometry
# 2 - end robot commands
robot_feedback: 0
在turtlebot3 的启动文件(turtlebot3_robot.launch)加入这句话(velocity_smoother.launch.xml文件路径要和下面的一样,不一样自己改)
<include file="$(find turtlebot_navigation)/launch/includes/velocity_smoother.launch.xml"/>
意思是在启动turtlebot3时启动速度平滑功能
下面是smoothrt.yaml里面参数意思
~accel_lim_v (double):强制必须设置,线性加速度最大值
~accel_lim_w (double):强制必须设置,角加速度最大值
~speed_lim_v (double):强制必须设置,线速度最大值
~speed_lim_w (double):强制必须设置,角速度最大值
~decel_factor (double, default: 1.0):加减速比,对于惯性大的机器人
~frequency (double, default: 20.0):输出速度频率。不论输入命令的频率。必要时插值
~robot_feedback (int, default: 0):速度反馈(0 - none, 1 - odometry, 2 - end robot commands).
虽然用了速度平滑,但是效果还是不太好。