Add catapult to collision avoidance
Signed-off-by: Henry Speiser <henry@speiser.net>
Change-Id: I504fbfc23d549f25c8e345818f7ee84f183508c6
Signed-off-by: Milind Upadhyay <milind.upadhyay@gmail.com>
diff --git a/y2022/control_loops/superstructure/superstructure.cc b/y2022/control_loops/superstructure/superstructure.cc
index b9e0698..bb8d4d0 100644
--- a/y2022/control_loops/superstructure/superstructure.cc
+++ b/y2022/control_loops/superstructure/superstructure.cc
@@ -279,9 +279,15 @@
turret_goal != nullptr &&
std::abs(turret_goal->unsafe_goal() - turret_.position()) <
kTurretGoalThreshold;
+ const bool collided = collision_avoidance_.IsCollided(
+ {.intake_front_position = intake_front_.estimated_position(),
+ .intake_back_position = intake_back_.estimated_position(),
+ .turret_position = turret_.estimated_position(),
+ .shooting = true});
- // If the turret reached the aiming goal, fire!
- if (flippers_open_ && turret_near_goal) {
+ // If the turret reached the aiming goal and the catapult is safe to move
+ // up, fire!
+ if (flippers_open_ && turret_near_goal && !collided) {
fire_ = true;
}
@@ -312,7 +318,8 @@
collision_avoidance_.UpdateGoal(
{.intake_front_position = intake_front_.estimated_position(),
.intake_back_position = intake_back_.estimated_position(),
- .turret_position = turret_.estimated_position()},
+ .turret_position = turret_.estimated_position(),
+ .shooting = state_ == SuperstructureState::SHOOTING},
turret_goal);
turret_.set_min_position(collision_avoidance_.min_turret_goal());