Shooting While Moving
Introduction
In many competitive robotics games, especially those involving game pieces launched as projectiles, it is advantageous to score while the robot is still in motion. Shooting while moving allows a robot to maintain speed, avoid defenders, and reduce the time spent stationary in vulnerable positions.
Successfully shooting while moving requires predicting how the robot’s motion will affect the trajectory of the game piece and compensating for that motion in the aiming system. This document introduces the fundamental geometric ideas behind that compensation for two common robot configurations:
- Robots with a fixed shooter (no turret)
- Robots with a rotating turret
This document assumes the robot uses a swerve drive, which allows independent control of translation (movement) and rotation (heading).
Linear Algebra Review
Transformations rely on basic linear algebra concepts. Here’s a brief summary:
-
Vectors A vector is an ordered list of numbers representing a point or direction in space. For example, a 2D point is a 2×1 column vector:
-
Matrices A matrix is a rectangular array of numbers that can represent a linear transformation. Multiplying a matrix by a vector transforms the vector according to the matrix’s rules:
where is a matrix and is the transformed vector.
-
Matrix Multiplication Matrix multiplication applies one transformation after another. For example, if and are transformations, applying both in sequence is:
Order matters: in general.
-
Rotation Matrices A rotation matrix rotates a vector around the origin. In 2D:
Multiplying by a vector rotates it counterclockwise by radians.
-
Translation in Homogeneous Coordinates Ordinary 2×2 rotation matrices cannot represent translation directly. By using homogeneous coordinates, we embed translation in a 3×3 matrix:
where is rotation and is translation. Multiplying this matrix by a 3×1 vector applies both rotation and translation simultaneously.
-
Chaining Transformations By multiplying transformation matrices, we can combine multiple motions into a single operation. For example, moving from the robot frame to the shooter frame and then to the field frame is just:
2D Transformation
In 2D space, a transformation is represented using a 3×3 homogeneous transformation matrix. This matrix encodes both rotation and translation in a single structure:
- (r) is a 2×2 rotation matrix
- (t) is a 2×1 translation vector
- The bottom row enables the use of homogeneous coordinates
Applying the Transformation
To transform a point from a local coordinate frame into a parent coordinate frame, represent the point using homogeneous coordinates:
Applying the transformation:
This operation simultaneously applies both the rotation and translation encoded in the matrix.
A note about transformation notation
In this document, transforms are notated with a where is the source (original) frame, and is the result (target) frame. For example, is a transformation from robot space into shooter space, i.e., it maps points expressed in the robot frame to coordinates expressed in the shooter frame
Shooting Theory - No Turret
The theory we will use to shoot on the move is an extension of a common stationary shooting technique that we are going to call Pose Based Shooting.
Pose Based Shooting
The theory behind pose based shooting is that if we know the translation of whatever we want to aim at, and the translation of our robot on the field, we can solve for the pose (translation and rotation) for the shooter to aim at.
From the game manual, we know the position of the goal relative to the field:
The robot knows where it is on the field from keeping track of its wheel positions over time (odometry) and any updates it gets from cameras:
Because both of these positions are relative to the field, we can compute the translation vector from the robot to the goal:
The angle the shooter must rotate to aim at the goal is then:
Offset Shooter
The above aiming method assumes the shooter is in the center of the robot. If the shooter is in the center, aiming the robot at the target also aims the shooter at the target. However, sometimes the shooter may not be at the robot center due to space constraints. In that case, we define the shooter offset as a rigid-body transform relative to the robot frame:
- is the translational offset of the shooter from the robot’s reference point.
- is the shooter’s fixed orientation relative to the robot frame.
From the game manual, the goal position in field coordinates is:
The robot’s field-relative pose, obtained from odometry and sensors, is:
The shooter’s pose in field coordinates is obtained by pose composition:
The translation part of gives the shooter’s field position:
The vector from the shooter to the goal is:
The field-relative angle the shooter must point is:
This is the angle the shooter should point in field coordinates.
To align the shooter with the goal, the robot must rotate so that the shooter’s field angle matches the target angle. Since the shooter’s field angle is the sum of the robot’s field orientation and the shooter offset:
Solving for the robot’s orientation:
Where:
- is the robot’s heading in field coordinates that makes the shooter point at the goal.
- is the angle from shooter to goal in field coordinates.
- is the shooter’s fixed orientation relative to the robot.
Shooting While Moving
When shooting while moving, the projectile inherits the shooter’s field-relative velocity at release. To compensate, the target must be projected backward along the shooter’s velocity vector for the projectile’s flight time .
Inputs
To calculate the adjusted target pose , we need:
- Robot's current field-relative pose:
- Nominal field-relative target pose:
- Robot's current linear velocity in the field:
- Robot's current angular velocity:
- Projectile flight time:
- Transform from robot frame to shooter frame:
Shooter offset distance
Let the translational offset of the shooter in the robot frame be:
The distance from the robot center to the shooter is:
Velocity induced by rotation
A shooter offset from the robot’s rotation center experiences a linear velocity due to the robot’s angular velocity:
- Compute the angle of the shooter relative to the robot frame:
- Linear velocity due to rotation (in robot coordinates):
Transform rotational velocity to field frame
The shooter’s velocity due to rotation in the field frame is:
Total shooter velocity in the field
Including the robot’s translational velocity:
This is the field-relative velocity of the shooter at the moment of firing.
Adjust target pose
Finally, compensate for the shooter’s motion during the projectile flight time :
This is the adjusted target position in field coordinates that the shooter should aim at to hit the nominal target while moving.