Add getters/setters for Jerk in Motion/PulseGen
This allows us to make tests that expect jerk to be the same across two axes, even if they're statically configured differently.pull/71/head
parent
606b22a9ad
commit
5e04d4ccaf
|
|
@ -151,6 +151,20 @@ public:
|
||||||
axisData[axis].ctrl.SetAcceleration(accel);
|
axisData[axis].ctrl.SetAcceleration(accel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get current jerk for the selected axis
|
||||||
|
/// @param axis axis affected
|
||||||
|
/// @returns jerk
|
||||||
|
steps_t Jerk(Axis axis) const {
|
||||||
|
return axisData[axis].ctrl.Jerk();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set maximum jerk for the selected axis
|
||||||
|
/// @param axis axis affected
|
||||||
|
/// @param max_jerk maximum jerk
|
||||||
|
void SetJerk(Axis axis, steps_t max_jerk) {
|
||||||
|
return axisData[axis].ctrl.SetJerk(max_jerk);
|
||||||
|
}
|
||||||
|
|
||||||
/// State machine doing all the planning and stepping. Called by the stepping ISR.
|
/// State machine doing all the planning and stepping. Called by the stepping ISR.
|
||||||
/// @returns the interval for the next tick
|
/// @returns the interval for the next tick
|
||||||
st_timer_t Step();
|
st_timer_t Step();
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,12 @@ class PulseGen {
|
||||||
public:
|
public:
|
||||||
PulseGen(steps_t max_jerk, steps_t acceleration);
|
PulseGen(steps_t max_jerk, steps_t acceleration);
|
||||||
|
|
||||||
|
/// @returns the jerk for the axis
|
||||||
|
steps_t Jerk() const { return max_jerk; };
|
||||||
|
|
||||||
|
/// Set maximum jerk for the axis
|
||||||
|
void SetJerk(steps_t max_jerk) { this->max_jerk = max_jerk; };
|
||||||
|
|
||||||
/// @returns the acceleration for the axis
|
/// @returns the acceleration for the axis
|
||||||
steps_t Acceleration() const { return acceleration; };
|
steps_t Acceleration() const { return acceleration; };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,13 @@ TEST_CASE("motion::basic", "[motion]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("motion::dual_move_fwd", "[motion]") {
|
TEST_CASE("motion::dual_move_fwd", "[motion]") {
|
||||||
// check for configuration values that we cannot change but should match for this test
|
|
||||||
// to function as expected (maybe this should be a static_assert?)
|
|
||||||
REQUIRE(config::idler.jerk == config::selector.jerk);
|
|
||||||
|
|
||||||
// enqueue moves on two axes
|
// enqueue moves on two axes
|
||||||
REQUIRE(motion.QueueEmpty());
|
REQUIRE(motion.QueueEmpty());
|
||||||
|
|
||||||
|
// ensure the same jerk is set on both
|
||||||
|
motion.SetJerk(Idler, motion.Jerk(Selector));
|
||||||
|
REQUIRE(motion.Jerk(Idler) == motion.Jerk(Selector));
|
||||||
|
|
||||||
// ensure the same acceleration is set on both
|
// ensure the same acceleration is set on both
|
||||||
motion.SetAcceleration(Idler, motion.Acceleration(Selector));
|
motion.SetAcceleration(Idler, motion.Acceleration(Selector));
|
||||||
REQUIRE(motion.Acceleration(Idler) == motion.Acceleration(Selector));
|
REQUIRE(motion.Acceleration(Idler) == motion.Acceleration(Selector));
|
||||||
|
|
@ -57,13 +57,13 @@ TEST_CASE("motion::dual_move_fwd", "[motion]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("motion::dual_move_inv", "[motion]") {
|
TEST_CASE("motion::dual_move_inv", "[motion]") {
|
||||||
// check for configuration values that we cannot change but should match for this test
|
|
||||||
// to function as expected (maybe this should be a static_assert?)
|
|
||||||
REQUIRE(config::idler.jerk == config::selector.jerk);
|
|
||||||
|
|
||||||
// enqueue moves on two axes
|
// enqueue moves on two axes
|
||||||
REQUIRE(motion.QueueEmpty());
|
REQUIRE(motion.QueueEmpty());
|
||||||
|
|
||||||
|
// ensure the same jerk is set on both
|
||||||
|
motion.SetJerk(Idler, motion.Jerk(Selector));
|
||||||
|
REQUIRE(motion.Jerk(Idler) == motion.Jerk(Selector));
|
||||||
|
|
||||||
// ensure the same acceleration is set on both
|
// ensure the same acceleration is set on both
|
||||||
motion.SetAcceleration(Idler, motion.Acceleration(Selector));
|
motion.SetAcceleration(Idler, motion.Acceleration(Selector));
|
||||||
REQUIRE(motion.Acceleration(Idler) == motion.Acceleration(Selector));
|
REQUIRE(motion.Acceleration(Idler) == motion.Acceleration(Selector));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue