Skip to content

Commit

Permalink
Committing clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Feb 14, 2024
1 parent 9e12bc3 commit 770f506
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 52 deletions.
28 changes: 18 additions & 10 deletions include/VOSS/chassis/AbstractChassis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class AbstractChassis {
void move_task(controller_ptr controller, double max, voss::Flags flags,
double exitTime);

void turn_task(controller_ptr controller, double max, voss::Flags flags, voss::AngularDirection direction,
double exitTime);
void turn_task(controller_ptr controller, double max, voss::Flags flags,
voss::AngularDirection direction, double exitTime);

public:
AbstractChassis(controller_ptr default_controller);
Expand All @@ -44,15 +44,23 @@ class AbstractChassis {
voss::Flags flags = voss::Flags::NONE, double exitTime = 22500);

void turn(double target, controller_ptr controller, double max = 100.0,
voss::Flags flags = voss::Flags::NONE, voss::AngularDirection direction = voss::AngularDirection::AUTO, double exitTime = 22500);
voss::Flags flags = voss::Flags::NONE,
voss::AngularDirection direction = voss::AngularDirection::AUTO,
double exitTime = 22500);
void turn(double target, double max = 100.0,
voss::Flags flags = voss::Flags::NONE, voss::AngularDirection direction = voss::AngularDirection::AUTO, double exitTime = 22500);
void turn_to(Point target, controller_ptr controller, double max = 100.0,
voss::Flags flags = voss::Flags::NONE, voss::AngularDirection direction = voss::AngularDirection::AUTO,
double exitTime = 22500);
void turn_to(Point target, double max = 100.0,
voss::Flags flags = voss::Flags::NONE, voss::AngularDirection direction = voss::AngularDirection::AUTO,
double exitTime = 22500);
voss::Flags flags = voss::Flags::NONE,
voss::AngularDirection direction = voss::AngularDirection::AUTO,
double exitTime = 22500);
void
turn_to(Point target, controller_ptr controller, double max = 100.0,
voss::Flags flags = voss::Flags::NONE,
voss::AngularDirection direction = voss::AngularDirection::AUTO,
double exitTime = 22500);
void
turn_to(Point target, double max = 100.0,
voss::Flags flags = voss::Flags::NONE,
voss::AngularDirection direction = voss::AngularDirection::AUTO,
double exitTime = 22500);
};

} // namespace voss::chassis
5 changes: 3 additions & 2 deletions include/VOSS/controller/AbstractController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ class AbstractController {
AbstractController(std::shared_ptr<localizer::AbstractLocalizer> l);

virtual chassis::ChassisCommand get_command(bool reverse, bool thru) = 0;
virtual chassis::ChassisCommand get_angular_command(bool reverse,
bool thru, voss::AngularDirection direction) = 0;
virtual chassis::ChassisCommand
get_angular_command(bool reverse, bool thru,
voss::AngularDirection direction) = 0;

virtual void reset() = 0;

Expand Down
5 changes: 3 additions & 2 deletions include/VOSS/controller/ArcPIDController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ class ArcPIDController : public AbstractController {
double linear_pid(double error);

chassis::ChassisCommand get_command(bool reverse, bool thru) override;
chassis::ChassisCommand get_angular_command(bool reverse,
bool thru, voss::AngularDirection direction) override;
chassis::ChassisCommand
get_angular_command(bool reverse, bool thru,
voss::AngularDirection direction) override;

void reset() override;

Expand Down
5 changes: 3 additions & 2 deletions include/VOSS/controller/BoomerangController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ class BoomerangController : public AbstractController {
BoomerangController(std::shared_ptr<localizer::AbstractLocalizer> l);

chassis::ChassisCommand get_command(bool reverse, bool thru) override;
chassis::ChassisCommand get_angular_command(bool reverse,
bool thru, voss::AngularDirection direction) override;
chassis::ChassisCommand
get_angular_command(bool reverse, bool thru,
voss::AngularDirection direction) override;

void reset();

Expand Down
5 changes: 3 additions & 2 deletions include/VOSS/controller/PIDController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ class PIDController : public AbstractController {
double angular_pid(double error);

chassis::ChassisCommand get_command(bool reverse, bool thru) override;
chassis::ChassisCommand get_angular_command(bool reverse,
bool thru, voss::AngularDirection direction) override;
chassis::ChassisCommand
get_angular_command(bool reverse, bool thru,
voss::AngularDirection direction) override;

void reset() override;

Expand Down
5 changes: 3 additions & 2 deletions include/VOSS/controller/SwingController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class SwingController : public AbstractController {
SwingController(std::shared_ptr<localizer::AbstractLocalizer> l);

chassis::ChassisCommand get_command(bool reverse, bool thru) override;
chassis::ChassisCommand get_angular_command(bool reverse,
bool thru, voss::AngularDirection direction) override;
chassis::ChassisCommand
get_angular_command(bool reverse, bool thru,
voss::AngularDirection direction) override;

double angular_pid(double error);

Expand Down
2 changes: 1 addition & 1 deletion include/VOSS/utils/angle.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <cmath>
#include "VOSS/utils/flags.hpp"
#include <cmath>

namespace voss {

Expand Down
6 changes: 1 addition & 5 deletions include/VOSS/utils/flags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,5 @@ auto inline operator&(Flags flag1, Flags flag2) {
static_cast<uint8_t>(flag2));
}

enum class AngularDirection {
AUTO,
COUNTERCLOCKWISE,
CLOCKWISE
};
enum class AngularDirection { AUTO, COUNTERCLOCKWISE, CLOCKWISE };
} // namespace voss
32 changes: 20 additions & 12 deletions src/VOSS/chassis/AbstractChassis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ void AbstractChassis::move_task(controller_ptr controller, double max,
}

void AbstractChassis::turn_task(controller_ptr controller, double max,
voss::Flags flags, voss::AngularDirection direction, double exitTime) {
voss::Flags flags,
voss::AngularDirection direction,
double exitTime) {
int t = 0;
pros::Task running_t([&, controller]() {
controller->reset();
while (!this->execute(
controller->get_angular_command(flags & voss::Flags::REVERSE,
flags & voss::Flags::THRU, direction),
max)) {
while (!this->execute(controller->get_angular_command(
flags & voss::Flags::REVERSE,
flags & voss::Flags::THRU, direction),
max)) {
if (pros::competition::is_disabled()) {
return;
}
Expand Down Expand Up @@ -94,13 +96,15 @@ void AbstractChassis::move(Pose target, controller_ptr controller, double max,
this->move_task(controller, max, flags, exitTime);
}

void AbstractChassis::turn(double target, double max, voss::Flags flags, voss::AngularDirection direction,
double exitTime) {
this->turn(target, this->default_controller, max, flags, direction, exitTime);
void AbstractChassis::turn(double target, double max, voss::Flags flags,
voss::AngularDirection direction, double exitTime) {
this->turn(target, this->default_controller, max, flags, direction,
exitTime);
}

void AbstractChassis::turn(double target, controller_ptr controller, double max,
voss::Flags flags, voss::AngularDirection direction, double exitTime) {
voss::Flags flags, voss::AngularDirection direction,
double exitTime) {
// this->m.take();

controller->set_target({0, 0, 0}, false);
Expand All @@ -109,13 +113,17 @@ void AbstractChassis::turn(double target, controller_ptr controller, double max,
this->turn_task(controller, max, flags, direction, exitTime);
}

void AbstractChassis::turn_to(Point target, double max, voss::Flags flags, voss::AngularDirection direction,
void AbstractChassis::turn_to(Point target, double max, voss::Flags flags,
voss::AngularDirection direction,
double exitTime) {
this->turn_to(target, this->default_controller, max, flags, direction, exitTime);
this->turn_to(target, this->default_controller, max, flags, direction,
exitTime);
}

void AbstractChassis::turn_to(Point target, controller_ptr controller,
double max, voss::Flags flags, voss::AngularDirection direction, double exitTime) {
double max, voss::Flags flags,
voss::AngularDirection direction,
double exitTime) {
// this->m.take();

controller->set_target({target.x, target.y, 361},
Expand Down
5 changes: 3 additions & 2 deletions src/VOSS/controller/ArcPIDController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ chassis::ChassisCommand ArcPIDController::get_command(bool reverse, bool thru) {
return chassis::ChassisCommand{chassis::Voltages{left_speed, right_speed}};
}

chassis::ChassisCommand ArcPIDController::get_angular_command(bool reverse,
bool thru, voss::AngularDirection direction) {
chassis::ChassisCommand
ArcPIDController::get_angular_command(bool reverse, bool thru,
voss::AngularDirection direction) {
return chassis::ChassisCommand{chassis::Stop{}};
}

Expand Down
5 changes: 3 additions & 2 deletions src/VOSS/controller/BoomerangController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ chassis::ChassisCommand BoomerangController::get_command(bool reverse,
return child->get_command(reverse, thru);
}

chassis::ChassisCommand BoomerangController::get_angular_command(bool reverse,
bool thru, voss::AngularDirection direction) {
chassis::ChassisCommand
BoomerangController::get_angular_command(bool reverse, bool thru,
voss::AngularDirection direction) {
child->set_target(target, false);
child->set_angular_target(angular_target, false);
return child->get_angular_command(reverse, thru, direction);
Expand Down
11 changes: 7 additions & 4 deletions src/VOSS/controller/PIDController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ chassis::ChassisCommand PIDController::get_command(bool reverse, bool thru) {
chassis::Voltages{lin_speed - ang_speed, lin_speed + ang_speed}};
}

chassis::ChassisCommand PIDController::get_angular_command(bool reverse,
bool thru, voss::AngularDirection direction) {
chassis::ChassisCommand
PIDController::get_angular_command(bool reverse, bool thru,
voss::AngularDirection direction) {
counter += 10;
double current_angle = this->l->get_orientation_rad();
double target_angle = 0;
Expand All @@ -126,9 +127,11 @@ chassis::ChassisCommand PIDController::get_angular_command(bool reverse,
}

if (!turn_overshoot) {
if (direction == voss::AngularDirection::COUNTERCLOCKWISE && angular_error < 0) {
if (direction == voss::AngularDirection::COUNTERCLOCKWISE &&
angular_error < 0) {
angular_error += 2 * M_PI;
} else if (direction == voss::AngularDirection::CLOCKWISE && angular_error > 0) {
} else if (direction == voss::AngularDirection::CLOCKWISE &&
angular_error > 0) {
angular_error -= 2 * M_PI;
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/VOSS/controller/SwingController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ chassis::ChassisCommand SwingController::get_command(bool reverse, bool thru) {
return chassis::ChassisCommand{chassis::Stop{}};
}

chassis::ChassisCommand SwingController::get_angular_command(bool reverse,
bool thru, voss::AngularDirection direction) {
chassis::ChassisCommand
SwingController::get_angular_command(bool reverse, bool thru,
voss::AngularDirection direction) {
counter += 10;
double current_angle = this->l->get_orientation_rad();
double target_angle = 0;
Expand All @@ -32,9 +33,11 @@ chassis::ChassisCommand SwingController::get_angular_command(bool reverse,
}

if (!turn_overshoot) {
if (direction == voss::AngularDirection::COUNTERCLOCKWISE && angular_error < 0) {
if (direction == voss::AngularDirection::COUNTERCLOCKWISE &&
angular_error < 0) {
angular_error += 2 * M_PI;
} else if (direction == voss::AngularDirection::CLOCKWISE && angular_error > 0) {
} else if (direction == voss::AngularDirection::CLOCKWISE &&
angular_error > 0) {
angular_error -= 2 * M_PI;
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ void opcontrol() {

if (master.get_digital_new_press(DIGITAL_Y)) {
odom->set_pose(voss::Pose{0.0, 0.0, 0});
chassis.turn(270, 100, voss::Flags::NONE, voss::AngularDirection::COUNTERCLOCKWISE);
chassis.turn(270, 100, voss::Flags::NONE,
voss::AngularDirection::COUNTERCLOCKWISE);
chassis.turn(0);
chassis.turn(-270, swing, 100, voss::Flags::NONE, voss::AngularDirection::CLOCKWISE);
chassis.turn(-270, swing, 100, voss::Flags::NONE,
voss::AngularDirection::CLOCKWISE);
}

pros::lcd::clear_line(1);
Expand Down

0 comments on commit 770f506

Please sign in to comment.