🤖
Introduction to ROS2 and Robotics
  • Introduction
  • ROS2
    • Index
    • IDE and CMake Setup
      • How to add additional include search path
    • ROS2 Building Blocks
      • ROS Workspace and Package Layout
      • Launch File
      • tf2
      • Quality of Service
      • Configurations
        • Rviz Configuration
      • Built-in Types
        • Built-in Message Type
    • ROS Architecture
      • Intra-process Communication
    • Navigation and Planning
      • Navigation Stack and Concepts
      • Navigation2 Implementation Overview
        • 🏗️Cost Map
        • Obstacle Avoidance and DWB Controller
      • DWB Controller
      • Page 5
    • How to launch the Nav2 stack
    • ROS2 Control
      • Online Resources
      • Overview of Codebase
    • 🍳Cookbook
      • Useful Commands
      • How to specify parameters
      • How to build the workspace
      • 🏗️How to publish message to a topic from command line?
      • How to inspect service and make a service call
      • How to properly terminate ROS and Gazebo
      • How to add and remove models in Gazebo simulation dynamically
      • 🚧How to spin nodes
    • 🛒Tutorials
      • Services and Communication between ROS2 and Gazebo
      • Subscription and Message Filters Demo
      • Executor and Spin Explained
      • Lifecycle Node Demo
      • Robotic Arm Demo
      • ⚒️Multiple Robotic Arms Simulation Demo
      • 🚧Introduction to xacro
    • Page
    • 🍺Tech Blog
      • Difference between URDF and SDF and how to convert
  • Gazebo
    • Index
    • Terminology
    • GUI
    • World Frame and Axis
    • Cookbook
    • Page 1
  • Programming in Robotics
    • C++
      • CMake
    • Python
    • Rust
  • Mathematics in Robotics
    • Linear Algebra
    • Matrix Properties
    • Probability
      • Expectation-Maximization Algorithm
    • Multivariable Function and Derivatives
  • Physics in Robotics
  • Control of Dynamic Systems
    • Dynamic Response and Transfer Function
    • Block Diagram
    • PID Controller
  • Robot Modeling and Control
    • Rotation and Homogeneous Transformation
  • Probabilistic Robotics
    • Bayes Filter
    • Kalman Filter
    • Particle Filter
    • Discrete Bayes Filter
    • Motion Model
    • Perception Model
    • Localization
    • SLAM
  • Miscellany
  • Concept Index
    • Quaternions
Powered by GitBook
On this page
  • Introduction
  • Resources and Related Readings
  • Notation and Convention
  • Rotation Representations
  • Rotation Matrices
  • Three-Angle Representations and Euler Angles
  • Exponential Coordinates and Different View of Rotation
  • Rotation Axis and Angle
  • Unit Quaternions
  • Relations between Different Representations
  1. Robot Modeling and Control

Rotation and Homogeneous Transformation

PreviousRobot Modeling and ControlNextProbabilistic Robotics

Last updated 1 year ago

Introduction

In this document, we will focus on rotation. We assume the reader is familiar with basic linear algebra.

Rotations and homogeneous transformations are key in robotic control. They are mathematical tools that represent rigid-body motion. In this document, we focus on different representations of rotation.

Resources and Related Readings

Most of the content of this document is based on the following three books:

Notation and Convention

It's important we have an intuitive notations in formula when we study robotics. In robotics, we need to deal with many different frames and coordinate systems and it's critical that we know unambiguously which frames we are working with. In this document, we adapt the notations from the book and .

Rotation Representations

There are many representations of rotations. The most common ones are the following:

  • rotation matrices

  • Euler and Cardan angles representation

  • rotation axis and angle

  • exponential coordinates

  • unit quaternions

In this section we will briefly go through each one of them.

Rotation Matrices

The rotation matrices representation is a direct application of the change of basis. Columns in a rotation matrix RRRrepresents the coordinates of bases of the transformed frame in the base frame. It has the following properties:

R−1=RTdet(R)=1\begin{align*} & R^{-1} = R^T &\\ & \textrm{det}(R) = 1 & \end{align*}​R−1=RTdet(R)=1​​

