Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add units for native falcon tic amounts #24

Open
Liam-Stow opened this issue Oct 18, 2022 · 0 comments
Open

Add units for native falcon tic amounts #24

Liam-Stow opened this issue Oct 18, 2022 · 0 comments

Comments

@Liam-Stow
Copy link
Member

Liam-Stow commented Oct 18, 2022

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>)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant