Skip to content

Commit

Permalink
Clean code (#91)
Browse files Browse the repository at this point in the history
* include new template zip file

* Clean code for beta release, cus we forgor

* update template
  • Loading branch information
Rocky14683 authored Apr 5, 2024
1 parent 4a12f7b commit 8dc950b
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 92 deletions.
Binary file modified [email protected]
Binary file not shown.
12 changes: 0 additions & 12 deletions include/VOSS/controller/BoomerangController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,9 @@ class BoomerangController : public AbstractController {
Pose carrotPoint;

utils::PID linear_pid, angular_pid;
double vel;
double exit_error;
double angular_exit_error;
double min_error;
bool can_reverse;
double settle_time;

double close;
double close_2;
int counter;
double prev_angle;
double min_vel;

public:
Expand All @@ -47,12 +39,8 @@ class BoomerangController : public AbstractController {
modify_linear_constants(double kP, double kI, double kD);
std::shared_ptr<BoomerangController>
modify_angular_constants(double kP, double kI, double kD);
std::shared_ptr<BoomerangController> modify_exit_error(double error);
std::shared_ptr<BoomerangController>
modify_angular_exit_error(double error);
std::shared_ptr<BoomerangController> modify_min_error(double error);
std::shared_ptr<BoomerangController> modify_lead_pct(double lead_pct);
std::shared_ptr<BoomerangController> modify_settle_time(double time);

friend class BoomerangControllerBuilder;
};
Expand Down
5 changes: 1 addition & 4 deletions include/VOSS/controller/BoomerangControllerBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ class BoomerangControllerBuilder {
double kD);
BoomerangControllerBuilder& with_angular_constants(double kP, double kI,
double kD);
BoomerangControllerBuilder& with_exit_error(double error);
BoomerangControllerBuilder& with_angular_exit_error(double error);
BoomerangControllerBuilder& with_min_error(double error);
BoomerangControllerBuilder& with_lead_pct(double lead_pct);
BoomerangControllerBuilder& with_settle_time(double time);
BoomerangControllerBuilder& with_min_error(double error);
BoomerangControllerBuilder& with_min_vel_for_thru(double min_vel);

std::shared_ptr<BoomerangController> build();
Expand Down
5 changes: 0 additions & 5 deletions include/VOSS/controller/PIDController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class PIDController : public AbstractController {
std::shared_ptr<PIDController> p;

utils::PID linear_pid, angular_pid;
double tracking_kP;
double min_error;
bool can_reverse;

Expand All @@ -35,11 +34,7 @@ class PIDController : public AbstractController {
double kD);
std::shared_ptr<PIDController>
modify_angular_constants(double kP, double kI, double kD);
std::shared_ptr<PIDController> modify_tracking_kp(double kP);
std::shared_ptr<PIDController> modify_exit_error(double exit_error);
std::shared_ptr<PIDController> modify_angular_exit_error(double exit_error);
std::shared_ptr<PIDController> modify_min_error(double min_error);
std::shared_ptr<PIDController> modify_settle_time(double settle_time);

friend class PIDControllerBuilder;
friend class BoomerangControllerBuilder;
Expand Down
1 change: 0 additions & 1 deletion include/VOSS/controller/PIDControllerBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class PIDControllerBuilder {
double kD);
PIDControllerBuilder& with_angular_constants(double kP, double kI,
double kD);
PIDControllerBuilder& with_tracking_kp(double kP);
PIDControllerBuilder& with_min_error(double error);
PIDControllerBuilder& with_min_vel_for_thru(double min_vel);

Expand Down
2 changes: 0 additions & 2 deletions include/VOSS/controller/SwingController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class SwingController : public AbstractController {

std::shared_ptr<SwingController>
modify_angular_constants(double kP, double kI, double kD);
std::shared_ptr<SwingController> modify_angular_exit_error(double error);
std::shared_ptr<SwingController> modify_settle_time(double time);

friend class SwingControllerBuilder;
};
Expand Down
33 changes: 0 additions & 33 deletions src/VOSS/controller/BoomerangController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ void BoomerangController::reset() {
this->linear_pid.reset();
this->angular_pid.reset();
this->can_reverse = false;
this->counter = 0;
}

std::shared_ptr<BoomerangController>
Expand All @@ -129,27 +128,6 @@ BoomerangController::modify_angular_constants(double kP, double kI, double kD) {
return this->p;
}

std::shared_ptr<BoomerangController>
BoomerangController::modify_exit_error(double exit_error) {
auto pid_mod = BoomerangControllerBuilder::from(*this)
.with_exit_error(exit_error)
.build();

this->p = pid_mod;

return this->p;
}

std::shared_ptr<BoomerangController>
BoomerangController::modify_angular_exit_error(double exit_error) {
auto pid_mod = BoomerangControllerBuilder::from(*this)
.with_angular_exit_error(exit_error)
.build();

this->p = pid_mod;

return this->p;
}

std::shared_ptr<BoomerangController>
BoomerangController::modify_min_error(double min_error) {
Expand All @@ -172,15 +150,4 @@ BoomerangController::modify_lead_pct(double lead_pct) {
return this->p;
}

std::shared_ptr<BoomerangController>
BoomerangController::modify_settle_time(double settle_time) {
auto pid_mod = BoomerangControllerBuilder::from(*this)
.with_settle_time(settle_time)
.build();

this->p = pid_mod;

return this->p;
}

} // namespace voss::controller
19 changes: 1 addition & 18 deletions src/VOSS/controller/BoomerangControllerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,36 +40,19 @@ BoomerangControllerBuilder::with_angular_constants(double kP, double kI,
return *this;
}

BoomerangControllerBuilder&
BoomerangControllerBuilder::with_exit_error(double error) {
this->ctrl.exit_error = error;
return *this;
}

BoomerangControllerBuilder&
BoomerangControllerBuilder::with_angular_exit_error(double error) {
this->ctrl.angular_exit_error = voss::to_radians(error);
return *this;
}

BoomerangControllerBuilder&
BoomerangControllerBuilder::with_min_error(double error) {
this->ctrl.min_error = error;
return *this;
}


BoomerangControllerBuilder&
BoomerangControllerBuilder::with_lead_pct(double lead_pct) {
this->ctrl.lead_pct = lead_pct;
return *this;
}

BoomerangControllerBuilder&
BoomerangControllerBuilder::with_settle_time(double time) {
this->ctrl.settle_time = (time > 0) ? time : 250;
return *this;
}

BoomerangControllerBuilder&
BoomerangControllerBuilder::with_min_vel_for_thru(double min_vel) {
this->ctrl.min_vel = min_vel;
Expand Down
9 changes: 0 additions & 9 deletions src/VOSS/controller/PIDController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,6 @@ PIDController::modify_angular_constants(double kP, double kI, double kD) {
return this->p;
}

std::shared_ptr<PIDController> PIDController::modify_tracking_kp(double kP) {
auto pid_mod =
PIDControllerBuilder::from(*this).with_tracking_kp(kP).build();

this->p = pid_mod;

return this->p;
}

std::shared_ptr<PIDController>
PIDController::modify_min_error(double min_error) {
auto pid_mod =
Expand Down
4 changes: 0 additions & 4 deletions src/VOSS/controller/PIDControllerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ PIDControllerBuilder::with_angular_constants(double kP, double kI, double kD) {
return *this;
}

PIDControllerBuilder& PIDControllerBuilder::with_tracking_kp(double kP) {
this->ctrl.tracking_kP = kP;
return *this;
}

PIDControllerBuilder& PIDControllerBuilder::with_min_error(double error) {
this->ctrl.min_error = error;
Expand Down
5 changes: 1 addition & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ auto pid = voss::controller::PIDControllerBuilder::new_builder(odom)
auto boomerang = voss::controller::BoomerangControllerBuilder::new_builder(odom)
.with_linear_constants(20, 0.02, 169)
.with_angular_constants(250, 0.05, 2435)
.with_exit_error(1.0)
.with_lead_pct(0.5)
.with_angular_exit_error(1.0)
.with_min_error(5)
.with_min_vel_for_thru(70)
.with_settle_time(200)
.with_min_error(5)
.build();

auto swing = voss::controller::SwingControllerBuilder::new_builder(odom)
Expand Down

0 comments on commit 8dc950b

Please sign in to comment.