Skip to content

Commit

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

* Committing clang-format changes

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
Rocky14683 and github-actions[bot] authored Apr 2, 2024
1 parent 51a9b87 commit 4a12f7b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
Binary file modified [email protected]
Binary file not shown.
3 changes: 2 additions & 1 deletion include/VOSS/controller/ArcPIDControllerBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class ArcPIDControllerBuilder {

ArcPIDControllerBuilder& with_linear_constants(double kP, double kI,
double kD);
ArcPIDControllerBuilder& with_angular_constants(double kP, double kI, double kD);
ArcPIDControllerBuilder& with_angular_constants(double kP, double kI,
double kD);
/*
* The track width is measured from your robot.
* Due to turning scrub, you want to use a track width a few inches larger
Expand Down
16 changes: 8 additions & 8 deletions src/VOSS/controller/ArcPIDController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ ArcPIDController::get_command(bool reverse, bool thru,

if (std::isnan(arc_radius)) {
arc_radius = t;
arc_center = {
current_pos.x + t * a,
current_pos.y + t * d
};
//printf("arc center: %f %f\n", arc_center.x, arc_center.y);
arc_center = {current_pos.x + t * a, current_pos.y + t * d};
// printf("arc center: %f %f\n", arc_center.x, arc_center.y);
}

double distance_error = sqrt(b * b + e * e);
Expand Down Expand Up @@ -81,15 +78,18 @@ ArcPIDController::get_command(bool reverse, bool thru,
// right_speed = (t + track_width / 2) / t * lin_speed;
left_speed = lin_speed * (2 - track_width / arc_radius) / 2;
right_speed = lin_speed * (2 + track_width / arc_radius) / 2;
double tangent = atan2(current_pos.y - arc_center.y, current_pos.x - arc_center.x);
double tangent =
atan2(current_pos.y - arc_center.y, current_pos.x - arc_center.x);
if ((bool)(arc_radius > 0) != reverse) {
tangent += M_PI_2;
} else {
tangent -= M_PI_2;
}
//printf("current %f target %f\n", voss::to_degrees(current_angle), voss::to_degrees(tangent));
// printf("current %f target %f\n", voss::to_degrees(current_angle),
// voss::to_degrees(tangent));
printf("x %f y %f\n", current_pos.x, current_pos.y);
double ang_speed = angular_pid.update(voss::norm_delta(tangent - current_angle));
double ang_speed =
angular_pid.update(voss::norm_delta(tangent - current_angle));
left_speed -= ang_speed;
right_speed += ang_speed;
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/VOSS/controller/ArcPIDControllerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ ArcPIDControllerBuilder::with_linear_constants(double kP, double kI,
}

ArcPIDControllerBuilder&
ArcPIDControllerBuilder::with_angular_constants(double kP, double kI, double kD) {
ArcPIDControllerBuilder::with_angular_constants(double kP, double kI,
double kD) {
this->ctrl.angular_pid.set_constants(kP, kI, kD);
return *this;
}
Expand Down
7 changes: 4 additions & 3 deletions src/VOSS/exit_conditions/ToleranceAngularExitCondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

namespace voss::controller {

ToleranceAngularExitCondition::ToleranceAngularExitCondition(double tolerance, double tolerance_time)
ToleranceAngularExitCondition::ToleranceAngularExitCondition(
double tolerance, double tolerance_time)
: tolerance(voss::to_radians(tolerance)), tolerance_time(tolerance_time) {
}

bool ToleranceAngularExitCondition::is_met(Pose current_pose, bool thru) {
if (std::abs(voss::norm_delta(current_pose.theta.value() -
this->target_pose.theta.value())) <
this->tolerance) {
this->target_pose.theta.value())) <
this->tolerance) {
if (thru) {
return true;
}
Expand Down
14 changes: 8 additions & 6 deletions src/VOSS/exit_conditions/ToleranceExitCondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ void ToleranceExitCondition::reset() {
}
}

void ToleranceExitCondition::add_ang_exit(double angular_tolerance, double tolerance_time) {
this->ang_exit =
std::make_shared<ToleranceAngularExitCondition>(angular_tolerance, tolerance_time);
void ToleranceExitCondition::add_ang_exit(double angular_tolerance,
double tolerance_time) {
this->ang_exit = std::make_shared<ToleranceAngularExitCondition>(
angular_tolerance, tolerance_time);
}

void ToleranceExitCondition::add_lin_exit(double linear_tolerance, double tolerance_time) {
this->lin_exit =
std::make_shared<ToleranceLinearExitCondition>(linear_tolerance, tolerance_time);
void ToleranceExitCondition::add_lin_exit(double linear_tolerance,
double tolerance_time) {
this->lin_exit = std::make_shared<ToleranceLinearExitCondition>(
linear_tolerance, tolerance_time);
}
} // namespace voss::controller
3 changes: 2 additions & 1 deletion src/VOSS/exit_conditions/ToleranceLinearExitCondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

namespace voss::controller {

ToleranceLinearExitCondition::ToleranceLinearExitCondition(double tolerance, double tolerance_time)
ToleranceLinearExitCondition::ToleranceLinearExitCondition(
double tolerance, double tolerance_time)
: tolerance(tolerance), tolerance_time(tolerance_time) {
}

Expand Down

0 comments on commit 4a12f7b

Please sign in to comment.