From b3c09c6047b823b35ab68e98a1d0462ac628e945 Mon Sep 17 00:00:00 2001 From: Andy Killorin <37423245+Speedy6451@users.noreply.github.com> Date: Sat, 6 Dec 2025 14:47:00 -0500 Subject: [PATCH] factored out header --- robot_controller/robot_controller.ino | 3 ++- robot_controller/trapezoidal.h | 14 ++++++++++++++ robot_controller/trapezoidal.ino | 14 +------------- 3 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 robot_controller/trapezoidal.h diff --git a/robot_controller/robot_controller.ino b/robot_controller/robot_controller.ino index 82f0ad1..10e0ed7 100644 --- a/robot_controller/robot_controller.ino +++ b/robot_controller/robot_controller.ino @@ -2,6 +2,7 @@ #include #include #include +#include "trapezoidal.h" const float ACCEL_LIMIT = 4.0; // cm/s/s const float VEL_LIMIT = 16.0; // cm/s @@ -91,7 +92,7 @@ void loop() { Serial.println(""); // move on if at setpoint TODO: check that the error is low as well - if (setpoint.completed) { + if (setpoint.complete) { switch (robot_state) { case FORWARD: robot_state = TURN; diff --git a/robot_controller/trapezoidal.h b/robot_controller/trapezoidal.h new file mode 100644 index 0000000..78dcaa8 --- /dev/null +++ b/robot_controller/trapezoidal.h @@ -0,0 +1,14 @@ +#pragma once + +// unitless trapezoidal +struct Trapezoidal { + float max_vel; + float max_acc; + float dist; +}; + +struct Setpoint { + float velocity; // unitless + float position; // unitless + bool complete; // the setpoint will no longer change +}; diff --git a/robot_controller/trapezoidal.ino b/robot_controller/trapezoidal.ino index 87799bc..e0ab6e5 100644 --- a/robot_controller/trapezoidal.ino +++ b/robot_controller/trapezoidal.ino @@ -1,18 +1,6 @@ +#include "trapezoidal.h" // trapezoidal impl, not fuzzed -// unitless trapezoidal -struct Trapezoidal { - float max_vel; - float max_acc; - float dist; -}; - -struct Setpoint { - float velocity; // unitless - float position; // unitless - bool complete; // the setpoint will no longer change -}; - // returns the position and velocity at the given time on a trapezoidal motion plan // this could be baked if too computationally expensive // not fully fuzzed