mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
[wpimath] Replace Speeds with Velocities (#8479)
I left "free speed" alone since that's the technical term for it. In general, velocity is a vector quantity, and speed is a magnitude (i.e., a strictly positive value). This PR also replaces the speed verbiage in MotorController with duty cycle. Fixes #8423.
This commit is contained in:
84
wpimath/src/main/python/semiwrap/ChassisVelocities.yml
Normal file
84
wpimath/src/main/python/semiwrap/ChassisVelocities.yml
Normal file
@@ -0,0 +1,84 @@
|
||||
extra_includes:
|
||||
- wpystruct.h
|
||||
|
||||
classes:
|
||||
wpi::math::ChassisVelocities:
|
||||
force_no_default_constructor: true
|
||||
attributes:
|
||||
vx:
|
||||
vy:
|
||||
omega:
|
||||
methods:
|
||||
ToTwist2d:
|
||||
Discretize:
|
||||
overloads:
|
||||
wpi::units::meters_per_second_t, wpi::units::meters_per_second_t, wpi::units::radians_per_second_t, wpi::units::second_t:
|
||||
const ChassisVelocities&, wpi::units::second_t:
|
||||
operator+:
|
||||
operator-:
|
||||
overloads:
|
||||
const ChassisVelocities& [const]:
|
||||
'[const]':
|
||||
operator*:
|
||||
operator/:
|
||||
operator==:
|
||||
ToRobotRelative:
|
||||
ToFieldRelative:
|
||||
|
||||
inline_code: |
|
||||
cls_ChassisVelocities
|
||||
.def(
|
||||
py::init<
|
||||
wpi::units::meters_per_second_t, wpi::units::meters_per_second_t,
|
||||
wpi::units::radians_per_second_t
|
||||
>(),
|
||||
py::arg("vx") = 0, py::arg("vy") = 0, py::arg("omega") = 0
|
||||
)
|
||||
.def_static("fromFeet", [](wpi::units::feet_per_second_t vx, wpi::units::feet_per_second_t vy, wpi::units::radians_per_second_t omega){
|
||||
return ChassisVelocities{vx, vy, omega};
|
||||
}, py::arg("vx") = 0, py::arg("vy") = 0, py::arg("omega") = 0)
|
||||
.def_property("vx_fps",
|
||||
[](ChassisVelocities * self) -> wpi::units::feet_per_second_t {
|
||||
return self->vx;
|
||||
},
|
||||
[](ChassisVelocities * self, wpi::units::feet_per_second_t vx) {
|
||||
self->vx = vx;
|
||||
}
|
||||
)
|
||||
.def_property("vy_fps",
|
||||
[](ChassisVelocities * self) -> wpi::units::feet_per_second_t {
|
||||
return self->vy;
|
||||
},
|
||||
[](ChassisVelocities * self, wpi::units::feet_per_second_t vy) {
|
||||
self->vy = vy;
|
||||
}
|
||||
)
|
||||
.def_property("omega_dps",
|
||||
[](ChassisVelocities * self) -> wpi::units::degrees_per_second_t {
|
||||
return self->omega;
|
||||
},
|
||||
[](ChassisVelocities * self, wpi::units::degrees_per_second_t omega) {
|
||||
self->omega = omega;
|
||||
}
|
||||
)
|
||||
.def("__len__", [](const ChassisVelocities &self) { return 3; })
|
||||
.def("__getitem__", [](const ChassisVelocities &self, int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return self.vx();
|
||||
case 1:
|
||||
return self.vy();
|
||||
case 2:
|
||||
return self.omega();
|
||||
default:
|
||||
throw std::out_of_range("ChassisVelocities index out of range");
|
||||
}
|
||||
})
|
||||
.def("__repr__", [](const ChassisVelocities &cs) -> std::string {
|
||||
return "ChassisVelocities(vx=" + std::to_string(cs.vx()) + ", "
|
||||
"vy=" + std::to_string(cs.vy()) + ", "
|
||||
"omega=" + std::to_string(cs.omega()) + ")";
|
||||
})
|
||||
;
|
||||
|
||||
SetupWPyStruct<wpi::math::ChassisVelocities>(cls_ChassisVelocities);
|
||||
Reference in New Issue
Block a user