SCRIPT Move subprojects

This commit is contained in:
PJ Reiniger
2025-11-07 19:55:36 -05:00
committed by Peter Johnson
parent 8cfc158790
commit a5492d30da
431 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,210 @@
# Data Collection
This document details how data must be sent over NetworkTables for accurate data collection. Note that the data format has changed from what the old [frc-characterization](https://github.com/wpilibsuite/frc-characterization) tool used to generate.
## NetworkTables Data Entries
Here is a list of the NT entries that are used to send and collect data between sysid and the robot program:
| NT Entry | Type | Description |
| --------------------------------------| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `/SmartDashboard/SysIdTelemetry` | `string` | Used to send telemetry from the robot program. This data is sent after the test completes once the robot enters the disabled state. |
| `/SmartDashboard/SysIdVoltageCommand` | `double` | Used to either send the ramp rate (V/s) for the quasistatic test or the voltage (V) for the dynamic test. |
| `/SmartDashboard/SysIdTestType` | `string` | Used to send the test type ("Quasistatic" or "Dynamic") which helps determine how the `VoltageCommand` entry will be used. |
| `/SmartDashboard/SysIdRotate` | `bool` | Used to receive the rotation bool from the Logger. If this is set to true, the drivetrain will rotate. It is only applicable for drivetrain tests. |
## Telemetry Format
There are two formats used to send telemetry from the robot program. One format is for non-drivetrain mechanisms, whereas the other is for all drivetrain tests (linear and angular). All timestamps must be in seconds.
### Non-Drivetrain Mechanisms
`timestamp, voltage, position, velocity`
Example JSON:
```json
{
"fast-backward": [
[
timestamp 1,
voltage 1,
position 1,
velocity 1
],
[
timestamp 2,
voltage 2,
position 2,
velocity 2
]
],
"fast-forward": [
[
timestamp 1,
voltage 1,
position 1,
velocity 1
],
[
timestamp 2,
voltage 2,
position 2,
velocity 2
]
],
"slow-backward": [
[
timestamp 1,
voltage 1,
position 1,
velocity 1
],
[
timestamp 2,
voltage 2,
position 2,
velocity 2
]
],
"slow-forward": [
[
timestamp 1,
voltage 1,
position 1,
velocity 1
],
[
timestamp 2,
voltage 2,
position 2,
velocity 2
]
],
"sysid": true,
"test": "Simple",
"units": "Rotations",
"unitsPerRotation": 1.0
}
```
Supported test types for the "test" field in this data format include "Arm",
"Elevator", and "Simple". Supported unit types include "Meters", "Feet",
"Inches", "Radians", "Rotations", and "Degrees".
### Drivetrain
`timestamp, l voltage, r voltage, l position, r position, l velocity, r velocity, angle, angular rate`
Note that all positions and velocities should be in rotations of the output and rotations/sec of the output respectively. If there is a gearing between the encoder and the output, that should be taken into account.
Example JSON:
```json
{
"fast-backward": [
[
timestamp 1,
l voltage 1,
r voltage 1,
l position 1,
r position 1,
l velocity 1,
r velocity 1,
angle 1,
angular rate 1
],
[
timestamp 2,
l voltage 2,
r voltage 2,
l position 2,
r position 2,
l velocity 2,
r velocity 2,
angle 2,
angular rate 2
]
],
"fast-forward": [
[
timestamp 1,
l voltage 1,
r voltage 1,
l position 1,
r position 1,
l velocity 1,
r velocity 1,
angle 1,
angular rate 1
],
[
timestamp 2,
l voltage 2,
r voltage 2,
l position 2,
r position 2,
l velocity 2,
r velocity 2,
angle 2,
angular rate 2
]
],
"slow-backward": [
[
timestamp 1,
l voltage 1,
r voltage 1,
l position 1,
r position 1,
l velocity 1,
r velocity 1,
angle 1,
angular rate 1
],
[
timestamp 2,
l voltage 2,
r voltage 2,
l position 2,
r position 2,
l velocity 2,
r velocity 2,
angle 2,
angular rate 2
]
],
"slow-forward": [
[
timestamp 1,
l voltage 1,
r voltage 1,
l position 1,
r position 1,
l velocity 1,
r velocity 1,
angle 1,
angular rate 1
],
[
timestamp 2,
l voltage 2,
r voltage 2,
l position 2,
r position 2,
l velocity 2,
r velocity 2,
angle 2,
angular rate 2
]
],
"sysid": true,
"test": "Drivetrain",
"units": "Rotations",
"unitsPerRotation": 1.0
}
```
Supported test types for the "test" field in this data format include
"Drivetrain" and "Drivetrain (Angular)". Supported unit types include "Meters",
"Feet", "Inches", "Radians", "Rotations", and "Degrees".

View File

@@ -0,0 +1,120 @@
# OLS derivations
## Simple/drivetrain
Here's the ODE for a drivetrain.
```
dx/dt = -Kv/Ka x + 1/Ka u - Ks/Ka sgn(x)
```
### OLS setup
Let `α = -Kv/Ka`, `β = 1/Ka`, and `γ = -Ks/Ka`.
```
dx/dt = αx + βu + γ sgn(x)
```
### Feedforward gains
Divide the OLS terms by each other to obtain `Ks`, `Kv`, and `Ka`.
```
Ks = -γ
Kv = -α
Ka = 1/β
```
## Elevator
Here's the ODE for an elevator.
```
dx/dt = -Kv/Ka x + 1/Ka u - Ks/Ka sgn(x) - Kg/Ka
```
### OLS setup
Let `α = -Kv/Ka`, `β = 1/Ka`, `γ = -Ks/Ka`, and `δ = -Kg/Ka`.
```
dx/dt = αx + βu + γ sgn(x) + δ
```
### Feedforward gains
Divide the OLS terms by each other to obtain `Ks`, `Kv`, `Ka`, and `Kg`.
```
Ks = -γ
Kv = -α
Ka = 1/β
Kg = −δ/β
```
## Arm
Here's the ODE for an arm:
```
dx/dt = -Kv/Ka x + 1/Ka u - Ks/Ka sgn(x) - Kg/Ka cos(angle)
```
If the arm encoder doesn't read zero degrees when the arm is horizontal, the fit
for `Kg` will be wrong. An angle offset should be added to the model like so.
```
dx/dt = -Kv/Ka x + 1/Ka u - Ks/Ka sgn(x) - Kg/Ka cos(angle + offset)
```
Use a trig identity to split the cosine into two terms.
```
dx/dt = -Kv/Ka x + 1/Ka u - Ks/Ka sgn(x) - Kg/Ka (cos(angle) cos(offset) - sin(angle) sin(offset))
dx/dt = -Kv/Ka x + 1/Ka u - Ks/Ka sgn(x) - Kg/Ka cos(angle) cos(offset) + Kg/Ka sin(angle) sin(offset)
```
Reorder multiplicands so the offset trig is absorbed by the OLS terms.
```
dx/dt = -Kv/Ka x + 1/Ka u - Ks/Ka sgn(x) - Kg/Ka cos(offset) cos(angle) + Kg/Ka sin(offset) sin(angle)
```
### OLS setup
Let `α = -Kv/Ka`, `β = 1/Ka`, `γ = -Ks/Ka`, `δ = -Kg/Ka cos(offset)`, and `ε = Kg/Ka sin(offset)`.
```
dx/dt = αx + βu + γ sgn(x) + δ cos(angle) + ε sin(angle)
```
### Feedforward gains: Ks, Kv, Ka
Divide the OLS terms by each other to obtain `Ks`, `Kv`, and `Ka`.
```
Ks = -γ
Kv = -α
Ka = 1/β
```
### Feedforward gains: Kg
Take the sum of squares of the OLS terms containing the angle offset. The angle
offset trig functions will form a trig identity that cancels out. Then, just
solve for `Kg`.
```
δ²+ε² = (-Kg/Ka cos(offset))² + (Kg/Ka sin(offset))²
δ²+ε² = (-Kg/Ka)² cos²(offset) + (Kg/Ka)² sin²(offset)
δ²+ε² = (Kg/Ka)² cos²(offset) + (Kg/Ka)² sin²(offset)
δ²+ε² = (Kg/Ka)² (cos²(offset) + sin²(offset))
δ²+ε² = (Kg/Ka)² (1)
δ²+ε² = (Kg/Ka)²
√(δ²+ε²) = Kg/Ka
hypot(δ, ε) = Kg/Ka
hypot(δ, ε) = Kg β
Kg = hypot(δ, ε)/β
```
### Feedforward gains: offset
Divide ε by δ, combine the trig functions into `tan(offset)`, then use `atan2()`
to preserve the angle quadrant. Maintaining the proper negative signs in the
numerator and denominator are important for obtaining the correct result.
```
δ = -Kg/Ka cos(offset)
ε = Kg/Ka sin(offset)
sin(offset)/-cos(offset) = ε/δ
sin(offset)/cos(offset) = ε/-δ
tan(offset) = ε/-δ
offset = atan2(ε, -δ)
```