Skip to content

Commit df609a1

Browse files
committed
add offset shooter
1 parent 6c5892b commit df609a1

1 file changed

Lines changed: 245 additions & 22 deletions

File tree

docs/SOTM.md

Lines changed: 245 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,87 @@ This document assumes the robot uses a **swerve drive**, which allows independen
1414
## Key Terms
1515
To reason about shooting while moving, we need a precise way to describe where things are on the field and how they are oriented. This document uses standard geometric representations commonly found in robotics, physics, and control systems.
1616

17+
<details>
18+
<summary>TLDR</summary>
19+
20+
<table>
21+
<thead>
22+
<tr>
23+
<th>Concept</th>
24+
<th>Definition</th>
25+
</tr>
26+
</thead>
27+
<tbody>
28+
<tr>
29+
<td>Translation (2D)</td>
30+
<td>
31+
$t = \begin{bmatrix} x \\ y \end{bmatrix}$
32+
</td>
33+
</tr>
34+
<tr>
35+
<td>Translation (3D)</td>
36+
<td>
37+
$t = \begin{bmatrix} x \\ y \\ z \end{bmatrix}$
38+
</td>
39+
</tr>
40+
<tr>
41+
<td>Rotation (2D)</td>
42+
<td>
43+
$r = \theta$
44+
</td>
45+
</tr>
46+
<tr>
47+
<td>Rotation (3D)</td>
48+
<td>
49+
$
50+
r = \begin{bmatrix}
51+
\alpha & \text{(roll)} \\
52+
\beta & \text{(pitch)} \\
53+
\gamma & \text{(yaw)}
54+
\end{bmatrix}
55+
$
56+
</td>
57+
</tr>
58+
<tr>
59+
<td>Pose (2D)</td>
60+
<td>
61+
$P = \begin{bmatrix} x \\ y \\ \theta \end{bmatrix}$
62+
</td>
63+
</tr>
64+
<tr>
65+
<td>Pose (3D)</td>
66+
<td>
67+
$
68+
P = \begin{bmatrix}
69+
x \\ y \\ z \\
70+
\alpha \\ \beta \\ \gamma
71+
\end{bmatrix}
72+
$
73+
</td>
74+
</tr>
75+
<tr>
76+
<td>Transform (2D)</td>
77+
<td>
78+
$T = \begin{bmatrix} x \\ y \\ \theta \end{bmatrix}$
79+
</td>
80+
</tr>
81+
<tr>
82+
<td>Transform (3D)</td>
83+
<td>
84+
$
85+
T = \begin{bmatrix}
86+
x \\ y \\ z \\
87+
\alpha \\ \beta \\ \gamma
88+
\end{bmatrix}
89+
$
90+
</td>
91+
</tr>
92+
</tbody>
93+
</table>
94+
95+
</details>
96+
97+
1798
---
1899

19100
### Translation
@@ -196,7 +277,9 @@ x \\
196277
y \\
197278
\theta
198279
\end{bmatrix}
280+
$$
199281

282+
$$
200283
T_{3D} =
201284
\begin{bmatrix}
202285
x \\
@@ -275,7 +358,7 @@ Transformations rely on basic linear algebra concepts. Here’s a brief summary:
275358
276359
<details>
277360
<summary>
278-
While the full 2D and 3D transformation are shown below for completeness, many shooting problems reduce to a planar yaw-only case, which significantly simplifies the math while preserving the same geometric structure.
361+
2D and 3D Transformation Matrix Definitions
279362
</summary>
280363
#### 2D Transformation
281364
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:
@@ -288,9 +371,9 @@ r & t \\
288371
\end{bmatrix}
289372
$$
290373

291-
- \(r\) is a 2×2 rotation matrix
292-
- \(t\) is a 2×1 translation vector
293-
- The bottom row enables the use of homogeneous coordinates
374+
- \(r\) is a 2×2 rotation matrix
375+
- \(t\) is a 2×1 translation vector
376+
- The bottom row enables the use of homogeneous coordinates
294377

