Skip to content

Commit 7ac5410

Browse files
fix boomerang (#112)
* fix boomerang * Committing clang-format changes --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 66e1e2b commit 7ac5410

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

VOSS@0.1.3.zip

-249 KB
Binary file not shown.

src/VOSS/controller/BoomerangController.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,21 @@ BoomerangController::get_command(bool reverse, bool thru,
2828
double dy = target.y - current_pos.y;
2929

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

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

3940
double angle_error;
40-
angle_error = atan2(dy, dx) - current_angle;
41+
if (!reverse) {
42+
angle_error = atan2(dy, dx) - current_angle;
43+
} else {
44+
angle_error = atan2(-dy, -dx) - current_angle;
45+
}
4146

4247
angle_error = voss::norm_delta(angle_error);
4348

0 commit comments

Comments
 (0)