Skip to content

Dev_ROSUnityCoordinateSystemConversion

Mehmet Emre Çakal edited this page Oct 10, 2024 · 7 revisions

ROS - Unity Coordinate System Conversions

Unity uses a Left-Handed, with y-up world coordinate system, whereas ROS uses a Right-Handed, with z-up world coordinate system.

Axis conventions:

Unity ROS
Forward Z X
Right X -Y
Up Y Z
Rotation clockwise counter-clockwise

Transform Extensions in ROS#

TransformExtensions.cs script of ROS# handles coordinate system conversions by keeping the Forward-Leftward-Upward convention same for both simulation platforms.

Example: Ros2Unity() code snippet

public static Vector3 Ros2Unity(this Vector3 vector3)
{
    return new Vector3(-vector3.y, vector3.z, vector3.x);
}

Joint Axes Conversions

Joint axes are imported/exported via the help of transform extensions. The vector which defines the axis is converted by keeping the same Forward-Leftward-Upward convention and will point into the same direction in the other coordinate system.

However, the rotation direction should also be taken into account.

Example: Apply Torque to Continuous or Revolute Joints

  • Spawn a URDF model with continuous or revolute joint in Gazebo to run a physics simulation.

  • Apply positive torque around forward-axis to observe a counter-clockwise rotation.

  • Import URDF model to Unity, and run physics simulation independently from Gazebo simulation.

  • Tick Use Motor and Free Spin

  • Apply negative torque around forward-axis to observe the same counter-clockwise rotation.


© Siemens AG, 2017-2024

Clone this wiki locally