Skip to content

Commit ab5271f

Browse files
authored
Spring 2025 Improvements (#115)
* improvements * print carrot point in boomerang debug * update clang-tidy action * bump version number
1 parent 9476330 commit ab5271f

20 files changed

+314
-110
lines changed

.github/workflows/clang-tidy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ jobs:
2525
- name: Build Project
2626
run: pros build-compile-commands
2727
- name: Run clang-tidy
28-
uses: ZedThree/clang-tidy-review@v0.14.0
28+
uses: ZedThree/clang-tidy-review@v0.20.1

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ EXCLUDE_COLD_LIBRARIES:=
2727
IS_LIBRARY:=1
2828
# TODO: CHANGE THIS!
2929
LIBNAME:=VOSS
30-
VERSION:=0.1.4
30+
VERSION:=0.1.5
3131
# EXCLUDE_SRC_FROM_LIB= $(SRCDIR)/unpublishedfile.c
3232
# this line excludes opcontrol.c and similar files
3333
EXCLUDE_SRC_FROM_LIB+=$(foreach file, $(SRCDIR)/main,$(foreach cext,$(CEXTS),$(file).$(cext)) $(foreach cxxext,$(CXXEXTS),$(file).$(cxxext)))

include/VOSS/api.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "selector/Selector.hpp"
3636

3737
#include "utils/angle.hpp"
38+
#include "utils/debug.hpp"
3839
#include "utils/flags.hpp"
3940
#include "utils/Point.hpp"
4041
#include "utils/Pose.hpp"

include/VOSS/chassis/AbstractChassis.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class AbstractChassis {
3939
virtual bool execute(DiffChassisCommand cmd, double max) = 0;
4040
virtual void set_brake_mode(pros::motor_brake_mode_e mode) = 0;
4141

42+
void wait_until_done() const;
43+
bool is_running() const;
44+
4245
void move(double distance, double max = 100.0,
4346
voss::Flags flags = voss::Flags::NONE);
4447

include/VOSS/controller/BoomerangController.hpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,34 @@
1111
namespace voss::controller {
1212

1313
class BoomerangController : public AbstractController {
14+
public:
15+
enum class ThruBehavior { // affects calculation of lin_speed on thru movements
16+
MIN_VEL, // use linear PID, but enforce a minimum velocity
17+
FULL_SPEED // no PID, go full speed
18+
};
19+
enum class CosineScaling {
20+
MIN_ERR, // only do cosine scaling within the minimum err
21+
ALL_THE_TIME // do cosine scaling all the time
22+
};
23+
enum class MinErrBehavior {
24+
TARGET_HEADING, // directly switch from turning towards carrot point to turning towards target heading
25+
SCALE_TARGET_HEADING, // scale between turning towards carrot point to turning towards target point
26+
};
1427
protected:
1528
std::shared_ptr<BoomerangController> p;
1629
double lead_pct;
17-
Pose carrotPoint;
1830

1931
utils::PID linear_pid, angular_pid;
2032
double min_error;
2133
bool can_reverse;
2234

2335
double min_vel;
2436

37+
ThruBehavior thru_behavior = ThruBehavior::FULL_SPEED;
38+
CosineScaling cosine_scaling = CosineScaling::ALL_THE_TIME;
39+
MinErrBehavior min_err_behavior = MinErrBehavior::SCALE_TARGET_HEADING;
40+
bool enable_overturn = false;
41+
2542
public:
2643
BoomerangController(std::shared_ptr<localizer::AbstractLocalizer> l);
2744

@@ -42,6 +59,11 @@ class BoomerangController : public AbstractController {
4259
std::shared_ptr<BoomerangController> modify_min_error(double error);
4360
std::shared_ptr<BoomerangController> modify_lead_pct(double lead_pct);
4461

62+
void set_thru_behavior(ThruBehavior thru_behavior);
63+
void set_cosine_scaling(CosineScaling cosine_scaling);
64+
void set_min_err_behavior(MinErrBehavior min_err_behavior);
65+
void set_overturn(bool overturn);
66+
4567
friend class BoomerangControllerBuilder;
4668
};
4769

include/VOSS/controller/PIDController.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,36 @@
77
namespace voss::controller {
88

99
class PIDController : public AbstractController {
10+
public:
11+
enum class ThruBehavior { // affects calculation of lin_speed on thru movements
12+
MIN_VEL, // use linear PID, but enforce a minimum velocity
13+
FULL_SPEED // no PID, go full speed
14+
};
15+
enum class CosineScaling {
16+
MIN_ERR, // only do cosine scaling within the minimum err
17+
ALL_THE_TIME // do cosine scaling all the time
18+
};
19+
enum class MinErrBehavior {
20+
NO_ANG_PID, // no angular PID, set ang_speed to 0
21+
SCALE_ANG_PID, // scale output of angular pid so it reaches 0 at half of min_err
22+
MAINTAIN_HEADING // maintain heading of when it entered min_err
23+
};
1024
protected:
1125
std::shared_ptr<PIDController> p;
1226

1327
utils::PID linear_pid, angular_pid;
1428
double min_error;
1529
bool can_reverse;
30+
double min_err_heading;
1631

1732
double min_vel;
1833
bool turn_overshoot;
1934

35+
ThruBehavior thru_behavior = ThruBehavior::FULL_SPEED;
36+
CosineScaling cosine_scaling = CosineScaling::MIN_ERR;
37+
MinErrBehavior min_err_behavior = MinErrBehavior::MAINTAIN_HEADING;
38+
bool enable_overturn = false;
39+
2040
public:
2141
PIDController(std::shared_ptr<localizer::AbstractLocalizer> l);
2242

@@ -36,6 +56,11 @@ class PIDController : public AbstractController {
3656
modify_angular_constants(double kP, double kI, double kD);
3757
std::shared_ptr<PIDController> modify_min_error(double min_error);
3858

59+
void set_thru_behavior(ThruBehavior thru_behavior);
60+
void set_cosine_scaling(CosineScaling cosine_scaling);
61+
void set_min_err_behavior(MinErrBehavior min_err_behavior);
62+
void set_overturn(bool overturn);
63+
3964
friend class PIDControllerBuilder;
4065
friend class BoomerangControllerBuilder;
4166
};

include/VOSS/localizer/AbstractLocalizer.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class AbstractLocalizer {
2727
double get_orientation_rad();
2828
double get_orientation_deg();
2929
Point get_position();
30+
void wait_until_near(Point target, double tolerance);
31+
void wait_until_distance(double distance);
3032
virtual void calibrate() = 0;
3133
};
3234

include/VOSS/localizer/TrackingWheelLocalizer.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class TrackingWheelLocalizer : public AbstractLocalizer {
1212
protected:
1313
std::atomic<double> prev_left_pos, prev_right_pos, prev_middle_pos;
1414
AtomicPose prev_pose;
15+
AtomicPose real_pose;
16+
Pose local_offset = {0, 0, 0};
1517

1618
std::atomic<double> left_right_dist, middle_dist;
1719
std::unique_ptr<AbstractTrackingWheel> left_tracking_wheel,
@@ -28,6 +30,7 @@ class TrackingWheelLocalizer : public AbstractLocalizer {
2830
void calibrate() override;
2931
void set_pose(Pose pose) override;
3032
void set_pose(double x, double y, double theta) override;
33+
void set_local_offset(Pose local_offset);
3134

3235
friend class TrackingWheelLocalizerBuilder;
3336
};

include/VOSS/utils/debug.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
namespace voss {
4+
5+
void enable_debug();
6+
void disable_debug();
7+
bool get_debug();
8+
9+
}

src/VOSS/chassis/AbstractChassis.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ AbstractChassis::AbstractChassis(controller_ptr default_controller, ec_ptr ec) {
1313
this->default_ec = std::move(ec);
1414
}
1515

16+
void AbstractChassis::wait_until_done() const {
17+
while (task_running) {
18+
pros::delay(constants::MOTOR_UPDATE_DELAY);
19+
}
20+
}
21+
22+
bool AbstractChassis::is_running() const {
23+
return task_running;
24+
}
25+
1626
void AbstractChassis::move_task(controller_ptr controller, ec_ptr ec,
1727
double max, voss::Flags flags) {
1828

@@ -154,7 +164,7 @@ void AbstractChassis::turn_to(Point target, controller_ptr controller,
154164
ec_ptr ec, double max, voss::Flags flags,
155165
voss::AngularDirection direction) {
156166
while (this->task_running) {
157-
pros::delay(10);
167+
pros::delay(constants::MOTOR_UPDATE_DELAY);
158168
}
159169
this->task_running = true;
160170

0 commit comments

Comments
 (0)