I have noticed that most people simulate sonar sensors using ros_gazebo_range plugin which in turn uses gazebo's RayPlugin. However, the behavior is not identical. When the sonar beam touches the floor it doesn't get reflected back to the receiver, and hence the measured distance is not the distance from the sensor to the floor. The gazebo_ros_range plugin uses a ray sensor as its source which is different than a sonar sensor (check the sdf format for this). What we need is a new plugin that uses SonarSensor and SonarPlugin to simulate the real behavior in ROS.
I have developed a new plugin inspired by ros_gazebo_range but it seems that RaySensor and SonarSensor don't use the same axes. (for RaySensor distance is toward the +x-axis but in SonarSensor it is toward -z-axis). I created an additional fake link to be able to simulate the behavior but I don't think it's the best solution. Let me know if you're interested in the code I wrote.
I have noticed that most people simulate sonar sensors using ros_gazebo_range plugin which in turn uses gazebo's RayPlugin. However, the behavior is not identical. When the sonar beam touches the floor it doesn't get reflected back to the receiver, and hence the measured distance is not the distance from the sensor to the floor. The gazebo_ros_range plugin uses a ray sensor as its source which is different than a sonar sensor (check the sdf format for this). What we need is a new plugin that uses SonarSensor and SonarPlugin to simulate the real behavior in ROS. I have developed a new plugin inspired by ros_gazebo_range but it seems that RaySensor and SonarSensor don't use the same axes. (for RaySensor distance is toward the +x-axis but in SonarSensor it is toward -z-axis). I created an additional fake link to be able to simulate the behavior but I don't think it's the best solution. Let me know if you're interested in the code I wrote.