ZeroSimROSUnity icon indicating copy to clipboard operation
ZeroSimROSUnity copied to clipboard

Unity Left Handed Coordinate System

Open EdvardGrodem opened this issue 2 years ago • 7 comments

Hi, after trying to run SLAM from the simulator we have some trouble with the coordinate frames from Unity. I know Unity uses a left handed coordinate system. Does ZeroSim account for this when publishing transforms?

EdvardGrodem avatar Jul 09 '21 08:07 EdvardGrodem

From what I can tell form the code the conversion is implemented, but not used by the transform publisher. https://github.com/fsstudio-team/ZeroSimROSUnity/blob/ead163a96296c3b3dbd83315e050941c259b3892/Runtime/Scripts/ROS/MessageTypes/Geometry/ZOROSGeometryMessages.cs#L36-L67

EdvardGrodem avatar Jul 09 '21 09:07 EdvardGrodem

So I tried this out by creating a simple scene with a TF Publisher with coordinates (1, 2, 3) and looked at the result in RViz and the TF position is (3, -1, 2) as expected. See attached images.

We have run ROS gmapper successfully. What SLAM system are you using?

unity_tf rviz_tf

micahpearlman avatar Jul 09 '21 16:07 micahpearlman

@EdvardGrodem are you still having issues? Found a major issue with converting Unity Quaternion to ROS. v0.1.14 should fix that.

FYI: Specifically the issue was that roll and pitch were swapped and yaw was fine. Because yaw was fine we never noticed it because all the mobile robot we worked with roll and pitch didn't matter only yaw.

micahpearlman avatar Jul 28 '21 00:07 micahpearlman

Hi, we are still struggeling with running SLAM, however I do not think it's due to the left handed coordinate system anymore. I think the initial confusion was due to the cameras not having the z-axis pointing into the image as is common convention. We found the settings for correcting this.

EdvardGrodem avatar Aug 03 '21 08:08 EdvardGrodem

@EdvardGrodem can you elaborate on the camera coordinate system and how it was fixed? Is there a patch or pull request that you can provide?

micahpearlman avatar Aug 03 '21 15:08 micahpearlman

Hi, sorry for not coming back to this sooner. In ZOROSRBGDepthPublisher we used the Camera Rotation Degrees to align the camera with our preferred coordinate system.

EdvardGrodem avatar Aug 30 '21 06:08 EdvardGrodem

On this note, I am struggling to understand the vector conversion. I am expecting

FromUnityVector(ToUnityVector3([0.1, 0.2, 0.3])) == [0.1, 0.2, 0.3]

but it does not seem to be true

Is this method correct? It looks to me that this is wrong.

     /// ROS Coordinate System (See: https://www.ros.org/reps/rep-0103.html) 
     /// x forward 
     /// y left  
     /// z up 
     ///  
     /// Unity Coordinate System: 
     /// x right 
     /// y up 
     /// z forward  
     public UnityEngine.Vector3 ToUnityVector3() { 
         return new UnityEngine.Vector3((float)-this.x, (float)this.z, (float)this.y); 
     } 

Using your comment on the coordinate system, shouldn't the method be rather as below? Am I missing something?

     public UnityEngine.Vector3 ToUnityVector3() { 
         return new UnityEngine.Vector3((float)-this.y, (float)this.z, (float)this.x); 
     } 

szandara avatar Dec 16 '21 09:12 szandara