From 8312d53c663ee19d5b3c183c1f62f01a5bd8b2d7 Mon Sep 17 00:00:00 2001 From: Jess Zarchi Date: Tue, 3 Dec 2024 21:59:26 -0800 Subject: [PATCH] Added motor group exit condition wrapper --- include/EZ-Template/PID.hpp | 10 ++++++++++ src/EZ-Template/PID.cpp | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/include/EZ-Template/PID.hpp b/include/EZ-Template/PID.hpp index f0f35783..72b8ff5c 100644 --- a/include/EZ-Template/PID.hpp +++ b/include/EZ-Template/PID.hpp @@ -222,6 +222,16 @@ class PID { */ ez::exit_output exit_condition(std::vector sensor, bool print = false); + /** + * Iterative exit condition for PID. + * + * \param sensor + * Pros motor group on your mechanism. + * \param print = false + * if true, prints when complete. + */ + ez::exit_output exit_condition(pros::MotorGroup sensor, bool print = false); + /** * Sets the name of the PID that prints during exit conditions. * diff --git a/src/EZ-Template/PID.cpp b/src/EZ-Template/PID.cpp index 2b3981f4..7a633e91 100644 --- a/src/EZ-Template/PID.cpp +++ b/src/EZ-Template/PID.cpp @@ -249,4 +249,12 @@ exit_output PID::exit_condition(std::vector sensor, bool print) { } return exit_condition(print); +} + +exit_output PID::exit_condition(pros::MotorGroup sensor, bool print) { + std::vector vector_sensor; + for (i = 0; i < sensor.size(); i++) { + vector_sensor.push_back(pros::Motor(sensor.get_port(i))); + } + return exit_condition(vector_sensor, print); } \ No newline at end of file