Unity-Technologies/Unity-Robotics-Hub

Lidar Scan Visualization Inconsistent with Gazebo

keli95566 opened this issue · 1 comments

Describe the bug
The gif below shows the odometry visualization, the 2D occupancy map, and the 2D lidar scan of turtlebot3 in Unity. However, unlike the Gazebo simulation environment, the 2D lidar scan visualized in Unity centered around the Unity origin rather than aligned with the global occupancy map.
04_ros_slam_vis
I think the problem is on the LaserScanVisualizerSettings script, line 46: Vector3 point = Quaternion.Euler(0, Mathf.Rad2Deg * angle, 0) * Vector3.forward * message.ranges[i] , the point is defined assuming the robot is always at the origin. What would be the best way to modify this script so that the visualized point cloud aligns with the global occupancy map like in the Gazebo simulation?

I did try subscribes to /odom and basically transform the scanned points to follow the robot's position in the world like this: OdomTracker.transform.TransformPoint(Quaternion.Euler(0, Mathf.Rad2Deg * angle, 0) * Vector3.forward * message.ranges[i]) ;, but it only results in partially aligned point clouds, some points still seem to be rotated and drifted around.

04_ros_slam_vis_drifted

Can anyone help answer what caused this transformation issue and provide any potential solution? Many thanks!!

Expected behavior
The 2D lidar scan should align with the occupancy map.

Environment (please complete the following information, where applicable):

  • Unity Version: [ Unity 2019.4 LTS]
  • Windows 10
  • Ubuntu 20.04, Noetic
  • ROS–Unity communication: TCP
  • Branch or version: visualization 0.5.0

Ah sorry, using TransformPoint actually solves the issue. It did not work as I filtered some infinity points away.