Skip to content

Commit

Permalink
fix boomerang (#112)
Browse files Browse the repository at this point in the history
* fix boomerang

* Committing clang-format changes

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
AndrewLuGit and github-actions[bot] authored Nov 23, 2024
1 parent 66e1e2b commit 7ac5410
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Binary file modified [email protected]
Binary file not shown.
13 changes: 9 additions & 4 deletions src/VOSS/controller/BoomerangController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,21 @@ BoomerangController::get_command(bool reverse, bool thru,
double dy = target.y - current_pos.y;

double distance_error = sqrt(dx * dx + dy * dy);
double at = voss::to_radians(target.theta.value());
double at = target.theta.value();

this->carrotPoint = {this->target.x - distance_error * cos(at) * lead_pct,
this->target.y - distance_error * sin(at) * lead_pct,
target.theta};
double current_angle =
this->l->get_orientation_rad() + (reverse ? M_PI : 0);
dx = carrotPoint.x - current_pos.x;
dy = carrotPoint.y - current_pos.y;
double current_angle = this->l->get_orientation_rad();

double angle_error;
angle_error = atan2(dy, dx) - current_angle;
if (!reverse) {
angle_error = atan2(dy, dx) - current_angle;
} else {
angle_error = atan2(-dy, -dx) - current_angle;
}

angle_error = voss::norm_delta(angle_error);

Expand Down

0 comments on commit 7ac5410

Please sign in to comment.