how to read odomety and imu sensor in gazebo

asked 2018-04-02 08:44:44 -0500

JossiChrist gravatar image

I am newbie in ROS and gazebo. I have a differential robot model and I add odometry and imu plugin. but once i subscribe the topic, here is the condition 1st Condition : (in visual, the robot turn to 90 degree) - odometry result : 45 degree - imu result : 90,... degree

2nd Condition, once i terminate and start again : (in visual, the robot turn to 90 degree) - odometry result : 45 degree - imu result : 0.000025,... degree

what should i do? here is my .gazebo files

<robot xmlns:xacro="http://www.ros.org/wiki/xacro">

  <!-- ros_control plugin -->
  <gazebo>
    <plugin name="gazebo_ros_control" 
            filename="libgazebo_ros_control.so">
      <robotNamespace>/my_robot</robotNamespace>
      <robotParam>/robot_description</robotParam>
      <robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
    </plugin>
  </gazebo>




  <!--
    The plugin broadcasts a body's pose and rates through ROS nav_msgs::Odometry message.
    The plugin broadcasts pose and rate of a body named "chassis" over ROS topic name "my_robot/odom".
  -->
  <gazebo>
    <plugin name="ground_truth" 
            filename="libgazebo_ros_p3d.so">
      <frameName>map</frameName>
      <bodyName>chassis</bodyName>
      <!-- <topicName>my_robot/odom</topicName> -->
      <topicName>odom</topicName>
      <updateRate>30.0</updateRate>
    </plugin>
  </gazebo>


  <!-- Chassis -->
  <gazebo reference="chassis">

    <mu1>0.3</mu1>
    <mu2>0.3</mu2>

    <material>Gazebo/black</material>
  </gazebo>


  <!-- Caster wheel -->
  <gazebo reference="caster_wheel">
    <mu1>0.0</mu1>
    <mu2>0.0</mu2>

    <kp>1000000.0</kp>
    <kd>100.0</kd>
    <minDepth>0.001</minDepth>
    <maxVel>1.0</maxVel>

    <material>Gazebo/Chrome</material>
  </gazebo>



<!-- <gazebo>
<sensor name="imu_sensor" type="imu">
      <always_on>1</always_on>
      <update_rate>1000</update_rate>
      <visualize>1</visualize>
      <topic>__default_topic__</topic>

  <controller:gazebo_ros_imu name="imu_controller" plugin="libgazebo_ros_imu.so">
    <alwaysOn>true</alwaysOn>
    <updateRate>20.0</updateRate> 
    <bodyName>imu_link</bodyName>
    <topicName>imu_data</topicName>
    <gaussianNoise>2.89e-08</gaussianNoise>
    <xyzOffsets>0 0 0</xyzOffsets>
    <rpyOffsets>0 0 0</rpyOffsets>
    <interface:position name="imu_position"/>
  </controller:gazebo_ros_imu>
</gazebo> -->

<!-- <gazebo reference="imu_sensor_link">
    <gravity>true</gravity>
    <imu>
    <angular_velocity>
  <x>
    <noise type="gaussian">
      <mean>0.0</mean>
      <stddev>2e-4</stddev>
      <bias_mean>0.0000075</bias_mean>
      <bias_stddev>0.0000008</bias_stddev>
    </noise>
  </x>
  <y>
    <noise type="gaussian">
      <mean>0.0</mean>
      <stddev>2e-4</stddev>
      <bias_mean>0.0000075</bias_mean>
      <bias_stddev>0.0000008</bias_stddev>
    </noise>
  </y>
  <z>
    <noise type="gaussian">
      <mean>0.0</mean>
      <stddev>2e-4</stddev>
      <bias_mean>0.0000075</bias_mean>
      <bias_stddev>0.0000008</bias_stddev>
    </noise>
  </z>
</angular_velocity>
<linear_acceleration>
  <x>
    <noise type="gaussian">
      <mean>0.0</mean>
      <stddev>1.7e-2</stddev>
      <bias_mean>0.1</bias_mean>
      <bias_stddev>0.001</bias_stddev>
    </noise>
  </x>
  <y>
    <noise type="gaussian">
      <mean>0.0</mean>
      <stddev>1.7e-2</stddev>
      <bias_mean>0.1</bias_mean>
      <bias_stddev>0.001</bias_stddev>
    </noise>
  </y>
  <z>
    <noise type="gaussian">
      <mean>0.0</mean>
      <stddev>1.7e-2</stddev>
      <bias_mean>0.1</bias_mean>
      <bias_stddev>0.001</bias_stddev>
    </noise>
  </z>
</linear_acceleration>  
    </imu>

    <sensor name="imu_sensor" type="imu">
      <always_on>1</always_on>
      <update_rate>1000</update_rate>
      <visualize>1</visualize>
      <topic>__default_topic__</topic>
      <plugin filename="libgazebo_ros_imu_sensor.so" name="imu_plugin">
        <topicName>imu_data</topicName>
        <bodyName>imu_sensor_link</bodyName>
        <updateRateHZ>100.0</updateRateHZ>
        <gaussianNoise>2.89e-08</gaussianNoise>
        <xyzOffsets>0 0 0</xyzOffsets>
        <rpyOffsets>0 0 0</rpyOffsets>
      </plugin>
      <pose>0 0 0 0 0 0</pose>
    </sensor>
  </gazebo> -->



  <gazebo>
    <plugin name="differential_drive_controller" 
            filename="libgazebo_ros_diff_drive.so">
            <!-- <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so"> -->

      <!-- <robotNamespace>/</robotNamespace> -->

      <alwaysOn>true</alwaysOn>
      <updateRate>20</updateRate>
      <leftJoint ...
(more)
edit retag flag offensive close merge delete