LoginSignup
4

More than 1 year has passed since last update.

ROS講座88 オムニホイールの簡易シミュレーション

Last updated at Posted at 2018-12-22

環境

この記事は以下の環境で動いています。

項目
CPU Core i5-8250U
Ubuntu 20.04
ROS Noetic
Gazebo 11.9.0

インストールについてはROS講座02 インストールを参照してください。
またこの記事のプログラムはgithubにアップロードされています。ROS講座11 gitリポジトリを参照してください。

概要

これまでにオムニホイールを厳密にシミュレーションする方法を説明してきましたが、今回はとにかく物理的にシミュレーションせずに、twist通りに動かすplanar_moveというプラグインの使い方を説明します。

ソースコード

urdf

簡易移動プラグインを使用したurdfです。

sim2_lecture/urdf/odm_simple.urdf
<?xml version="1.0"?>
<robot name="odm_robot" xmlns:xacro="http://ros.org/wiki/xacro">
  <material name="red">
    <color rgba="1.0 0 0 2.5"/>
  </material>

  <link name="base_link"/>

  <joint name="body_joint" type="fixed">
    <parent link="base_link"/>
    <child  link="body_link"/>
    <origin xyz="0 0 0.05" rpy="0 0 0"/>
  </joint>
  <link name="body_link">
   <inertial>
     <origin xyz="0 0 0.5" rpy="0 0 0"/>
     <mass value="1"/>
     <inertia ixx="0.1"  ixy="0"  ixz="0" iyy="0.1" iyz="0" izz="0.1" />
   </inertial>
   <visual>
     <origin xyz="0 0 0" rpy="0 0 0" />
     <geometry>
       <cylinder radius="0.1" length="0.1"/>
     </geometry>
     <material name="red" />
   </visual>
   <collision>
     <origin xyz="0 0 0" rpy="0 0 0"/>
     <geometry>
       <cylinder radius="0.1" length="0.1"/>
     </geometry>
   </collision>
  </link>
  <gazebo reference="body_link">
    <material>Gazebo/Red</material>
    <mu1 value="0.1" />
    <mu2 value="0.1" />
  </gazebo>

  <joint name="head_joint" type="fixed">
    <parent link="base_link"/>
    <child  link="head_link"/>
    <origin xyz="0.05 0 0.12" rpy="0 0 0"/>
  </joint>
  <link name="head_link">
   <visual>
     <origin xyz="0 0 0" rpy="0 0 0" />
     <geometry>
       <cylinder radius="0.03" length="0.04"/>
     </geometry>
     <material name="red" />
   </visual>
  </link>
  <gazebo reference="head_link">
    <material>Gazebo/Red</material>
  </gazebo>

  <gazebo>
    <plugin name="object_controller" filename="libgazebo_ros_planar_move.so">
      <commandTopic>cmd_vel</commandTopic>
      <odometryTopic>odom</odometryTopic>
      <odometryFrame>odom</odometryFrame>
      <odometryRate>20.0</odometryRate>
      <robotBaseFrame>base_link</robotBaseFrame>
      <cmdTimeout>2.0</cmdTimeout>
    </plugin>
  </gazebo>
</robot>

以下がプラグインの本体です。<commandTopic>で受け取るtwistのrostopic名を、<robotBaseFrame>で移動対象のlink名を指定します。

移動プラグイン
  <gazebo>
    <plugin name="object_controller" filename="libgazebo_ros_planar_move.so">
      <commandTopic>cmd_vel</commandTopic>
      <odometryTopic>odom</odometryTopic>
      <odometryFrame>odom</odometryFrame>
      <odometryRate>20.0</odometryRate>
      <robotBaseFrame>base_link</robotBaseFrame>
    </plugin>
  </gazebo>

launch

sim2_lecture/launch/odm_simple.launch
<?xml version="1.0" encoding="UTF-8"?>
<launch>
  <arg name="model" default="$(find sim2_lecture)/urdf/odm_simple.urdf" />
  <param name="robot_description" command="$(find xacro)/xacro.py $(arg model)" />

  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="paused" value="false"/>
    <arg name="use_sim_time" value="true"/>
    <arg name="gui" value="true"/>
    <arg name="headless" value="false"/>
    <arg name="debug" value="false"/>
  </include>

  <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-param robot_description -urdf -model odm_robot" />

</launch>

実行

各ターミナルごとに実行前にsource ~/catkin_ws/devel/setup.bashを実行する必要があります。

実行
roslaunch sim2_lecture odm_simple.launch 
twist送信
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist "linear:
  x: 0.5
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 0.5" 

sim_odm_simple.gif

問題点

このプラグインを適用すると重力が働かなくなるという特徴があります。具体的には

  • 段差から落ちそうになっても段差などなかったかのように宙を浮いて進みます。
  • 重心が高かったり、床との摩擦が大きかったりすると、ロボットが傾くことがあります。その後傾いた状態で空間に固定されます。

解決策はあるようですが、ソースからビルドしなおさないといけなくなるので面倒です。

参考

PlanarMovePlugin
PlanarMovePluginの問題
PlanarMovePluginの問題の修正方法

目次ページへのリンク

ROS講座の目次へのリンク

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4