Skip to content
IanVan edited this page Sep 24, 2015 · 1 revision

WTF IS ROS

ROS is an open source robot framework that runs on Ubuntu.

What does that mean to us?

The main reason is that ROS enables us to communicate between processes. So we can have two programs running at once that send messages to each other through ROS using the notion of a Publisher and a Subscriber. A publisher sends messages to a "topic" (An example of a topic would be "robot/front_camera_images" or "robot/position_xyz"), and a subscriber reads messages from a topic.

It also has features like "TF" - the "transform" library, which enables us to manage the many different reference frames on the robot. We can use it to easily figure out the position of the end-effector relative to the base, relative to the world. Or the orientation of the arm base relative to the robot base, relative to the world. Additional reading:

  • Quaternions: These look really complicated but are pretty simple. They represent a rotation in 3D, it's a vector that looks like <x, y, z, w> where the line from <0, 0, 0> to <x, y, z> defines the axis of rotation, and w is the angle amount to rotate. You multiply a quaternion by a point or set of points to rotate them.
  • Coordinate Transformations: These look complicated but are pretty simple

How does it work?

In Python, when you make a subscriber, you set up a "callback function", a function that is called when that subscriber gets a message on its topic, and takes that message as an argument.

example:

pose_subscriber = rospy.Subscriber('robot/pose', PoseStamped, pose_callback)

def pose_callback(message):
''' This function will automatically be called whenever something publishes on the topic "robot/pose" '''

Whenever a PoseStamped type message is published on "robot/pose", ROS will automatically call pose_callback on the content of that message.

Caveats

pose_callback (or any other callback) is called in a separate thread. This means that it could edit data that you are currently using! To avoid this, use a threading lock. See the XMega driver for how to do this if you need it.

Look at some examples in our codebase to see how to read messages, it's not immediately obvious.