学习ROS Control

对着背影说爱祢 提交于 2019-11-28 04:56:04

点此下载源码
参考网页:Tutorial: ROS Control
通过使用控制器驱动机器人的关节,为MoveIt!等规划器提供一个准确的ROS接口。将使用ros_control包。

ros_control 与 Gazebo的数据流图

在Gazebo中进行控制器的仿真,可以利用ros_control和简单的Gazebo插件来实现。各相关组件的关系参考下图

前期准备

参考Using URDF in Gazebo建立一个RRBot机器人模型。
主要教程目录参考如下
这里写图片描述
这里写图片描述

使用

向URDF文件添加传动机构

将驱动器与关节相连接。

<robot>   ...   <transmission name="tran1">     <type>transmission_interface/SimpleTransmission</type>     <joint name="joint1">       <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>     </joint>     <actuator name="motor1">       <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>       <mechanicalReduction>1</mechanicalReduction>     </actuator>   </transmission>    <transmission name="tran2">     <type>transmission_interface/SimpleTransmission</type>     <joint name="joint2">       <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>     </joint>     <actuator name="motor2">       <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>       <mechanicalReduction>1</mechanicalReduction>     </actuator>   </transmission>  </robot>

添加gazebo_ros_control插件

<robot>    <!-- ros_control plugin -->   <gazebo>     <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">       <robotNamespace>/rrbot</robotNamespace>       <robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>     </plugin>   </gazebo>  </robot>

创建.yaml配置文件

rrbot:   # Publish all joint states -----------------------------------   joint_state_controller:     type: joint_state_controller/JointStateController     publish_rate: 50      # Position Controllers ---------------------------------------   joint1_position_controller:     type: effort_controllers/JointPositionController     joint: joint1     pid: {p: 100.0, i: 0.01, d: 10.0}   joint2_position_controller:     type: effort_controllers/JointPositionController     joint: joint2     pid: {p: 100.0, i: 0.01, d: 10.0}

创建启动文件

<launch>    <!-- Load joint controller configurations from YAML file to parameter server -->   <rosparam file="$(find rrbot_control)/config/rrbot_control.yaml" command="load"/>    <!-- load the controllers -->   <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"     output="screen" ns="/rrbot" args="joint1_position_controller joint2_position_controller joint_state_controller"/>    <!-- convert joint states to TF transforms for rviz, etc -->   <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"     respawn="false" output="screen">     <remap from="/joint_states" to="/rrbot/joint_states" />   </node>  </launch>

使用启动文件开启控制器

开始RRBot机器人仿真

roslaunch rrbot_gazebo rrbot_world.launch

加载两关节控制器

roslaunch rrbot_control rrbot_control.launch

使用service手动调用控制器

rosservice call /rrbot/controller_manager/load_controller "name: 'joint1_position_controller'" rosservice call /rrbot/controller_manager/load_controller "name: 'joint2_position_controller'"

启动控制器

rosservice call /rrbot/controller_manager/switch_controller "{start_controllers: ['joint1_position_controller','joint2_position_controller'], stop_controllers: [], strictness: 2}"

停止控制器

rosservice call /rrbot/controller_manager/switch_controller "{start_controllers: [], stop_controllers: ['joint1_position_controller','joint2_position_controller'], strictness: 2}"

手动发送命令

rostopic pub -1 /rrbot/joint1_position_controller/command std_msgs/Float64 "data: 1.5" rostopic pub -1 /rrbot/joint2_position_controller/command std_msgs/Float64 "data: 1.0"

使用rqt工具

rosrun rqt_gui rqt_gui

已经配置好的一个RQT

roslaunch rrbot_control rrbot_rqt.launch

与RVIZ建立连接

rosrun rviz rviz

添加“RobotModel”


这里写图片描述

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!