icrobotics-team5584 / FRC-2022-Sumsy

Code for 5584's off-season robot project, a swerve bot for the Deep Space game
Other
1 stars 0 forks source link

Add units for native falcon tic amounts #24

Open Liam-Stow opened 2 years ago

Liam-Stow commented 2 years ago

The Falcon 500s use weird units that are hard to work with: encoder tics for position and encoder tics per 100ms for velocity. Let's add new unit types for these so we can implicitly convert to and from nice units like meters, degrees and meters per second. Use https://github.com/nholthaus/units#unit-definition-macros Note that units will need to be mechanism specific. for example, a Drive Base speed unit type using the falcons will need to take into account the gear ratio and wheel size:

metersPerSecToWheelRotationsPerSec = 1/WHEEL_CIRCUMFERENCE metersPerSecToMotorRotationsPerSec = metersPerSecToWheelRotationsPerSec / GEAR_RATIO metersPerSecToFalconTicsPerSec = metersPerSecToMotorRotationsPerSec FALCON_TICS_PER_ROTATION metersPerSecToFalconTicsPerMillisec = metersPerSecToFalconTicsPerSec / 1000 metersPerSecToFalconTicsPer100Milliseconds = metersPerSecToFalconTicsPerMillisec 100

UNIT_ADD(length, falconSwerveSpeed, unit<std::ratio<1, metersPerSecToFalconTicsPer100Milliseconds>, meters_per_second>)