295378
---
296379

@@ -306,8 +389,8 @@ y
306389
$$
307390

308391
This represents a shift of:
309-
- \(x\) units along the x-axis
310-
- \(y\) units along the y-axis
392+
- \(x\) units along the x-axis
393+
- \(y\) units along the y-axis
311394

312395
---
313396

@@ -383,9 +466,9 @@ r & t \\
383466
\end{bmatrix}
384467
$$
385468

386-
- \(r\) is a 3×3 rotation matrix
387-
- \(t\) is a 3×1 translation vector
388-
- The bottom row enables the use of homogeneous coordinates
469+
- \(r\) is a 3×3 rotation matrix
470+
- \(t\) is a 3×1 translation vector
471+
- The bottom row enables the use of homogeneous coordinates
389472

390473
---
391474

@@ -402,17 +485,17 @@ z
402485
$$
403486

404487
This represents a shift of:
405-
- \(x\) units along the x-axis
406-
- \(y\) units along the y-axis
407-
- \(z\) units along the z-axis
488+
- \(x\) units along the x-axis
489+
- \(y\) units along the y-axis
490+
- \(z\) units along the z-axis
408491

409492
---
410493

411494
##### Rotation Component
412495
The rotation matrix \(r\) is constructed from **Euler angles**:
413-
- $\alpha$: roll (rotation about the x-axis)
414-
- $\beta$: pitch (rotation about the y-axis)
415-
- $\gamma$: yaw (rotation about the z-axis)
496+
- $\alpha$: roll (rotation about the x-axis)
497+
- $\beta$: pitch (rotation about the y-axis)
498+
- $\gamma$: yaw (rotation about the z-axis)
416499

417500
This document assumes the rotations are applied in the following order:
418501

@@ -468,20 +551,160 @@ $$
468551

469552
</details>
470553

554+
:::important
555+
### A note about transformation notation
556+
557+
In this document, transforms are notated with a $T_{AB}$ where $B$ is the source (original) frame, and $A$ is the result (target) frame. For example, $T_{SR}$ 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
558+
:::
559+
471560
---
472561

473-
## Shooting Theory
562+
## Shooting Theory - No Turret
474563

475-
The theory we will use to shoot on the move is a continuation of a common stationary shooting technique that we are going to call *Pose Based Shooting*.
564+
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*.
476565

477566
### Pose Based Shooting
478-
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
479567

480-
From the game manual, we know the translation of the goal relative to the field: $t_{goal}$.
568+
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.
569+
570+
From the game manual, we know the translation of the goal relative to the field:
571+
572+
$$
573+
\mathbf{t}_{\text{goal}} =
574+
\begin{bmatrix}
575+
x_{\text{goal}} \\
576+
y_{\text{goal}}
577+
\end{bmatrix}
578+
$$
579+
580+
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:
581+
582+
$$
583+
\mathbf{t}_{\text{robot}} =
584+
\begin{bmatrix}
585+
x_{\text{robot}} \\
586+
y_{\text{robot}}
587+
\end{bmatrix}
588+
$$
589+
590+
Because both of these translations are relative to the field, we can compute the translation vector from the robot to the goal:
591+
592+
$$
593+
\mathbf{t}_{\text{goal->robot}} =
594+
\mathbf{t}_{\text{goal}} - \mathbf{t}_{\text{robot}}
595+
$$
596+
597+
The angle the shooter must rotate to aim at the goal is then:
598+
599+
$$
600+
\theta_{\text{shooter}} =
601+
\tan^{-1}\left(\frac{
602+
y_{\text{goal}} - y_{\text{robot}}}
603+
{x_{\text{goal}} - x_{\text{robot}}}
604+
\right)
605+
$$
606+
607+
### Offset Shooter
481608

