将Kinetic中的原生Gazebo 7升为Gazebo 9

  • Post author:
  • Post category:其他

前言

在使用默认UR包时,由三个报错,其中两个是Gazebo版本太低造成的。因此,需要对此升级。
Kinetic中的默认Gazebo都是版本7.x。因此,写下如何将其升为9.x

报错1

[ERROR] [1584964832.924015441, 0.161000000]: GazeboRosControlPlugin missing <legacyModeNS> while using DefaultRobotHWSim, defaults to true.
This setting assumes you have an old package with an old implementation of DefaultRobotHWSim, where the robotNamespace is disregarded and absolute paths are used instead.
If you do not want to fix this issue in an old package just set <legacyModeNS> to true.

这个问题的解决方法,一种是在ur_description/urdf下的common.gazebo.xacro中添加标签。另一个,自然就是升级gazebo.

<?xml version="1.0"?>
<robot xmlns:xacro="http://wiki.ros.org/xacro">
  <gazebo>
    <plugin name="ros_control" filename="libgazebo_ros_control.so">
      <!--robotNamespace>/</robotNamespace-->
      <!--robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType-->
      <legacyModeNS>true</legacyModeNS>
    </plugin>
  </gazebo>
</robot>

报错2

[ INFO] [1584964832.925555429, 0.161000000]: gazebo_ros_control plugin is waiting for model URDF in parameter [robot_description] on the ROS param server.
[ERROR] [1584964833.035989044, 0.161000000]: No p gain specified for pid.  Namespace: /gazebo_ros_control/pid_gains/shoulder_pan_joint
[ERROR] [1584964833.037210922, 0.161000000]: No p gain specified for pid.  Namespace: /gazebo_ros_control/pid_gains/shoulder_lift_joint
[ERROR] [1584964833.038284477, 0.161000000]: No p gain specified for pid.  Namespace: /gazebo_ros_control/pid_gains/elbow_joint
[ERROR] [1584964833.039154456, 0.161000000]: No p gain specified for pid.  Namespace: /gazebo_ros_control/pid_gains/wrist_1_joint
[ERROR] [1584964833.040023898, 0.161000000]: No p gain specified for pid.  Namespace: /gazebo_ros_control/pid_gains/wrist_2_joint
[ERROR] [1584964833.040943284, 0.161000000]: No p gain specified for pid.  Namespace: /gazebo_ros_control/pid_gains/wrist_3_joint

缺少关节控制参数,目前还对我还没有啥影响,就仅记录一下。
可能的解决方法参考:
链接1
链接2
链接3
链接4
链接5

报错3

[ INFO] [1584964833.045408629, 0.161000000]: Loaded gazebo_ros_control.
[ WARN] [1584964833.045570601, 0.162000000]: The default_robot_hw_sim plugin is using the Joint::SetPosition method without preserving the link velocity.
[ WARN] [1584964833.045597261, 0.162000000]: As a result, gravity will not be simulated correctly for your model.
[ WARN] [1584964833.045614699, 0.162000000]: Please set gazebo_pid parameters, switch to the VelocityJointInterface or EffortJointInterface, or upgrade to Gazebo 9.
[ WARN] [1584964833.045629097, 0.162000000]: For details, see https://github.com/ros-simulation/gazebo_ros_pkgs/issues/612

升级方法

首先需要说明一下,Kinetic版本默认安装的都是7.x的Gazebo参考

ROS Kinetic hosts or use the 7.x version of Gazebo. For a fully-integrated ROS system, we recommend using the 7.x version of Gazebo. The way to proceed is just to use the ROS repository (it will automatically install gazebo7) and do not use the osrfoundation repository.

因此,需要手动对其进行升级,主要参考

$ sudo apt-get remove ros-kinetic-gazebo*
$ sudo apt-get remove libgazebo*
$ sudo apt-get remove gazebo*

$ sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" /etc/apt/sources.list.d/gazebo-stable.list'
$ wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -

$ sudo apt-get update

$ sudo apt-get install ros-kinetic-gazebo9-*

# test
$ gazebo

关于手动添加软件源

我在进行安装的时候,提示

E: 无法定位软件包 ros-kinetic-gazebo9-* 
E: 无法按照 glob ‘ros-kinetic-gazebo9-*’ 找到任何软件包 
E: 无法按照正则表达式 ros-kinetic-gazebo9-* 找到任何软件包

搞了半天,终于确定是软件源的问题。也就是执行下面这句话有问题,没有创建相应文件。

sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" /etc/apt/sources.list.d/gazebo-stable.list'

方法是,手动创建/etc/apt/sources.list.d/gazebo-stable.list,并写入

deb http://packages.osrfoundation.org/gazebo/ubuntu-stable xenial main 

版权声明:本文为weixin_42268975原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。