Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions subprojects/robotpy-wpimath/semiwrap/controls/TrapezoidProfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ classes:
{
std::string clsNameCopy = clsName;

cls_Constraints
.def("__repr__", [clsNameCopy](const Constraints &self) {
return clsNameCopy + ".Constraints("
"maxVelocity=" + std::to_string(self.maxVelocity()) + ", "
"maxAcceleration=" + std::to_string(self.maxAcceleration()) + ")";
});

cls_State
.def(
py::init<Distance_t, Velocity_t>(),
Expand All @@ -71,23 +78,10 @@ classes:
ignore: true
Velocity_t, Acceleration_t:
param_override:
maxVelocity_:
name: maxVelocity
maxVelocity:
default: '0'
maxAcceleration_:
name: maxAcceleration
maxAcceleration:
default: '0'
template_inline_code: |
{
std::string clsNameCopy = clsName;

cls_Constraints
.def("__repr__", [clsNameCopy](const Constraints &self) {
return clsNameCopy + ".Constraints("
"maxVelocity=" + std::to_string(self.maxVelocity()) + ", "
"maxAcceleration=" + std::to_string(self.maxAcceleration()) + ")";
});
}
frc::TrapezoidProfile::State:
force_no_default_constructor: true
attributes:
Expand Down
24 changes: 24 additions & 0 deletions subprojects/robotpy-wpimath/tests/test_trapezoid_profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest

from wpimath import trajectory

trapezoid_profile_types = [
trajectory.TrapezoidProfile,
trajectory.TrapezoidProfileRadians,
]


@pytest.mark.parametrize("TrapezoidProfile", trapezoid_profile_types)
def test_constraints_repr(TrapezoidProfile):
expected_qualname = f"{TrapezoidProfile.__name__}.Constraints"
constraints = TrapezoidProfile.Constraints()

assert repr(constraints).startswith(f"{expected_qualname}(maxVelocity=0.")


@pytest.mark.parametrize("TrapezoidProfile", trapezoid_profile_types)
def test_state_repr(TrapezoidProfile):
expected_qualname = f"{TrapezoidProfile.__name__}.State"
constraints = TrapezoidProfile.State()

assert repr(constraints).startswith(f"{expected_qualname}(position=0.")
Loading