blob: 99b5e567d51704b3bde5c50ff02f5cdfe0153a48 [file] [log] [blame]
justinT2166f75d72024-07-13 15:59:58 -07001\documentclass{article}
2\usepackage[letterpaper, margin=1in]{geometry}
3\usepackage{graphicx}
4\usepackage{amsmath}
5\usepackage[backend=bibtex]{biblatex}
6\usepackage[hidelinks, linktoc=all]{hyperref}
7\usepackage{tikz,tikz-3dplot}
8\usepackage[hypcap=false, margin = 3cm]{caption}
9\usepackage{booktabs}
10
11\DeclareMathOperator{\Ell}{\mathcal{L}}
12\newcommand{\harpoon}{\overset{\rightharpoonup}}
13
14\usetikzlibrary{calc}
15
16\bibliography{references}
17
18\title{Swerve Model}
19\author{Justin Turcotte, Austin Schuh}
20\date{May 2024}
21
22\begin{document}
23
24\maketitle
25\tableofcontents
26\newpage
27\section{Swerve Model}
28\subsection{Single Tire}
29This section describes the physics behind a single tire model where all variables are in reference to the wheel. The full robot model is in the next section.
30\subsubsection{Definitions}
31\begin{center}
32 \captionof{table}{Symbol definitions for a Single Tire Model}
33 \begin{tabular}{l c c}
34 \toprule
35 Description & Symbol & Units \\
36 \hline
37 Effective Radius of Wheel & $r_e$ & m \\
38 Longitudinal Velocity & $v_x$ & m/s \\
39 Lateral Velocity & $v_y$ & m/s \\
40 Angular Velocity of Wheel & $\omega$ & rad/s \\
41 Angle the velocity vector makes with the longitudinal axis of vehicle & $\theta$ & rad \\
42 Angle the tire makes with the longitudinal axis of vehicle & $\delta$ & rad \\
43 Cornering Tire Stiffness & $C_\alpha$ & N/rad \\
44 Longitudinal Tire Stiffness & $C_\sigma$ & N \\
45 Longitudinal Slip Ratio & $\sigma$ & Dimensionless \\
46 Slip Angle & $\alpha$ & rad \\
47 Mass & m & kg \\
48 Gear Ratio(Typically less than 1) & G & Dimensionless \\
49 External Force in Longitudinal Direction & $F_{dx}$ & N \\
50 External Force in Lateral Direction & $F_{dy}$ & N \\
51 Current through Motor & $I$ & A \\
52 Lateral Force From Tire & $F_a$ & N \\
53 Longitudinal Force From Tire & $F_o$ & N \\
54 Motor Torque Constant & $K_t$ & Nm/A \\
55 Moment of Inertia of motor to wheel & $J$ & kgm\textsuperscript{2} \\
56 \bottomrule
57 \end{tabular}
58\end{center}
59\subsubsection{Tire Forces}
60Longitudinal Slip Ratio and Slip angle are defined as follows
61\begin{gather}
62 \sigma = \frac{r_e\omega - v_x}{|v_x|} \\ % add breaking/accelerating and figure out whether we need the abs value
63 \alpha = \delta-\theta
64\end{gather}
65Both of these are empirically proven to be approximately linearly proportional to force around zero. \supercite{tire_basics} Thus
66\begin{gather}
67 F_o = C_\sigma \sigma \label{f_o}\\
68 F_a = C_\alpha \alpha \label{f_a}
69\end{gather}
70We can also say that
71\begin{gather}
72 \tan(\theta) = \frac{v_y}{v_x}
73\end{gather}
74and thus assuming no steering angle, $\delta$, we can say
75\begin{gather}
76 \alpha = -atan2\left(\frac{v_y}{v_x}\right)
77\end{gather}
78\subsubsection{Motor Forces}
79A DC motor can be modeled by the following two equations
80\begin{gather}
81 V = IR + \frac{\omega}{K_v}\\
82 \tau_{motor} = K_tI \label{motor_torque}
83\end{gather}
84\subsubsection{Equations of Motion}
85We can encapsulate our whole system in terms of $v_x$, $v_y$, and $\omega$(of wheel), thus the total forces in each direction is
86\begin{gather}
87 \Sigma F_x = F_o + F_{dx}\\
88 \Sigma F_y = F_a + F_{dy}\\
89 \Sigma \tau = \frac{\tau_{motor} - GF_o r_e}{G}
90\end{gather}
91The Gear ratios constants are required to shift to and from torque at wheel and motor.
92Thus, the equations of motion are
93\begin{gather}
94 \dot{v}_x = \frac{C_\sigma \frac{r_e \omega - v_x}{v_x} + F_{dx}}{m}\\
95 \dot{v}_y = \frac{-C_\alpha atan2\left(\frac{v_y}{v_x}\right) + F_{dy}}{m}\\
96 \dot{\omega} = \frac{-GF_or_e + K_tI}{GJ} \label{wheel_omega}
97\end{gather}
98
99\subsection{Swerve Model}
100\subsubsection{Definitions}
101
102\tdplotsetmaincoords{0}{90}
103\begin{center}
104 \begin{tikzpicture} [scale=2, tdplot_main_coords, axis/.style={->,blue,thick},
105 vector/.style={-stealth,black,very thick},
106 vector guide/.style={dashed,black,thick}]
107
108 \coordinate (O) at (0,0);
109
110 \draw[axis] (0,0) -- (0,1) node[anchor=north west]{$\mathbf{v_x}$};
111 \draw[axis] (0,0) -- (-1,0) node[anchor=south west]{$\mathbf{v_y}$};
112
113 \draw[thick,tdplot_main_coords] (2,2)-- (2,-2) -- (-2,-2)--(-2,2)--cycle;
114
115 \draw[thick,tdplot_main_coords] (2, 2) node[anchor=south east]{module 3};
116 \draw[thick,tdplot_main_coords] (2, -2) node[anchor=south west]{module 2};
117 \draw[thick,tdplot_main_coords] (-2, -2) node[anchor=north west]{module 1};
118 \draw[thick,tdplot_main_coords] (-2, 2) node[anchor=north east]{module 0};
119
120 \newcommand{\circAr}%
121 { \draw[axis] (0,0, 0) +(0:.25)[->] arc(0:360:.25);
122 }
123
124 \begin{scope}[tdplot_main_coords]
125 \circAr
126 \end{scope}
127 \draw[blue, thick](0.35,0,0)node[anchor=west]{$\mathbf{\theta}$};
128
129 \end{tikzpicture}
130 \captionof{figure}{Shows the module numbering scheme(like Quadrants) and the axes of the robot}
131
132 \vspace{1cm}
133
134 \tdplotsetmaincoords{0}{90}
135 \begin{tikzpicture} [scale=3, tdplot_main_coords, axis/.style={->,blue,thick},
136 vector/.style={-stealth,black,thick},
137 vector guide/.style={dashed,black,thick},
138 ref axis/.style={->,dashed, magenta, thick}]
139
140 %standard tikz coordinate definition using x, y, z coords
141 \coordinate (O) at (0,0,0);
142
143 \draw[axis] (0,0,0) -- (0,1,0) node[anchor= west]{$\mathbf{v_x}$};
144 \draw[axis] (0,0,0) -- (-1,0,0) node[anchor=west, yshift=-0.15cm]{$\mathbf{v_y}$};
145 % \draw[axis] (0,0,0) -- (0,0,1);
146
147 \draw[thick, tdplot_main_coords] (0,0,0) -- (-2, 2, 0) node[midway, anchor = north west]{$\mathbf{\harpoon{d}_{mod}}$};
148 \coordinate (perp) at ($ (-2,2,0)!0.15!-90:(0,0,0) $);
149
150 \draw [ref axis] (-2,2,0) -- (perp) node[very near end, anchor = north east]{$\mathbf{\dot{\theta} \times \harpoon{d}_{mod}}$};
151 % \draw[thick,tdplot_main_coords] (2,2,0)-- (2,-2,0) -- (-2,-2,0)--(-2,2,0)--cycle;
152
153 \draw[vector guide] (-2,0,0) -- (-2,2,0) node[midway, above]{};
154 \draw[vector guide] (0,0,0) -- (-2,0,0) node[midway, above, right, pos=0.65]{};
155 \draw[vector guide] (-2,2,0) -- (-2+0.375,2,0);
156
157 \coordinate (Shift) at (-2,2,0);
158 \tdplotsetrotatedcoordsorigin{(Shift)}
159
160 \draw[ref axis, tdplot_rotated_coords] (0,0,0) -- (0,0.5,0) node[anchor=north west]{$\mathbf{F_x/v_{mod_x}}$};
161 \draw[ref axis, tdplot_rotated_coords] (0,0,0) -- (-0.5,0,0) node[anchor=south]{$\mathbf{F_y/v_{mod_y}}$};
162 \draw[ref axis, tdplot_rotated_coords] (0,0,0) -- (0,0,0.5);
163
164 \tdplotsetrotatedcoords{-30}{0}{0}
165
166 \draw[axis, tdplot_rotated_coords] (0,0,0) -- (0,0.5,0) node[anchor= west]{$\mathbf{F_{wy}/v_{patch_y}}$};
167 \draw[axis, tdplot_rotated_coords] (0,0,0) -- (-0.5,0,0) node[anchor= west]{$\mathbf{F_{wx}/v_{patch_x}}$};
168 \tdplotdrawarc[blue, thick, tdplot_rotated_coords]{(0,0,0)}{0.25}{-60+90}{90}{anchor=north west}{$\mathbf{\psi}$}
169
170 % \newcommand{\circAr}%
171 % { \draw[axis] (0,0, 0) +(0:.25)[->] arc(0:360:.25);
172 % }
173
174 % \newcommand{\translatepoint}[1]%
175 % { \coordinate (mytranslation) at (#1);
176 % }
177
178 % \translatepoint{0,0,0.5}
179 % \begin{scope}[tdplot_main_coords,shift=(mytranslation)]
180 % \circAr;
181 % \end{scope}
182 % \draw(0,0,0.7)node[anchor=west]{$\psi$};
183
184 \end{tikzpicture}
185 \captionof{figure}{Shows the swerve axes one of the module axes, and variables defining the shift in coordinates}
186
187 \captionof{table}{Symbol definitions for the Swerve Model}
188 \begin{tabular}{l c c}
189 \toprule
190 Description & Symbol & Units \\
191 \hline
192 velocity of the module & $\harpoon{v}_{mod}$ & m/s \\
193 angle of the robot with respect to the field & $\theta$ & rad \\
194 location of the module with respect to a center point & $\harpoon{d}_{mod}$ & m \\
195 angular velocity of the robot & $\omega$ & rad/s \\
196 velocity of the robot & $\harpoon{v}$ & m/s \\
197 velocity of the contact patch of the wheel & $\harpoon{v}_{patch}$ & m/s \\
198 steer angle of the module & $\theta_{mod_s}$ & rad \\
199 caster of the wheel & $d_{caster}$ & m \\
200 angular velocity of steer of a module & $\omega_{mod_s}$ & rad/s \\
201 velocity of the module with respect to the ground & $\harpoon{v}_{ground}$ & m/s \\
202 effective radius of the wheel & $r_w$ & m \\
203 angular velocity of drive of a module & $\omega_{mod_d}$ & rad/s \\
204 slip ratio of a module & $\sigma_{mod}$ & Unitless \\
205 slip angle of a module & $\alpha_{mod}$ & rad \\
206 self righting moment of a module & $M_{mod_s}$ & m/s \\
207 force exerted by a module on the robot & $\harpoon{F}_{mod}$ & N \\
208 force of the tire on the module in the Longitudinal direction & $F_{wx}$ & N \\
209 force of the tire on the module in the lateral direction & $F_{wy}$ & N \\
210 mass of the robot & $m$ & kg \\
211 moment of inertia of the robot & $J_{robot}$ & kgm\textsuperscript{2} \\
212 external force on the robot & $\harpoon{F}_d$ & N \\
213 external torque on the robot & $\tau_d$ & Nm \\
214 \bottomrule
215 \end{tabular}
216 \vspace{0.1cm}\\
217 Note: Dots on top of symbols represent the time derivative of that symbol. The subscript $mod$ signifies the variable is per module
218 \captionof{table}{Symbol definitions for a module of the Swerve Model used in Section 1.2.3 and 1.2.4}
219 \begin{tabular}{l c c}
220 \toprule
221 Description & Symbol & Units \\
222 \hline
223 sun angle & $\beta$ & rad \\
224 carrier angle & $\psi$ & rad \\
225 planetary angle & $\gamma$ & rad \\
226 pitch radius of the sun & $r_s$ & m \\
227 pitch radius of the planetary & $r_p$ & m \\
228 torque on the sun & $\tau_\beta$ & Nm \\
229 torque on the carrier & $\tau_\psi$ & Nm \\
230 torque on the planetary & $\tau_\gamma$ & Nm \\
231 force acting between the sun and planetary & $F_1$ & N \\
232 force acting between the bevel gears & $F_2$ & N \\
233 force acting on the left axle contact point & $F_l$ & N \\
234 force acting on the right axle contact point & $F_r$ & N \\
235 effective radius of the vertical, smaller bevel gear & $r_{b1}$ & m \\
236 effective radius of the horizontal, larger bevel gear & $F_{b2}$ & m \\
237 offset of the pitch circle of the bevel gear from the center of the wheel & $w_b$ & m \\
238 distance between the center of the wheel and each axle contact points & $w_w$ & m \\
239 torque constant of the motor & $K_t$ & Nm/A \\
240 current applied to the steer motor & $I_s$ & A \\
241 current applied to the drive motor & $I_d$ & A \\
242 moment of inertia of the steer motor & $J_{ms}$ & kgm\textsuperscript{2} \\
243 gear ratio from the wheel to steer motor & $G_s$ & Unitless \\
244 gear ratio from the wheel to drive motor & $G_d$ & Unitless \\
245 moment of inertia of the drive motor & $J_{md}$ & Nm \\
246 gear ratio from the motor to sun & $G_{d1}$ & Unitless \\
247 gear ratio of the sun to planetary gear & $G_{d2}$ & Unitless \\
248 gear ratio of the bevel gears & $G_{d3}$ & Unitless \\
249 angle of the module & $\theta_s$ & rad \\
250 angle of the wheel & $\theta_d$ & rad \\
251 angle of the wheel motor & $\theta_{md}$ & rad \\
252 torque caused by the steer motor on the steer coordinate & $\tau_s$ & Nm \\
253 \bottomrule
254 \end{tabular}
255\end{center}
256\subsubsection{Module Velocities and Forces}
257Due to the circular motion, we use a cross product added to linear velocities
258\begin{gather}
259 \harpoon{v}_{mod} = \left(\omega \times R\left(\theta\right)\harpoon{d}_{mod}\right) + \harpoon{v}\\
260 \harpoon{v}_{patch} = \harpoon{v}_{mod} + \left(\omega + \omega_{mod_s}\right) \times R\left(\theta + \theta_{mod_s}\right)
261 \begin{bmatrix}
262 d_{caster} \\
263 0
264 \end{bmatrix}
265\end{gather}
266where all functions R are rotation matrices expressed as the following
267\begin{gather}
268 R(\psi) =
269 \begin{bmatrix}
270 \cos(\psi) & -\sin(\psi) \\
271 \sin(\psi) & \cos(\psi) \\
272 \end{bmatrix}
273\end{gather}
274We then express this in the coordinate system of the wheel which is needed for the tire forces
275\begin{gather}
276 \harpoon{v}_{ground} = R(-(\theta + \theta_{mod_s}))\harpoon{v}_{patch}
277\end{gather}
278We then can use those velocities to calculate the slip ratios which are slightly modified
279\begin{gather}
280 \sigma_{mod} = \frac{r_w\omega_{mod_d} - \harpoon{v}_{ground_x}}{max(0.02, |\harpoon{v}_{ground_x}|)}\\
281 \alpha_{mod} = -atan2(\frac{\harpoon{v}_{ground_y}}{\harpoon{v}_{ground_x}})
282\end{gather}
283The lateral and longitudinal forces are given by equations \eqref{f_o} and \eqref{f_a}.
284A tire also has a self aligning torque due to having more forces and the far side of the contact path due to a greater deflection. The equation for this assuming a constant weight distribution is found in \textcite{tire_basics} where $a$ is half the length of the contact patch
285\begin{gather}
286 M_{mod_s} = -\frac{aF_{wy}}{3}
287\end{gather}
288\subsubsection{Module Behavior}
289{\footnotesize Note: For the following section(until 1.2.4) use symbol table 3 in addition to 2}\\
290This section aims to find the static relation, since the inertia is negligible, between the sun gear and the wheel and its relation to the rotation of the whole module
291\begin{center}
292 % TODO(Justin):A nice latex diagram would be nice at some point intead of an image
293
294 % \tdplotsetmaincoords{60}{100}
295 % \begin{center}
296 % \begin{tikzpicture} [scale=2, tdplot_main_coords, axis/.style={blue,thick},
297 % vector/.style={-stealth,black,very thick},
298 % vector guide/.style={dashed,black,thick}]
299
300 % \coordinate (O) at (0,0);
301
302 % \draw[axis] (0,0,2) arc (0:360:1);
303 % \draw[axis] (0,2,2) arc (0:360:1);
304
305 % \end{tikzpicture}
306 % \captionof{figure}{Shows the module numbering scheme(like Quadrants) and the axes of the robot}
307 % \end{center}
308 \begin{figure}[h]
309 \includegraphics[width=\textwidth]{module_diagram.jpg}
310 \end{figure}
311 \begin{tikzpicture} [axis/.style={blue, very thick},
312 vector/.style={black,thick},
313 vector guide/.style={dashed,black}]
314
315 \draw[vector guide] (0.5,0) arc (0:60:0.5) node[midway, anchor = south west]{$\psi$};
316 \draw[vector] (2,0) arc (0:360:2) node[midway, anchor = east]{sun};
317 \draw[vector] (60:3) ++(1,0) arc (0:360:1) node[anchor = west]{planetary};
318 \draw[vector guide] (0,0) --(2,0);
319 \draw[axis] (0,0) --(60:3) node[vector, pos=0.45, sloped, above]{carrier};
320 \draw[axis] (0,0) -- (130:2);
321 \draw[vector guide] (0.4,0) arc (0:130:0.4) node[very near end, anchor = south]{$\beta$};
322 \draw[vector guide] (60:3) -- +(1,0);
323 \draw[axis] (60:3) -- +(110:1);
324 \draw[vector guide] (60:3) ++(0.5, 0) arc (0:110:0.5) node[midway, above]{$\gamma$};
325 \end{tikzpicture}
326 \captionof{figure}{Each blue line represents a rotational axis where the carrier rotates the planetary gear itself}
327\end{center}
328From the figure, we can say the following
329\begin{gather}
330 F_2 = \frac{r_p}{r_{b1}}F_1\\
331 F_2 = \frac{\tau_\gamma}{r_{b1}}\\
332 F_w = \frac{r_{b2}}{r_w}F_2\label{fw_to_f2}\\
333 \tau_\psi +F_lw_w-F_rw_w + \left(r_s+r_p\right)\left(F_2-F_1\right)= 0\label{the_eq}\\
334 F_w - F_l -F_r + F_2 = 0
335\end{gather}
336which we can express as
337\begin{gather}
338 \left(1+\frac{r_{b1}}{r_w}\right)F_2 - F_l -F_r = 0
339\end{gather}
340Thus, we can express $F_l$ and $F_r$ in terms of $F_2$
341\begin{gather}
342 F_l = \frac{1}{2}\left(1+\frac{r_{b1}}{r_w}-\frac{w_b}{w_w}\right)F_2\\
343 F_r = \frac{1}{2}\left(1+\frac{r_{b1}}{r_w}+\frac{w_b}{w_w}\right)F_2
344\end{gather}
345We then plug these values of $F_l$ and $F_r$ into \eqref{the_eq} to express everything in terms of $F_2$ which we can then express in terms of $F_w$ with \eqref{fw_to_f2}
346\begin{gather}
347 \tau_\psi = \left(w_b + \left(r_s+r_p\right)\left(1-\frac{r_{b1}}{r_p}\right)\right)F_2\\
348 = \left(w_b + \left(r_s+r_p\right)\left(1-\frac{r_{b1}}{r_p}\right)\right)\frac{r_w}{r_{b2}}F_w
349\end{gather}
350\subsubsection{Full Module Kinematics}
351We add up all the torques/forces in each dimension to give the following equations. The variables used here are separate per module
352\begin{gather}
353 M_s + \tau_s + \tau_\psi = J_{total}\ddot{\theta_s}\\
354 \tau_md + \tau_d = -F_{wx}r_w\\
355 \dot\theta_d = G_{d3}\left(\left(G_{carrier} - 1\right)\dot\theta_s - \dot\theta_{md}G_{motor-to-planet}\right) \label{the_one}
356\end{gather}
357The $-1$ in equation \eqref{the_one} comes from the additional contirbution of the wrapping around the gear with the change of coordinates.\\
358which we can expand into
359\begin{gather}
360 M_s + \frac{K_tI_s}{G_s} + \left(-w_b+\left(r_s+r_p\right)\left(1-\frac{r_{b1}}{r_p}\right)\right)\frac{r_w}{r_{b2}}\left(-F_{wx}\right) = \left(J_s + \frac{J_{ms}}{G^2_s}\right)\ddot\theta_s\\
361 \left(\frac{-J_{md}\ddot\theta_{md}}{G_d}\right)+\frac{K_{t}I_d}{G_d} = -F_{wx}r_w\\
362 \dot\theta_d = G_{d3}\left(\left(\frac{r_p+r_s}{r_p}-1\right)\dot\theta_s - \dot\theta_{md}G_{d1}G_{d2}\right)
363\end{gather}
364where each G represents a separate gear ratio.
365\subsubsection{Robot Equation of Motion}
366We then rotate back the module forces by
367\begin{gather}
368 \harpoon{F}_{mod} = R(\theta + \theta_{mod_s})\begin{bmatrix}
369 F_{wx} \\
370 F_{wy}
371 \end{bmatrix}
372\end{gather}
373The linear velocity differential equations are relatively simple as it's just adding all the forces by the module and an arbitrary external force
374\begin{gather}
375 \dot{\harpoon{v}} = \frac{\Sigma \harpoon{F}_{mod} + \harpoon{F}_{d}}{m}
376\end{gather}
377However, the angular velocity differential equation is more complicated as the torque added per module varies in sign
378\begin{gather}
379 \ddot{\theta} = \frac{\Sigma\left(\harpoon{r} \times \harpoon{F}_{mod}\right) + \tau_{d}}{J_{robot}}
380\end{gather}
381\newpage
382\printbibliography
383\end{document}