“units-of-measure” is a type-safe, embedded DSL for dimensional analysis and units of measure in Kotlin.
Looks like a nice, simple way to avoid programmer mistakes. We were using something similar to this in C++ a few years back (unitsc++), although we ended up dropping it when we moved to just using metric units for everything, everywhere. Where it ended up failing - and what I’d warn you about - is that depending on how extensive your generated code is, your units system may end up getting confused with more complex constants. As long as you limit it to simple units, though, (velocities and distances work nicely) you should be fine.
I designed something like this in 1995-1996 (when java was a pretty new thing) for what was supposed to be a very general mapping and plotting infrastructure. The idea was that you could define sound speed in meters/sec, an acoustic travel time in minutes, and ask the product of these two quantities to express itself in thousands of yards. We were a bit discouraged when we realized how many different dimensional attributes we dealt with in oceanography and acoustics, but finally dropped it when we started introducing nominally dimensionless things like radians and sound speed ratios and salinity fractions because we didn’t have enough programmer months to implement this feature and still do the other stuff it really had to do. (First problem for a robotic system is likely that torque has the same dimensions as work.)
TLDR: Be sure to bound the problem or it will eat up your resources.