Example: Rotate a robot on a 2D map

In this case, the rotation is around the z-axis and the rotation matrix takes the following form

Rz(θ)=(cos⁡θ−sin⁡θ0sin⁡θcos⁡θ0001)R_z(\theta)=\begin{pmatrix} \cos{\theta} & -\sin{\theta} & 0 \\ \sin{\theta} & \cos{\theta} & 0 \\ 0 & 0 & 1 \end{pmatrix}Rz​(θ)=​cosθsinθ0​−sinθcosθ0​001​​

Interpretations of Rotation Matrix

There are two interpretations/views of rotation. As we mentioned earlier, the rotation matrix represents the change of basis. It relates the coordinates of the same point in two differnet frames.

The second view of the rotation matrix is that it applies the rotation transformation on an object. In this view, the coordinates are all in the same frames (i.e. the original frame) and no other frames are involved. The effect is that it transforms the coordinates of the blue dot in the black frame in the figure below to the coordinates of the red dot in the black frame. (The orange frame is the frame after the rotation as it's rigidly related to the dot. However it's not involved in the formula)

Three-Angle Representations and Euler Angles

Euler's rotation theorem:

Any two independent orthonormal coordinate frames can be related by a sequence of rotations (not more than three) about coordinate axes, where no two successive rotations may be about the same axis (Kuipers 1999)

According to the Euler's theorem, a rotation between any coordinate frames can be constructed by a sequence of rotation about a particular axis. During the process of constructing the intermediate rotations, new coordinate frames are created and the next rotation is about one of the axis in the current frame (not the original one). More specifically, suppose the original frame is denoted by F0F_0F0​ and the consecutive rotations are denoted by R1R_1R1​, R2R_2R2​, and R3R_3R3​. We use FfinalF_{final}Ffinal​to denote the final frame and we have the transformation sequence below:

F0→R1F1→R2F2→R3F3=FfinalF_0 \xrightarrow{R_1} F_1 \xrightarrow{R_2} F_2 \xrightarrow{R_3} F_3=F_{final}F0​R1​​F1​R2​​F2​R3​​F3​=Ffinal​

Because the rotation is about an axis in the current frame, we can simply compose the transformation:

Rfinal0=R1R2R3R^{0}_{final}=R_1R_2R_3Rfinal0​=R1​R2​R3​

The bottom line is that when we use the three-angle representation of rotations, we need to

  • Remember the rotation axis is in the "current" or "latest" intermediate frame.

  • Simply compose the rotation following the order.

Example: Roll-pitch-yaw with ZYX sequence

Remember that the composition order is simply the order of the rotation sequence. In this example, the rotation sequence is Rz(γ)R_z(\gamma)Rz​(γ), Ry(β)R_y(\beta)Ry​(β), and Rx(α)R_x(\alpha)Rx​(α). Therefore, the overall rotation is:

R(α,β,γ)=Rz(γ)Ry(β)Rx(α)R(\alpha, \beta, \gamma) = R_z(\gamma)R_y(\beta)R_x(\alpha)R(α,β,γ)=Rz​(γ)Ry​(β)Rx​(α)

Exponential Coordinates and Different View of Rotation

A rotation can be viewed as the result of the object being subject to a constant angular velocity θ˙\dot{\theta}θ˙during the unit of time (i.e. 1 second). Suppose the rotation axis is given by the unit vector ω^\hat{\omega}ω^, the angular velocity can be represented by

ω=θ˙ω^\omega = \dot{\theta} \hat {\omega}ω=θ˙ω^

We also have the formula of the velocity of a point subject to the angular velocity:

p˙(t)=ω×p(t)\dot{p}(t) = \omega \times p(t)p˙​(t)=ω×p(t)

TODO: this is a bit complicated. It's related to the twist concetp.

Rotation Axis and Angle

The most natural way to describe a rotation is to specify the rotation axis and the rotation angle.

The relationship between the axis-angle pair and the rotation matrix is established by the Rodrigues' rotation formula:

