需求
控制机器人模型在 rviz 中做圆周运动
实现流程
- 安装 Arbotix
- 创建新功能包,准备机器人 urdf、xacro 文件
- 添加 Arbotix 配置文件
- 编写 launch 文件配置 Arbotix
- 启动 launch 文件并控制机器人模型运动
添加 arbotix 所需的配置文件
在urdf01_rviz config中添加control.yaml文件
# 该文件是控制器配置,一个机器人模型可能有多个控制器,比如: 底盘、机械臂、夹持器(机械手)....
# 因此,根 name 是 controller
controllers: {
# 单控制器设置
base_controller: {
#类型: 差速控制器
type: diff_controller,
#参考坐标
base_frame_id: base_footprint,
#两个轮子之间的间距
base_width: 0.2,
#控制频率
ticks_meter: 2000,
#PID控制参数,使机器人车轮快速达到预期速度
Kp: 12,
Kd: 12,
Ki: 0,
Ko: 50,
#加速限制
accel_limit: 1.0
}
}
添加launch文件 demo07_control.launch
<launch>
<!-- 1. 在参数服务器中载入URDF 建议用第二种方式-->
<!-- <param name = "robot_description" textfile = "$(find urdf01_rviz)/urdf/xacro/demo05_car_base.urdf" /> -->
<param name = "robot_description" command = "$(find xacro)/xacro $(find urdf01_rviz)/urdf/xacro/car.urdf.xacro" />
<!-- 2. 启动rviz -->
<node pkg = "rviz" type = "rviz" name = "rviz" args = "-d $(find urdf01_rviz)/config/show_mycar.rviz"/>
<!-- 3. 添加关节状态发布节点 -->
<node pkg = "joint_state_publisher" type = "joint_state_publisher" name = "joint_state_publisher" />
<!-- 4. 添加机器人状态发布节点 -->
<node pkg = "robot_state_publisher" type = "robot_state_publisher" name = "robot_state_publisher" />
<!-- 集成 arbotix 运动控制节点,并且加载参数 第二句表示使用仿真simulator-->
<node pkg = "arbotix_python" type = "arbotix_driver" name = "driver" output = "screen" >
<rosparam command = "load" file = "$(find urdf01_rviz)/config/control.yaml" />
<param name = "sim" value = "true" />
</node>
</launch>
rostopic list
/clicked_point
/cmd_vel
/diagnostics
/initialpose
/joint_states
/move_base_simple/goal
/odom
/rosout
/rosout_agg
/tf
/tf_static
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist “linear:
x: 1.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 1.0”