# Laser beam visualisation from libgazebo_ros_laser_sensor.so shifts

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Hi,

I'm currently working on a model of cartesian robot in Gazebo 11, using ROS2 with Foxy distro.

I built a cartesian robot (3-axis CNC like) from the Gazebo interface, I developed a plugin to control the speed on each axis and I use the laser beam plugin from the library lib_gazebo_ros_sensor.so to simulate optical sensors ; using the range mode to simulate limit switches. These optical sensors are basicaly composed of a rectangular cuboid and a 2 beam laser sensor. All sensors work well and are well addressed. I wrote a plugin to get ranges mesured by sensors and there isn't any trouble about this point. Actually, I have a problem related to the pose of my laser sensors with relation to their associated links when those links are mooving.

More precisely, I applied velocity control on each axis in the "absolute way" (neither PID or force), which is the first one discribed in the velodyn project. I observed that when the velocity is too high, the origin of the laser beam is shifted from its moving link. Of course, when the robot is static or moves at low speed such as 0.1 m.s-1, there is no problem at all.

For the use of my simulation, the velocity should not exceed 0.1 m.s-1 luckily, but I'm very curious about this issue for a higher velocity.

I didn't find any related post. Do you knwo the reason of this shift please ?

Here is a picture discribing the problem when my sensor is moving with a speed of 1 m.s-1 along X axis and the laser beam is oriented along Z axis. C:\fakepath\glitch optical sensor Gazebo.png

And here is the sdf code of the beginning of the link and its associated sensor (no need of the following code of the link):

<link name='link_Z1_MIN>
<inertial>
<mass>1e-06</mass>
<inertia>
<ixx>0.166667</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.166667</iyy>
<iyz>0</iyz>
<izz>0.166667</izz>
</inertia>
<pose>0 0 0 0 -0 0</pose>
</inertial>
<pose>0 3.025 2.11 -1.5707 1.5707 0.0000</pose>
<gravity>0</gravity>
<self_collide>0</self_collide>
<kinematic>0</kinematic>
<enable_wind>0</enable_wind>
<sensor name='Z1_MIN' type='ray'>
<pose>-0.005 0 0 1.5707 0 -3.14159</pose>
<visualize>1</visualize>
<update_rate>30</update_rate>
<ray>
<scan>
<vertical>
<samples>2</samples>
<resolution>1</resolution>
<min_angle>-0.05</min_angle>
<max_angle>0.05</max_angle>
</vertical>
<horizontal>
<samples>640</samples>
<resolution>1</resolution>
<min_angle>0</min_angle>
<max_angle>0</max_angle>
</horizontal>
</scan>
<range>
<min>0.01</min>
<max>0.2</max>
<resolution>0.02</resolution>
</range>
</ray>
<plugin name="Z1_MIN" filename="libgazebo_ros_ray_sensor.so">
<ros>
<namespace>/Z1_MIN</namespace>
<remapping>~/out:=range</remapping>
</ros>
<!-- when leaving away frame_name it defaults to base_footprint instead-->