R(θ,v^)=I+sin(θ)[v^]×+(1−cos⁡θ)[v^]×2R(\theta, \hat{v}) = I + sin(\theta)[\hat{v}]_{\times} + (1 - \cos{\theta})[\hat{v}]^2_{\times}R(θ,v^)=I+sin(θ)[v^]×​+(1−cosθ)[v^]×2​

where θ\thetaθ is the rotation angle, v^\hat{v}v^ is the unit vector that represents the rotation axis. [v^]×[\hat{v}]_{\times}[v^]×​ is a skew-symmetric matrix constructed from the rotation axis vector.

This formula has a variation:

R(θ,v^)x=x+2s(ω×x)+2(ω×(ω×x))R(\theta, \hat{v})x = x + 2s(\omega \times x) + 2(\omega \times (\omega \times x))R(θ,v^)x=x+2s(ω×x)+2(ω×(ω×x))

where s=cos⁡θ2s=\cos{\frac{\theta}{2}}s=cos2θ​ and ω=sin⁡θ2v^\omega = \sin{\frac{\theta}{2}} \hat{v}ω=sin2θ​v^.

We can also recover the the rotation axis vector and the rotation angle from the rotation matrix. The rotation axis vector is the eigen vector with eigen value equals to 1. Note that a rotation matrix always has a real eigenvalue 1 because vectors on the rotation axis will not be changed by the rotation. The other two eigenvalues are λ=cos⁡θ±jsin⁡θ\lambda = \cos{\theta} \pm j \sin{\theta} λ=cosθ±jsinθ where θ\thetaθ is the rotation angle.

Unit Quaternions

q˘(s,v)=s⟨vx,vy,vz⟩\breve{q}(s, \bm{v}) = s\langle v_x, v_y, v_z \rangleq˘​(s,v)=s⟨vx​,vy​,vz​⟩

and a rotation with axis v^\bm{\hat{v}}v^ and angle θ\thetaθ can be represented by a unit quaternion:

q˚=cos⁡θ2⟨v^sin⁡θ2⟩\r{q} = \cos{\frac{\theta}{2}} \langle \bm{\hat{v}} \sin{\frac{\theta}{2}} \rangleq˚​=cos2θ​⟨v^sin2θ​⟩

We can apply the following operations to a quaternion:

q˘∗=s⟨−vx,−vy,−vz⟩q˘1⋅q˘2=s1s2+vx1vx2+vy1vy2+vz1vz2q˘1∘q˘2=(s1s2−v1⋅v2)⟨s1v2+s2v1+v1×v2⟩\begin{align*} &\breve{q}^* = s \langle -v_x, -v_y, -v_z \rangle \\ &\breve{q}_1 \cdot \breve{q}_2 = s_1s_2 + v_{x1}v_{x2} + v_{y1}v_{y2} + v_{z1}v_{z2} \\ &\breve{q}_1 \circ \breve{q}_2 = (s_1s_2 - \bm{v_1}\cdot\bm{v_2}) \langle s_1 \bm{v_2} + s_2 \bm{v_1} +\bm{v_1} \times \bm{v_2} \rangle \end{align*}​q˘​∗=s⟨−vx​,−vy​,−vz​⟩q˘​1​⋅q˘​2​=s1​s2​+vx1​vx2​+vy1​vy2​+vz1​vz2​q˘​1​∘q˘​2​=(s1​s2​−v1​⋅v2​)⟨s1​v2​+s2​v1​+v1​×v2​⟩​

Relations between Different Representations

In the book , the author mentions that Euler angles is an ambiguous term. What's more confusing is that the rotation sequence depends on the context. For example, when we say roll-pitch-yaw angle, it could mean either XYZ or ZYX rotation.

Quaternions is frequently used in ROS. For information about quaternion in ROS, you can refer to the article .

We adopt the notation in the book and represent a quaternion using the following form:

Robotics, Vision and Control - 3rd Edition
Quaternion Fundamentals
Robotics, Vision and Control - 3rd Edition
Modern Robotics: Mechanics, Planning, and Control
Robotics, Vision and Control - 3rd Edition
Robot Modeling and Control - 2nd Edition
Robotics, Vision and Control - 3rd Edition
Robot Modeling and Control - 2nd Edition