ROS学习笔记之——ROS与gazebo之间的控制关系

82 篇文章 117 订阅

之前博客《学习笔记之——gazebo仿真》有采用用ricz来监控gazebo中的机器人。本博文对其进行深入的介绍。

本文以《 ROS学习笔记之——gazebo模型(URDF)》中的RRBot为例。

 

目录

ros_control package

ROS与gazebo之间的连接

 transmission elements to a URDF

Add the gazebo_ros_control plugin

Create a ros_controls package

使用rviz来监控机器人

参考资料


 

ros_control package

https://wiki.ros.org/ros_control

The ros_control packages are a rewrite of the pr2_mechanism packages to make controllers generic to all robots beyond just the PR2.

ros_control packages从机器人执行器的编码器和输入设定点获取关节状态数据作为输入。它使用一个通用的控制回路反馈机制,通常是一个PID控制器,来控制发送到执行器的输出,通常是作用力。ros_control packages对于没有一对一的联合位置、工作等映射的物理机制变得更加复杂,但是这些场景是使用传输来解释的。

 

ROS与gazebo之间的连接

An overview of the relationship between simulation, hardware, controllers and transmissions is shown below:

其实gazebo与ROS的关键跟ROS跟硬件设备的关系是类似的。

 

 transmission elements to a URDF

To use ros_control with your robot, you need to add some additional elements to your URDF. The <transmission> element is used to link actuators (连接执行器) to joints, see the <transmission> spec for exact XML format.

For the purposes of gazebo_ros_control in its current implementation, the only important information in these transmission tags are:

  • <joint name=""> - the name must correspond to a joint else where in your URDF
  • <type> - the type of transmission. Currently only "transmission_interface/SimpleTransmission" is implemented. (feel free to add more)
  • <hardwareInterface> - within the <actuator> and <joint> tags, this tells the gazebo_ros_control plugin what hardware interface to load (position, velocity or effort interfaces). Currently only effort interfaces are implemented. (feel free to add more)

The rest of the names and elements are currently ignored.

Add the gazebo_ros_control plugin

In addition to the transmission tags, a Gazebo plugin needs to be added to your URDF that actually parses the transmission tags and loads the appropriate hardware interfaces and controller manager. By default the gazebo_ros_control plugin is very simple, though it is also extensible (可扩展的) via an additional plugin architecture to allow power users to create their own custom robot hardware interfaces between ros_control and Gazebo.

除了传输标签之外,还需要在URDF中添加一个Gazebo插件,该插件可以解析传输标签并加载适当的硬件接口和控制器管理器。

默认情况下,gazebo_ros_control插件非常简单,但它也可以通过附加的插件架构进行扩展,允许超级用户在ros_control和gazebo之间创建自己的自定义机器人硬件接口。

The default plugin XML should be added to your URDF:

<gazebo>
  <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
    <robotNamespace>/MYROBOT</robotNamespace>
  </plugin>
</gazebo>

The gazebo_ros_control <plugin> tag also has the following optional child elements:

  • <robotNamespace>: The ROS namespace to be used for this instance (实例) of the plugin, defaults to robot name in URDF/SDF
  • <controlPeriod>: The period of the controller update (in seconds), defaults to Gazebo's period
  • <robotParam>: The location of the robot_description (URDF) on the parameter server, defaults to '/robot_description'
  • <robotSimType>: The pluginlib name of a custom robot sim interface to be used (see below for more details), defaults to 'DefaultRobotHWSim'

打开《 ROS学习笔记之——gazebo模型(URDF)》中的rrbot.xacro,在文件的下面会看到以下语句:

  <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>

同时在文件rrbot.gazebo也会看到gazebo_ros_control 插件。如下图所示

  <!-- 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>

Create a ros_controls package

We'll next need to create a configuration file and launch file for our ros_control controllers that interface with Gazebo.

将gazebo与ROS的插件添加完后,需要配置相应的环境来让ROS与gazebo交互。也就是下面这个软件包

mkdir ~/catkin_ws
cd ~/catkin_ws
catkin_create_pkg MYROBOT_control controller_manager joint_state_controller robot_state_publisher
cd MYROBOT_control
mkdir config
mkdir launch

(关于这部分的详细介绍参考http://gazebosim.org/tutorials?tut=ros_control

 

使用rviz来监控机器人

 use Rviz to monitor the state of your simulated robot by publishing /joint_states directly from Gazebo. In the previous example, the RRBot in Rviz is getting its /joint_states from a fake joint_states_publisher node (the window with the slider bars).

rosrun rviz rviz

 

 

参考资料

http://gazebosim.org/tutorials?tut=ros_control

  • 0
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值