siemens / ros-sharp

ROS# is a set of open source software libraries and tools in C# for communicating with ROS from .NET applications, in particular Unity3D
Apache License 2.0
945 stars 364 forks source link

Fix the problem that the laser data is mirrored in ROS #420

Closed ftyghome closed 2 years ago

ftyghome commented 2 years ago

Recently I am testing gmapping with ROS#. I imported the urdf of my robot, set up the navigation stack, and found everything is working fine except the LaserScanReader.

As is shown in the images below, the laser scan data is mirrored in RViz. The obstacles should be on the right side of the robot, not on the left.

image image

After doing some debugging work, I found that this problem is caused by the fact that ROS# does not align the laser data in the same way as ROS. ROS requires that laser scan angles are measured counterclockwise[1], with 0 facing forward, but ROS# uses the clockwise alignment in Unity.

I fixed the problem in this commit. The reason for keeping the old range array is that Laser Scan Visualizer in ROS# may need the data arranged in a clockwise way.

btw, this may help solve issue #199

[1] http://wiki.ros.org/navigation/Tutorials/RobotSetup/Sensors

MartinBischoff commented 2 years ago

Thank you @ftyghome for this pull request.

MartinBischoff commented 2 years ago

@ftyghome Please check the direction of the axis in your urdf. Can anyone confirm this merge request is a fix?

ftyghome commented 2 years ago

@ftyghome Please check the direction of the axis in your urdf. Can anyone confirm this merge request is a fix?

Hi, I am sorry to leave this pull request open that long. Maybe the code is only a workaround for my buggy URDF. I am not working with ROS 1 these days, But once I am sure it was a bug, I'll clean up the code and open another request to fix it. Thank you.