ROS Coordinates (Thu Sep 19, lect 7) | previous | next | slides |

How does ROS handle coordinates, frames, transforms

Reminder: Readings are your responsibility. You will be expected to come to class prepared, having read the material, and ready to participate in the discussion

Coordinate systems

  • Review of Chapters up to 8: Teleop-bot
  • Who has implemented and run it?
  • Where is a robot? How do we designate the location?
  • If it’s a surface moving mobile robot, then an x,y coordinate would seem to be sufficient
  • We need to determine the units: for us, usually Meters
  • We need to designate the origin
  • Anything else?

What about the “real world”?

  • Where is that 0,0?
  • Does it matter?

What part of the robot?

  • What part of the robot are we talking about?
  • The “middle”?
  • Who says where the middle is?
  • Does it matter how high off the ground it is?

Orientation

  • What about where it is pointing?
  • Is that part of the orientation?
  • What does it mean to tell the robot to rotate right or left?
  • Is that direction also part of the orientation in space?
  • When would that matter?

Demo

What else?

  • What other aspects of orientation in space?
  • If the Robot has a camera mounted on it?
  • If there is an arm?
  • Robot pushing an elevator button

Actions

  • Taking action based on orientation. Think about:
  • Turn Right
  • Turn North
  • Point camera in the direction of the sound

“Pose”

  • The combination of the robot’s position and orientation (direction it is pointing)
  • Each one has 3 dimensions: x,y,z and r,p,y
  • x,y,z are cartesian coordinates (position)
  • r,p,y are Euler coordinates (orientation)

Multiple Coordinate systems

  • Each component of the robot potentially has a coordinate system
  • Many of them have a fixed relationship to each other
  • Point 0,0 for the robot’s tf might be Point 10,0 for the camera’s tf
  • There are coordinate systems attached to (each) robot
  • But also to the rest of the “world” the robot knows about

Conversions

  • Converting between coordinate systems
  • Very common calculation is to convert a certain actual point
  • From one coordinate system to another

ROS Units and data types (see Rep 103)

  • In ROS, we use the following units:
    1. Distance: Meter
    2. Velocity: Meters/Second
    3. Angles: Radians (sometimes degrees)
    4. Orientation: Euler angles (roll pitch yaw) or Quaternions
    5. Right Hand Rule
    6. “RPG” Mnemonic

Euler Angles

  • Conventional way to represent orientation
  • Pitch, Roll, Yaw (from airplanes)
  • Can be radians or angles, but for ROS poses, it’s radians
  • Reminder: Radians go from 0 (0 degrees) to 2 * PI (360 degrees == 0 degrees)
  • Howevever you will encounter negative radians for poses
  • Be careful when you add angles together (modulo!)

Quaternions

  • Quaternion represents the same, but with 4 numbers
  • There’s an exact conversion between Euler angles and Quaternions
  • For subtle mathematical reasons, when combining a series of rotations, Quaternions work better
  • Don’t try to interpret the x,y,z,r of a quaternion, it doesn’t have an intuitive mapping to x,y and z euler angles.


# type(pose) = geometry_msgs.msg.Pose
# convert from euler to quaternion

quaternion = tf.transformations.quaternion_from_euler(roll, pitch, yaw)
pose.orientation.x = quaternion[0]
pose.orientation.y = quaternion[1]
pose.orientation.z = quaternion[2]
pose.orientation.w = quaternion[3]

# type(pose) = geometry_msgs.msg.Pose
# convert from quaternion to euler

quaternion = (
    pose.orientation.x,
    pose.orientation.y,
    pose.orientation.z,
    pose.orientation.w)
euler = tf.transformations.euler_from_quaternion(quaternion)
roll = euler[0]
pitch = euler[1]
yaw = euler[2]

Datatypes in ROS

  • ROS “messages”, also *.msg files
  • Really amount to a C struct

Point

  • Point (geometry_msgs/Point.msg)
  • x,y,z: float64
  • A point in 3D space
  • Right hand rule
  • positive x-forward, positive y-left, positive z-up

Vector3

  • Vector3 (geometry_msgs/Vector3.msg)
  • x, y, z: float64
  • Simple, generic representation of 3 float64

Quaternion

  • Orientation (geometry_msgs/Quaternion.msg)
  • x, y, z, w: float64
  • An orientation in space, in quaternion form
  • Quaternions are another way to express orientation

Pose

  • Pose (geometry_msgs/Pose.msg)
  • position: Point
  • orientation: Quaternion
  • A combination of “where” and “facing what way”

Twist

  • Velocity in free space, broken into linear and angular
  • Twist (geometry_msgs/Twist.msg)
  • linear, angular: Vector3

Thank you. Questions?  (random Image from picsum.photos)