Hi,
I am simulating my own urdf in gazebo and visualizing in rviz. The problem I am facing here is about laser line position in rviz and and actual position of the object or wall in gazebo.
Case1 and Case2 for own robot simulation and Case3 for turtlebot3_waffle simulation.
Case1:
Here I put Lidar_joint origin at x=0.383, y=0, z=0.1 , r=0, p=0, y=0 and here parent link is base_link and child link is Lidar_link. In this case actual wall in gazebo is situated, approx 2.5 grid line away from the front face of the robot but laser red line I am getting in rviz is about 2.1 grid line away from the front face of the robot. You can see in the image and video attached below
In this case If I rotate the robot in gazebo, in rviz laser red line shifts its position.
Case2:
Here I put Lidar_joint origin at x=0, y=0, z=0.2 , r=0, p=0, y=0 and here parent link is base_link and child link is Lidar_link(same as Case1). In this case actual wall in gazebo is situated, approx 2.5 grid line away from the front face of the robot and laser red line I am getting in rviz is also 2.5 grid line away from the front face of the robot. You can see in the image and video attached below
In this case If I rotate the robot in gazebo, in rviz laser red line stays in same position.
Case3:
When I simulated turtlebot3_waffle in the same world, I did not find laser position error and shifting in rviz like Case1. Another thing I saw that turtlebot use .sdf file for gazebo simulation and .urdf fie for visualizing in rviz.
Conclusion:
Case2 and Case3 is giving expected result. I want to know that, while simulating a robot using urdf format is it required to keep lidar exactly on top of the base_link or reference_link for getting correct laser line in rviz. I checked with other urdf and construct video also, I found that when they are putting lidar on top of reference_link then only they are getting correct laser line or else if they shift the lidar in x-axis w.r.t reference_link then they are getting wrong laser line in rviz.
Should I use both .sdf and .urdf for correct output?
Please check the problem, I got stuck for a while.