Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: TF2 Tutorial #18

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mkdocs_rt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ extra:
nav:
- Getting Started: ./getting_started.md
- Robot Drivers: ./robot_drivers.md
- The Transform Tree: ./tf2.md
# - Writing Nodes: ./writing_nodes.md # TODO
- Navigation with Nav2:
- Overview: ./navigation_overview.md
Expand Down
11 changes: 7 additions & 4 deletions ros2/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ This tutorial series covers writing ROS 2 software for Stretch. ROS 2 programs c

Ensure that:

1. Your Stretch has the latest robot distribution installed
- These tutorials were written for the latest robot distribution. Take a look at the [Distributions & Roadmap](../../../software/distributions/) guide to identify your current distribution and upgrade if necessary.
2. You are comfortable developing with Stretch
- If you've never developed with Stretch before or are new to programming, check out the [Developing with Stretch](../../developing/basics/) tutorial series. In particular, the [Using ROS 2 with Stretch](#TODO) tutorial from that series is a good resource for those new to ROS 2.
1. Your Stretch has the latest software installed
- These tutorials were written for Ubuntu 22.04 and ROS2 Humble. Take a look at the [Distributions & Roadmap](../../../software/distributions/) guide to identify your current distribution and upgrade if necessary.
2. You are comfortable with Linux, the command line, and Python
- If you are new to programming, check out the [Developing with Stretch](../../developing/basics/) tutorial series.
3. Your Stretch is able to move freely about its environment
- Use an untethered set-up to connect to your robot, such as Remote Desktop software or using SSH + ROS2 networking. These tutorials were written assuming you've set up the [Moonlight Remote Desktop software](../../getting_started/connecting_to_stretch#untethered-setup) from the Getting Started tutorial series.


<!-- TODO:
## Overview
Expand Down
Binary file added ros2/images/stretch_transforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ros2/images/tf2_frame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ros2/images/tf2_transform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions ros2/tf2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# The Transform Tree

The many 3D coordinate frames on Stretch are managed by a piece of software called "tf2" (TransForm version 2). In this tutorial, we'll cover what "transformation frames" are, where they are placed on Stretch, and how to work with them using the TF2 library.

![transform tree](./images/stretch_transforms.png){ loading=lazy }

When working with a robot, we'd like to know where each part of the robot is in 3D space. Mathematically, the coordinate transformation system allows us to precisely describe where everything is located.

## Background

A great introduction on this subject can be found in chapter 2 of John J. Craig's textbook, Introduction to Robotics: Mechanics and Control. But in brief, a 3D coordinate frame is composed of 3 axes, orthogonal to one another according to the right-hand coordinate frame convention.

![frame](./images/tf2_frame.png){ loading=lazy }

!!! note

The X, Y, and Z axes are colored red, green, and blue respectively. An easy way to remember this is to map XYZ -> RGB

A "transformation" or transform describes the position and orientation of a coordinate frame with respect to another coordinate frame.

![transform](./images/tf2_transform.png){ loading=lazy }

Position and orientation can be described by 6 numbers: x, y, and z for position and roll, pitch, and yaw for orientation (more commonly, you'll see orientation described as a quaternion which is 4 numbers). Another term for a position + orientation combo is "pose". If we know the pose of an object in one coordinate frame, and we know the transform between this frame to another, then we can find the pose of the object with respect the latter frame. If we continue describing frames with respect to previous ones, we'll have built up a chain of transforms. Similarly, we can build up transform trees, and even transform graphs with cyclic connections.