482-
The robot knows where it is on the field from keeping track of its wheel's positions over time (odometry) and any updates it gets from cameras: $t_{robot}$
609+
The above aiming method assumes the shooter is in the center of the robot. If the shooter is in the center of the robot, aiming the robot at the target also aims the shooter at the target. However, in certain circumstances, a shooter may not be in the center of the robot due to space constraints. In that case, we can use a transformation ($T_{SR}$) that maps points from **robot space** to **shooter space**.
483610

484-
Because both of these poses are relative to the field, we can determine what angle our shooter needs to point at to aim at the goal:
611+
We define the shooter offset as a **rigid-body transform** relative to the robot frame:
485612

486613
$$
487-
$$
614+
T_{SR} =
615+
\begin{bmatrix}
616+
x_{SR} \\
617+
y_{SR} \\
618+
\theta_{SR}
619+
\end{bmatrix}
620+
$$
621+
622+
Here:
623+
624+
- $\begin{bmatrix} x_{SR} \\ y_{SR} \end{bmatrix}$ is the translational offset of the shooter from the robot center.
625+
- $\theta_{SR}$ is the orientation of the shooter relative to the robot frame.
626+
627+
From the game manual, we know the translation of the goal relative to the field:
628+
629+
$$
630+
\mathbf{t}_{\text{goal}} =
631+
\begin{bmatrix}
632+
x_{\text{goal}} \\
633+
y_{\text{goal}}
634+
\end{bmatrix}
635+
$$
636+
637+
The robot knows its pose on the field from keeping track of its wheel positions over time (odometry) and any updates it gets from cameras.
638+
639+
$$
640+
P_{robot} =
641+
\begin{bmatrix}
642+
x_{\text{robot}} \\
643+
y_{\text{robot}} \\
644+
\theta_{robot}
645+
\end{bmatrix}
646+
$$
647+
648+
Because the robot pose is relative to the origin of the field reference frame, we can express the pose of the robot on the field as a transform from the field origin to the robot:
649+
650+
$$
651+
T_{FR} =
652+
\begin{bmatrix}
653+
x_{\text{robot}} \\
654+
y_{\text{robot}} \\
655+
\theta_{robot}
656+
\end{bmatrix}
657+
$$
658+
659+
Then:
660+
661+
$$
662+
T_{FS} = T_{FR} \cdot T_{SR}
663+
$$
664+
665+
And:
666+
667+
$$
668+
t_{FS} = \begin{bmatrix} x_{FS} \\ y_{FS} \end{bmatrix} = \text{translation part of } T_{FS}
669+
$$
670+
671+
Then the goal relative to the shooter in field coordinates is:
672+
673+
$$
674+
\mathbf{t}_{\text{goal to shooter in field coordinates}} =
675+
\begin{bmatrix}
676+
x_{\text{goal}} \\
677+
y_{\text{goal}}
678+
\end{bmatrix}
679+
-
680+
\begin{bmatrix}
681+
x_{\text{shooter}} \\
682+
y_{\text{shooter}}
683+
\end{bmatrix}
684+
$$
685+
686+
The field-relative angle the shooter must point is:
687+
688+
$$
689+
\theta_{\text{shooter field}} =
690+
\tan^{-1}\left(\frac{
691+
y_{\text{goal}} - y_{\text{shooter}}}
692+
{x_{\text{goal}} - x_{\text{shooter}}}
693+
\right)
694+
$$
695+
696+
> This is the angle the shooter should point **in field coordinates**.
697+
698+
To align the shooter with the goal, the robot must rotate so that the shooter’s field angle matches the target angle.
699+
700+
The robot’s required orientation is:
701+
702+
$$
703+
\theta_{\text{robot to aim}} = \theta_{\text{SF}} - \theta_{SR}
704+
$$
705+
706+
Here:
707+
708+
- $\theta_{\text{robot to aim}}$ is the robot’s orientation in the field that will make the shooter point at the goal.
709+
- $\theta_{\text{SF}}$ is the angle from shooter to goal in field coordinates.
710+
- $\theta_{SR}$ is the shooter’s fixed orientation relative to the robot.

0 commit comments

Comments
 (0)