Hector sonar implementation on a Pioneer 3DX [closed]

asked 2017-06-01 05:54:21 -0600

Hdifsttar gravatar image

updated 2017-06-01 08:58:57 -0600


I'm working on a simulation of two Pioneer-3DX robots on Gazebo. (Debian Stretch / Gazebo 7 / ROS Kinetic)

I'm trying to implement sonar readings with Hector_sonar (to make one robot follow the other) but it seems like it doesn't work. The problem I face is that I don't get any range/sonar display on rviz and the range I get from the sonar is always the same, even when the p3dx is alone with nothing around it (range moves between 0.04 and 0.05 which is not really what I would expect).

Here's how I did :

I cloned in my catkin_ws/src : https://github.com/tu-darmstadt-ros-p...

I used https://github.com/tu-darmstadt-ros-p... from hector_models package to make my pioneer3dx_sonar.xacro :

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro">
  <property name="M_PI" value="3.1415926535897931" />

  <xacro:macro name="pioneer_sonar" params="name parent xyz rpy ros_topic update_rate min_range max_range field_of_view ray_count meshes">

  <joint name="{name}_joint" type="fixed">
    <origin xyz="${xyz}" rpy="${rpy}"/>
    <parent link="${parent}"/>
    <child link="${name}_link"/>
  <link name="${name}_link">
      <mass value="0.0001"/>
      <origin xyz="0 0 0"/>
      <inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1"/>
    <visual name="front_sonar_vis">
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry name="pioneer_geom">
        <mesh filename="${meshes}/back_sonar.stl"/>
      <material name="SonarYellow">
        <color rgba="0.715 0.583 0.210 1.0"/>
      <origin xyz="0 0 0" rpy="0 0 0"/>
        <box size="0.1 0.1 0.1"/>

   <gazebo reference="${name}_link">
      <sensor type="ray" name="${name}">
        <pose>0 0 0 0 0 0</pose>
              <max_angle> ${field_of_view/2}</max_angle>
              <max_angle> ${field_of_view/2}</max_angle>

        <plugin name="gazebo_ros_${name}_controller" filename="libhector_gazebo_ros_sonar.so">

Ten I added into my pioneer3dx.xacro a line to call the previous file :

<xacro:include filename="$(find p3dx_robot)/xacro/p3dx/pioneer3dx_sonar.xacro">
  xyz="0.109 0 0.209"
  rpy="0 0 0"

And I obviously deleted how the sonar was defined before. (There was only a model with joint and link and nothing to actually make use of the sonar)

If someone could figure out how to make this work with these informations, I'd be really thankful. If you need to know more and these aren't enough, just let me know.


Edit 1 : I changed the min value of the sonar range(=0.7) and the ... (more)

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Hdifsttar
close date 2017-06-01 08:59:17.529428