Tune speaker & shuttle shots
Includes ability to have more "stable" auto-aim shuttle shot that does
not rely on x/y of localizer.
Change-Id: I6b76cd8f8436b61bb2f40966dfa8e28a44e85297
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/y2024/constants/common.json b/y2024/constants/common.json
index 87a43cf..58fb1d2 100644
--- a/y2024/constants/common.json
+++ b/y2024/constants/common.json
@@ -9,14 +9,14 @@
{
"distance_from_goal": 4.0,
"shot_params": {
- "shot_altitude_angle": 1.15,
+ "shot_altitude_angle": 0.93,
"shot_speed_over_ground": 100000.0
}
},
{
"distance_from_goal": 6.5,
"shot_params": {
- "shot_altitude_angle": 1.15,
+ "shot_altitude_angle": 0.93,
"shot_speed_over_ground": 100000.0
}
},
@@ -44,7 +44,7 @@
],
"shooter_interpolation_table": [
{
- "distance_from_goal": 0.7,
+ "distance_from_goal": 0.5,
"shot_params": {
"shot_altitude_angle": 0.85,
"shot_speed_over_ground": 16.0
@@ -53,21 +53,21 @@
{
"distance_from_goal": 1.24,
"shot_params": {
- "shot_altitude_angle": 0.85,
+ "shot_altitude_angle": 0.825,
"shot_speed_over_ground": 16.0
}
},
{
"distance_from_goal": 1.904,
"shot_params": {
- "shot_altitude_angle": 0.73,
+ "shot_altitude_angle": 0.66,
"shot_speed_over_ground": 16.0
}
},
{
"distance_from_goal": 2.404,
"shot_params": {
- "shot_altitude_angle": 0.645,
+ "shot_altitude_angle": 0.59,
"shot_speed_over_ground": 16.0
}
},
@@ -75,28 +75,35 @@
{
"distance_from_goal": 2.744,
"shot_params": {
- "shot_altitude_angle": 0.61,
+ "shot_altitude_angle": 0.56,
"shot_speed_over_ground": 16.0
}
},
{
"distance_from_goal": 3.274,
"shot_params": {
- "shot_altitude_angle": 0.55,
+ "shot_altitude_angle": 0.515,
+ "shot_speed_over_ground": 16.0
+ }
+ },
+ {
+ "distance_from_goal": 3.76,
+ "shot_params": {
+ "shot_altitude_angle": 0.50,
"shot_speed_over_ground": 16.0
}
},
{
"distance_from_goal": 4.00,
"shot_params": {
- "shot_altitude_angle": 0.515,
+ "shot_altitude_angle": 0.465,
"shot_speed_over_ground": 16.0
}
},
{
"distance_from_goal": 4.68,
"shot_params": {
- "shot_altitude_angle": 0.51,
+ "shot_altitude_angle": 0.47,
"shot_speed_over_ground": 16.0
}
}
@@ -167,7 +174,7 @@
"catapult_supply_current_limit": 60,
"catapult_stator_current_limit": 250,
"retention_roller_stator_current_limit": 20,
- "slower_retention_roller_stator_current_limit": 2,
+ "slower_retention_roller_stator_current_limit": 12,
"shooting_retention_roller_stator_current_limit": -20,
"retention_roller_supply_current_limit": 10
},
@@ -311,7 +318,7 @@
"turret_loading_position": 0.58,
"catapult_return_position": 0.0,
"min_altitude_shooting_angle": 0.4,
- "max_altitude_shooting_angle": 1.15,
+ "max_altitude_shooting_angle": 0.94,
"retention_roller_voltages": {
"intaking": 1.5,
"retaining": 0.6,
@@ -331,8 +338,8 @@
"extend_set_points": {
"trap": 0.46,
"amp": 0.35,
- "catapult": 0.017,
- "retracted": 0.017
+ "catapult": 0.022,
+ "retracted": 0.022
},
"turret_avoid_extend_collision_position": 0.0,
"altitude_avoid_extend_collision_position": 0.3,
diff --git a/y2024/control_loops/superstructure/aiming.cc b/y2024/control_loops/superstructure/aiming.cc
index a2e92fd..d8d336f 100644
--- a/y2024/control_loops/superstructure/aiming.cc
+++ b/y2024/control_loops/superstructure/aiming.cc
@@ -52,8 +52,6 @@
if (status == nullptr) {
return;
}
- const frc971::control_loops::Pose robot_pose({status->x(), status->y(), 0},
- status->theta());
aos::Alliance alliance = aos::Alliance::kRed;
if (!joystick_state_fetcher_.Fetch() && !received_joystick_state_) {
received_joystick_state_ = false;
@@ -64,6 +62,15 @@
alliance = joystick_state_fetcher_->alliance();
}
+ const bool ignore_localizer_pos =
+ auto_aim_mode == AutoAimMode::TURRET_SHUTTLE;
+ const Eigen::Vector3d ignore_localizer_position{
+ 0.0 * (alliance == aos::Alliance::kRed ? 1.0 : -1.0), -1.0, 0.0};
+ const frc971::control_loops::Pose robot_pose(
+ ignore_localizer_pos ? ignore_localizer_position
+ : Eigen::Vector3d{status->x(), status->y(), 0},
+ status->theta());
+
frc971::shooter_interpolation::InterpolationTable<
y2024::constants::Values::ShotParams> *current_interpolation_table =
interpolation_tables_.at(auto_aim_mode);
diff --git a/y2024/control_loops/superstructure/aiming.h b/y2024/control_loops/superstructure/aiming.h
index 808a175..95e5840 100644
--- a/y2024/control_loops/superstructure/aiming.h
+++ b/y2024/control_loops/superstructure/aiming.h
@@ -67,7 +67,8 @@
y2024::constants::Values::ShotParams> *>
interpolation_tables_ = {
{AutoAimMode::SPEAKER, &interpolation_table_},
- {AutoAimMode::SHUTTLE, &interpolation_table_shuttle_}};
+ {AutoAimMode::SHUTTLE, &interpolation_table_shuttle_},
+ {AutoAimMode::TURRET_SHUTTLE, &interpolation_table_shuttle_}};
std::map<AutoAimMode, frc971::control_loops::Pose> red_alliance_goals_ = {
{AutoAimMode::SPEAKER,
@@ -91,6 +92,18 @@
->shooter_shuttle_targets()
->red_alliance()
->theta()),
+ },
+ {
+ AutoAimMode::TURRET_SHUTTLE,
+ frc971::control_loops::Pose(
+ frc971::ToEigenOrDie<3, 1>(*robot_constants_->common()
+ ->shooter_shuttle_targets()
+ ->red_alliance()
+ ->pos()),
+ robot_constants_->common()
+ ->shooter_shuttle_targets()
+ ->red_alliance()
+ ->theta()),
}};
std::map<AutoAimMode, frc971::control_loops::Pose> blue_alliance_goals_ = {
@@ -115,6 +128,18 @@
->shooter_shuttle_targets()
->blue_alliance()
->theta()),
+ },
+ {
+ AutoAimMode::TURRET_SHUTTLE,
+ frc971::control_loops::Pose(
+ frc971::ToEigenOrDie<3, 1>(*robot_constants_->common()
+ ->shooter_shuttle_targets()
+ ->blue_alliance()
+ ->pos()),
+ robot_constants_->common()
+ ->shooter_shuttle_targets()
+ ->blue_alliance()
+ ->theta()),
}};
aos::Fetcher<aos::JoystickState> joystick_state_fetcher_;
diff --git a/y2024/control_loops/superstructure/collision_avoidance.h b/y2024/control_loops/superstructure/collision_avoidance.h
index be58b35..dcc26d4 100644
--- a/y2024/control_loops/superstructure/collision_avoidance.h
+++ b/y2024/control_loops/superstructure/collision_avoidance.h
@@ -47,7 +47,7 @@
// Tolerances for the subsystems
static constexpr double kEpsTurret = 0.05;
static constexpr double kEpsIntake = 0.05;
- static constexpr double kEpsExtend = 0.01;
+ static constexpr double kEpsExtend = 0.005;
CollisionAvoidance();
diff --git a/y2024/control_loops/superstructure/shooter.cc b/y2024/control_loops/superstructure/shooter.cc
index 7fb8973..6e1fc71 100644
--- a/y2024/control_loops/superstructure/shooter.cc
+++ b/y2024/control_loops/superstructure/shooter.cc
@@ -152,7 +152,7 @@
frc971::shooter_interpolation::InterpolationTable<
y2024::constants::Values::ShotParams> *interpolation_table =
(shooter_goal != nullptr &&
- shooter_goal->auto_aim() == AutoAimMode::SHUTTLE)
+ shooter_goal->auto_aim() != AutoAimMode::SPEAKER)
? &interpolation_table_shuttle_
: &interpolation_table_;
if ((piece_loaded || state_ == CatapultState::FIRING) &&
diff --git a/y2024/control_loops/superstructure/superstructure.cc b/y2024/control_loops/superstructure/superstructure.cc
index e22dc80..a485943 100644
--- a/y2024/control_loops/superstructure/superstructure.cc
+++ b/y2024/control_loops/superstructure/superstructure.cc
@@ -17,7 +17,8 @@
constexpr double kExtendThreshold = 0.01;
constexpr double kTurretLoadingThreshold = 0.05;
-constexpr double kAltitudeLoadingThreshold = 0.02;
+// Extra large so that we can survive loss of zeroes.
+constexpr double kAltitudeLoadingThreshold = 0.04;
constexpr std::chrono::milliseconds kExtraIntakingTime =
std::chrono::milliseconds(500);
diff --git a/y2024/control_loops/superstructure/superstructure_goal.fbs b/y2024/control_loops/superstructure/superstructure_goal.fbs
index 2a5fb00..c93f6f3 100644
--- a/y2024/control_loops/superstructure/superstructure_goal.fbs
+++ b/y2024/control_loops/superstructure/superstructure_goal.fbs
@@ -30,6 +30,7 @@
NONE = 0, // No auto aim.
SPEAKER = 1, // Auto aim for the speaker shot.
SHUTTLE = 2, // Auto aim for the shuttle shot.
+ TURRET_SHUTTLE = 3, // Auto aim for the turret-only shuttle shot.
}
table ShooterGoal {
@@ -79,7 +80,7 @@
fire: bool (id: 4);
// Tells the climber to go absurdly slow on FULL_EXTEND
- // Deprecated now because we take care of this through
+ // Deprecated now because we take care of this through
// climber_goal_voltage
slow_climber: bool = false (id: 6, deprecated);
diff --git a/y2024/joystick_reader.cc b/y2024/joystick_reader.cc
index 2fb75c2..711f9d2 100644
--- a/y2024/joystick_reader.cc
+++ b/y2024/joystick_reader.cc
@@ -63,6 +63,7 @@
const ButtonLocation kRaiseClimber(3, 2);
const ButtonLocation kRaiseFastClimber(3, 1);
const ButtonLocation kAimShuttle(2, 10);
+const ButtonLocation kTurretShuttle(1, 10);
const ButtonLocation kExtraButtonTwo(0, 0);
const ButtonLocation kExtraButtonThree(0, 0);
const ButtonLocation kExtraButtonFour(0, 0);
@@ -145,6 +146,9 @@
} else if (data.IsPressed(kAimShuttle)) {
shooter_goal->set_auto_aim(
control_loops::superstructure::AutoAimMode::SHUTTLE);
+ } else if (data.IsPressed(kTurretShuttle)) {
+ shooter_goal->set_auto_aim(
+ control_loops::superstructure::AutoAimMode::TURRET_SHUTTLE);
}
// Updating aiming for shooter goal, only one type of aim should be possible