Difference between revisions of "Controllers"
Jump to navigation
Jump to search
m (→Steady Lean Angle Calculation: typo) |
|||
(36 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | [[File:Controlstructure.png|200px|thumb|right|Control Structure Flow]] | |
− | + | The control algorithms on our bicycle are separated into three cascaded controllers. The output of one controller is input to another controller. In order from high level to low level: | |
− | |||
# Navigation controller, which tries to follow a desired path | # Navigation controller, which tries to follow a desired path | ||
− | # Balance controller, which tries to achieve a desired lean angle (φ<sub>d</sub>) and desired steer angle (δ<sub>d</sub>). For straight line balance (no navigation), this controller attempts to achieve | + | # Balance controller, which tries to achieve a desired lean angle (φ<sub>d</sub>) and desired steer angle (δ<sub>d</sub>). For straight line balance (no navigation), this controller attempts to achieve φ<sub>d</sub> = 0 and δ<sub>d</sub> = 0. In this position, the bicycle is balanced (upright and steered straight ahead). |
# Front motor controller, which controls front wheel angle (δ). | # Front motor controller, which controls front wheel angle (δ). | ||
*Using cascaded controllers allows us to develop each controller semi-independently. | *Using cascaded controllers allows us to develop each controller semi-independently. | ||
− | + | ||
+ | ==Front Motor Controller== | ||
*The front motor controller works to minimize the angle between the current steer angle (δ) and the commanded steer angle (δ<sub>c</sub>). | *The front motor controller works to minimize the angle between the current steer angle (δ) and the commanded steer angle (δ<sub>c</sub>). | ||
− | *Currently (Spring 2018), the front motor controller is PD (Proportional-Derivative) | + | *Currently (Spring 2018), the front motor controller is PD (Proportional-Derivative) controller. Specifically: |
− | controller. Specifically | + | <math>{\rm total\_error} = k_p(\delta_c - \delta) + k_d \frac{d}{dt}\left[\delta_c - \delta\right]</math> |
− | total_error = | + | *total_error is converted into a direction (DIR) and a magnitude (motor_output). |
− | * | + | |
− | ===Balance | + | ==Balance Controller== |
− | ===Euler Integrator=== | + | *The balance controller attempts to achieve a desired lean angle (φ<sub>d</sub>) and steer angle (δ<sub>d</sub>). In navigation mode, the navigation algorithm sets φ<sub>d</sub> and δ<sub>d</sub>. |
+ | *In addition to the desired state (φ<sub>d</sub><sub>d</sub>, δ<sub>d</sub>), the balance controller takes as input current lean angle (φ), lean angle rate (φ), and steer angle (δ). The balance controller outputs a steer angle rate (δ). | ||
+ | *Currently (Spring 2018), the balance controller is the linear controller: | ||
+ | <math> \delta_d^\prime = k_1 (\phi - \phi_d ) + k_2 \phi^\prime + k_3 ( \delta - \delta_d) </math> | ||
+ | ===Navigation Mode=== | ||
+ | *In navigation mode, φ<sub>d</sub> ≠ 0 and δ<sub>d</sub> ≠ 0. | ||
+ | *Thus, the balance controller tries to minimize the three terms in above. | ||
+ | *If φ − φ<sub>d</sub> = 0 the current lean angle (φ) equals the desired lean angle (φ<sub>d</sub>). | ||
+ | In other words, the bicycle has achieved the desired lean angle. | ||
+ | *Similarly, if δ − δ<sub>d</sub> = 0, the bicycle has achieved the desired steer angle. Still, the bicycle should not wobble: φ'= 0. | ||
+ | ===Balance Only=== | ||
+ | *For balance only, φ<sub>d</sub>=0, δ<sub>d</sub>=0. The balance controller reduces to: | ||
+ | <math>\delta_d^\prime = k_1 \phi + k<_2 \phi^\prime + k_3 \delta </math> | ||
+ | *In balance only mode, the balance controller tries to minimize the sum of the three terms above. | ||
+ | # The first term includes lean angle (φ): if φ = 0, the bike should be upright. | ||
+ | #The second term includes lean angle rate (φ'): if φ'= 0, the bike should not wobble. | ||
+ | #The third term includes steer angle (δ): if δ = 0, the bike should be steered straight ahead. | ||
+ | *If all three of these terms equal 0, the bike is balanced. | ||
+ | |||
+ | ==Euler Integrator== | ||
+ | *Connects the balance controller and the front motor controller. | ||
+ | *Takes, as input, the steer angular rate (δ<sub>d</sub>) commanded by the balance controller. | ||
+ | *Outputs a steer angle (δ<sub>c</sub>). δ<sub>c</sub> is input to the front motor PD controller. | ||
+ | *Our embedded code runs in discrete timesteps (about 0.01s each). | ||
+ | *δ<sub>c</sub> is the angle the front wheel would be at in the next timestep if the wheel spins at speed ̇δ during the current timestep. | ||
+ | *In other words, the Euler Integrator integrates ̇δ<sub>d</sub> to find δ<sub>c</sub>. Specifically: | ||
+ | <math>\delta_c = \delta + \delta \cdot t_{step}</math> | ||
+ | *See [https://en.wikipedia.org/wiki/Euler_method this page] for more info on Euler Integrators | ||
+ | |||
+ | ==Steady Lean Angle Calculation== | ||
+ | *The balance controller takes as input a desired steer angle (δ<sub>d</sub>) and a desired lean angle (φ<sub>d</sub>). | ||
+ | *Somehow, the desired steer angle (δ<sub>d</sub>) from the navigation algorithm must generate both a desired steer angle (δ<sub>d</sub>) and desired lean angle | ||
+ | (φ<sub>d</sub>). | ||
+ | *If the bicycle is in a steady turn, it must be both leaned and steered. | ||
+ | *Thus, to achieve a given steer angle, the bicycle must also achieve a corresponding lean angle. | ||
+ | *We use the equation below to calculate a lean angle (φ<sub>d</sub>) given a steer angle (δ<sub>d</sub>). | ||
+ | *This equation relates lean (φ) and steer (δ) in steady state: | ||
+ | <math>\phi_d = \frac{\delta_d v^2}{lg} </math> |
Latest revision as of 20:27, 14 April 2019
The control algorithms on our bicycle are separated into three cascaded controllers. The output of one controller is input to another controller. In order from high level to low level:
- Navigation controller, which tries to follow a desired path
- Balance controller, which tries to achieve a desired lean angle (φd) and desired steer angle (δd). For straight line balance (no navigation), this controller attempts to achieve φd = 0 and δd = 0. In this position, the bicycle is balanced (upright and steered straight ahead).
- Front motor controller, which controls front wheel angle (δ).
- Using cascaded controllers allows us to develop each controller semi-independently.
Contents
Front Motor Controller
- The front motor controller works to minimize the angle between the current steer angle (δ) and the commanded steer angle (δc).
- Currently (Spring 2018), the front motor controller is PD (Proportional-Derivative) controller. Specifically:
- total_error is converted into a direction (DIR) and a magnitude (motor_output).
Balance Controller
- The balance controller attempts to achieve a desired lean angle (φd) and steer angle (δd). In navigation mode, the navigation algorithm sets φd and δd.
- In addition to the desired state (φdd, δd), the balance controller takes as input current lean angle (φ), lean angle rate (φ), and steer angle (δ). The balance controller outputs a steer angle rate (δ).
- Currently (Spring 2018), the balance controller is the linear controller:
- In navigation mode, φd ≠ 0 and δd ≠ 0.
- Thus, the balance controller tries to minimize the three terms in above.
- If φ − φd = 0 the current lean angle (φ) equals the desired lean angle (φd).
In other words, the bicycle has achieved the desired lean angle.
- Similarly, if δ − δd = 0, the bicycle has achieved the desired steer angle. Still, the bicycle should not wobble: φ'= 0.
Balance Only
- For balance only, φd=0, δd=0. The balance controller reduces to:
- In balance only mode, the balance controller tries to minimize the sum of the three terms above.
- The first term includes lean angle (φ): if φ = 0, the bike should be upright.
- The second term includes lean angle rate (φ'): if φ'= 0, the bike should not wobble.
- The third term includes steer angle (δ): if δ = 0, the bike should be steered straight ahead.
- If all three of these terms equal 0, the bike is balanced.
Euler Integrator
- Connects the balance controller and the front motor controller.
- Takes, as input, the steer angular rate (δd) commanded by the balance controller.
- Outputs a steer angle (δc). δc is input to the front motor PD controller.
- Our embedded code runs in discrete timesteps (about 0.01s each).
- δc is the angle the front wheel would be at in the next timestep if the wheel spins at speed ̇δ during the current timestep.
- In other words, the Euler Integrator integrates ̇δd to find δc. Specifically:
- See this page for more info on Euler Integrators
Steady Lean Angle Calculation
- The balance controller takes as input a desired steer angle (δd) and a desired lean angle (φd).
- Somehow, the desired steer angle (δd) from the navigation algorithm must generate both a desired steer angle (δd) and desired lean angle
(φd).
- If the bicycle is in a steady turn, it must be both leaned and steered.
- Thus, to achieve a given steer angle, the bicycle must also achieve a corresponding lean angle.
- We use the equation below to calculate a lean angle (φd) given a steer angle (δd).
- This equation relates lean (φ) and steer (δ) in steady state: