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

[wpiunits] Add Feedforward unit types #7064

Closed
wants to merge 12 commits into from
78 changes: 69 additions & 9 deletions wpiunits/generate_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def output(outPath, outfn, contents):
"Torque",
"Velocity<?>",
"Voltage",
"VoltagePerAnglePerTime",
"VoltagePerAnglePerTimeSquared",
"VoltagePerDistancePerTime",
"VoltagePerDistancePerTimeSquared",
]

# Configurations for all generated units
Expand All @@ -73,8 +77,13 @@ def output(outPath, outfn, contents):
},
"AngularAcceleration": {
"base_unit": "RadiansPerSecondPerSecond",
"multiply": {"Time": "AngularVelocity"},
"divide": {"Frequency": "AngularVelocity"},
"multiply": {
"Time": "AngularVelocity",
"VoltagePerAnglePerTimeSquared": "Voltage",
},
"divide": {
"Frequency": "AngularVelocity",
},
},
"AngularMomentum": {
"base_unit": "KilogramMetersSquaredPerSecond",
Expand All @@ -83,8 +92,14 @@ def output(outPath, outfn, contents):
},
"AngularVelocity": {
"base_unit": "RadiansPerSecond",
"multiply": {"Time": "Angle", "Frequency": "AngularAcceleration"},
"divide": {"Time": "AngularAcceleration"},
"multiply": {
"Time": "Angle",
"Frequency": "AngularAcceleration",
"VoltagePerAnglePerTime": "Voltage",
},
"divide": {
"Time": "AngularAcceleration",
},
"extra": inspect.cleandoc(
"""
default Frequency asFrequency() { return Hertz.of(baseUnitMagnitude()); }
Expand Down Expand Up @@ -115,6 +130,10 @@ def output(outPath, outfn, contents):
"Time": "Time",
"Torque": "Torque",
"Voltage": "Voltage",
"VoltagePerAnglePerTime": "VoltagePerAnglePerTime",
"VoltagePerAnglePerTimeSquared": "VoltagePerAnglePerTimeSquared",
"VoltagePerDistancePerTime": "VoltagePerDistancePerTime",
"VoltagePerDistancePerTimeSquared": "VoltagePerDistancePerTimeSquared",
},
"divide": {
"Time": "Frequency",
Expand Down Expand Up @@ -171,7 +190,10 @@ def output(outPath, outfn, contents):
},
"LinearAcceleration": {
"base_unit": "MetersPerSecondPerSecond",
"multiply": {"Time": "LinearVelocity"},
"multiply": {
"Time": "LinearVelocity",
"VoltagePerDistancePerTimeSquared": "Voltage",
},
"divide": {"Frequency": "LinearVelocity"},
},
"LinearMomentum": {
Expand All @@ -181,8 +203,14 @@ def output(outPath, outfn, contents):
},
"LinearVelocity": {
"base_unit": "MetersPerSecond",
"multiply": {"Time": "Distance", "Frequency": "LinearAcceleration"},
"divide": {"Time": "LinearAcceleration"},
"multiply": {
"Time": "Distance",
"Frequency": "LinearAcceleration",
"VoltagePerDistancePerTime": "Voltage",
},
"divide": {
"Time": "LinearAcceleration",
},
},
"Mass": {
"base_unit": "Kilograms",
Expand Down Expand Up @@ -261,7 +289,40 @@ def output(outPath, outfn, contents):
"multiply": {},
"divide": {},
},
"Voltage": {"base_unit": "Volts", "multiply": {"Current": "Power"}, "divide": {}},
"Voltage": {
"base_unit": "Volts",
"multiply": {"Current": "Power"},
"divide": {
"VoltagePerAnglePerTime": "AngularVelocity",
"AngularVelocity": "VoltagePerAnglePerTime",
"VoltagePerAnglePerTimeSquared": "AngularAcceleration",
"AngularAcceleration": "VoltagePerAnglePerTimeSquared",
"VoltagePerDistancePerTime": "LinearVelocity",
"LinearVelocity": "VoltagePerDistancePerTime",
"VoltagePerDistancePerTimeSquared": "LinearAcceleration",
"LinearAcceleration": "VoltagePerDistancePerTimeSquared",
},
},
"VoltagePerAnglePerTime": {
"base_unit": "VoltsPerRadianPerSecond",
"multiply": {"AngularVelocity": "Voltage"},
"divide": {},
},
"VoltagePerAnglePerTimeSquared": {
"base_unit": "VoltsPerRadianPerSecondSquared",
"multiply": {"AngularAcceleration": "Voltage"},
"divide": {},
},
"VoltagePerDistancePerTime": {
"base_unit": "VoltsPerMeterPerSecond",
"multiply": {"LinearVelocity": "Voltage"},
"divide": {},
},
"VoltagePerDistancePerTimeSquared": {
"base_unit": "VoltsPerMeterPerSecondSquared",
"multiply": {"LinearAcceleration": "Voltage"},
"divide": {},
},
}


Expand Down Expand Up @@ -311,7 +372,6 @@ def mtou(measure_name):


def main():

dirname, _ = os.path.split(os.path.abspath(__file__))

env = Environment(
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading