Retune interpolation table based on 1690's advice
Couple finisher and accelerator speeds too.
https://docs.google.com/spreadsheets/d/1cFcA8ncgptloiDLGW4ICp4YNkfOQLVXJi2EO5HpAJZA/edit?usp=sharing
Change-Id: I572d738de00ae7a58e8d98d7913283ffdf85da57
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
Signed-off-by: milind-u <milind.upadhyay@gmail.com>
diff --git a/y2020/constants.cc b/y2020/constants.cc
index 0b1b50a..f0e293a 100644
--- a/y2020/constants.cc
+++ b/y2020/constants.cc
@@ -32,34 +32,22 @@
// We found that the finisher velocity does not change ball velocity much,
// so keep it constant.
- constexpr double kVelocityFinisher = 350.0;
r->shot_interpolation_table =
- InterpolationTable<Values::ShotParams>({{1.0, {0.01, 10.7}},
- {1.2, {0.01, 10.7}},
- {1.4732, {0.10, 10.6}},
- {2.5, {0.36, 12.0}},
- {3.50, {0.43, 13.2}},
- {3.93, {0.44, 13.2}},
- {4.7371, {0.475, 14.2}},
- {5.31, {0.51, 14.6}},
- {6.332, {0.525, 15.2}},
- {7.35, {0.52, 17.0}},
- {8.30, {0.565, 17.0}},
- {9.20, {0.535, 17.0}}});
-
- r->flywheel_shot_interpolation_table =
- InterpolationTable<Values::FlywheelShotParams>(
- {{10.6, {250.0, kVelocityFinisher}},
- {12.0, {275.0, kVelocityFinisher}},
- {13.2, {300.0, kVelocityFinisher}},
- {14.0, {325.0, kVelocityFinisher}},
- {14.6, {350.0, kVelocityFinisher}},
- {15.2, {375.0, kVelocityFinisher}},
- {15.6, {400.0, kVelocityFinisher}},
- {16.1, {425.0, kVelocityFinisher}},
- {16.3, {450.0, kVelocityFinisher}},
- {16.6, {475.0, kVelocityFinisher}},
- {17.0, {500.0, kVelocityFinisher + 25}}});
+ InterpolationTable<Values::ShotParams>({{1.128, {0.01, 225, 170}},
+ {1.509, {0.01, 215, 160}},
+ {1.89, {0.01, 215, 155}},
+ {2.15, {0.093, 210, 170}},
+ {2.68, {0.195, 240, 190}},
+ {3.19, {0.27, 250, 220}},
+ {3.93, {0.365, 285, 250}},
+ {4.63, {0.42, 320, 280}},
+ {5.32, {0.515, 375, 330}},
+ {6, {0.565, 440, 400}},
+ {6.68, {0.58, 480, 450}},
+ {7.37, {0.645, 520, 540}},
+ {8.36, {0.645, 550, 560}},
+ {9.39, {0.66, 550, 580}},
+ {10.4, {0.67, 550, 600}}});
// Hood constants.
hood->zeroing_voltage = 2.0;
@@ -140,6 +128,8 @@
switch (team) {
// A set of constants for tests.
case 1:
+ r->shot_interpolation_table = InterpolationTable<Values::ShotParams>(
+ {{1, {0.01, 250, 250}}, {10, {0.67, 500, 600}}});
case Values::kSpareRoborioTeamNumber:
break;
diff --git a/y2020/constants.h b/y2020/constants.h
index 01cd177..6dceb65 100644
--- a/y2020/constants.h
+++ b/y2020/constants.h
@@ -211,36 +211,22 @@
// Measured in radians
double hood_angle;
// Muzzle velocity (m/s) of the ball as it is shot out of the shooter.
- double velocity_ball;
+ double velocity_accelerator;
+ double velocity_finisher;
static ShotParams BlendY(double coefficient, ShotParams a1, ShotParams a2) {
using ::frc971::shooter_interpolation::Blend;
- return ShotParams{Blend(coefficient, a1.hood_angle, a2.hood_angle),
- Blend(coefficient, a1.velocity_ball, a2.velocity_ball)};
- }
- };
-
- struct FlywheelShotParams {
- // Angular velocity in radians per second of the slowest (lowest) wheel in
- // the kicker. Positive is shooting the ball.
- double velocity_accelerator;
- // Angular velocity in radians per seconds of the flywheel. Positive is
- // shooting.
- double velocity_finisher;
-
- static FlywheelShotParams BlendY(double coefficient, FlywheelShotParams a1,
- FlywheelShotParams a2) {
- using ::frc971::shooter_interpolation::Blend;
- return FlywheelShotParams{
+ return ShotParams{
+ Blend(coefficient, a1.hood_angle, a2.hood_angle),
Blend(coefficient, a1.velocity_accelerator, a2.velocity_accelerator),
Blend(coefficient, a1.velocity_finisher, a2.velocity_finisher)};
}
};
- // { distance_to_target, { hood_angle, velocity_ball }}
+ // { distance_to_target,
+ // { hood_angle, velocity accelerator, velocity finisher}
+ // }
InterpolationTable<ShotParams> shot_interpolation_table;
- // { velocity_ball, { velocity_accelerator, velocity_finisher }}
- InterpolationTable<FlywheelShotParams> flywheel_shot_interpolation_table;
};
// Creates (once) a Values instance for ::aos::network::GetTeamNumber(). Should
diff --git a/y2020/control_loops/superstructure/superstructure.cc b/y2020/control_loops/superstructure/superstructure.cc
index ae79e76..4fb5c1d 100644
--- a/y2020/control_loops/superstructure/superstructure.cc
+++ b/y2020/control_loops/superstructure/superstructure.cc
@@ -75,18 +75,15 @@
aos::FlatbufferFixedAllocatorArray<ShooterGoal, 64> shooter_goal;
constants::Values::ShotParams shot_params;
- constants::Values::FlywheelShotParams flywheel_shot_params;
if (constants::GetValues().shot_interpolation_table.GetInRange(
- distance_to_goal, &shot_params) &&
- constants::GetValues().flywheel_shot_interpolation_table.GetInRange(
- shot_params.velocity_ball, &flywheel_shot_params)) {
+ distance_to_goal, &shot_params)) {
hood_goal.Finish(frc971::control_loops::
CreateStaticZeroingSingleDOFProfiledSubsystemGoal(
*hood_goal.fbb(), shot_params.hood_angle));
shooter_goal.Finish(CreateShooterGoal(
- *shooter_goal.fbb(), flywheel_shot_params.velocity_accelerator,
- flywheel_shot_params.velocity_finisher));
+ *shooter_goal.fbb(), shot_params.velocity_accelerator,
+ shot_params.velocity_finisher));
} else {
hood_goal.Finish(
frc971::control_loops::
diff --git a/y2020/control_loops/superstructure/superstructure_lib_test.cc b/y2020/control_loops/superstructure/superstructure_lib_test.cc
index 2e6ec08..f148296 100644
--- a/y2020/control_loops/superstructure/superstructure_lib_test.cc
+++ b/y2020/control_loops/superstructure/superstructure_lib_test.cc
@@ -1460,10 +1460,10 @@
->accelerator_right()
->angular_velocity_goal(),
250.0);
- EXPECT_DOUBLE_EQ(superstructure_status_fetcher_->shooter()
- ->finisher()
- ->angular_velocity_goal(),
- 350.0);
+ EXPECT_GE(superstructure_status_fetcher_->shooter()
+ ->finisher()
+ ->angular_velocity_goal(),
+ 250.0);
EXPECT_GE(superstructure_status_fetcher_->hood()->position(),
constants::Values::kHoodRange().lower);
}
diff --git a/y2020/control_loops/superstructure/turret/aiming.cc b/y2020/control_loops/superstructure/turret/aiming.cc
index cdc6181..c8f8f6e 100644
--- a/y2020/control_loops/superstructure/turret/aiming.cc
+++ b/y2020/control_loops/superstructure/turret/aiming.cc
@@ -67,12 +67,12 @@
// speed. Assuming a constant average speed over the course of the trajectory
// should be reasonable, since all we are trying to do here is calculate an
// overall time-of-flight (we don't actually care about the ball speed itself).
-constexpr double kBallSpeedOverGround = 15.0; // m/s
+constexpr double kBallSpeedOverGround = 17.0; // m/s
// Minimum distance that we must be from the inner port in order to attempt the
// shot--this is to account for the fact that if we are too close to the target,
// then we won't have a clear shot on the inner port.
-constexpr double kMinimumInnerPortShotDistance = 3.9;
+constexpr double kMinimumInnerPortShotDistance = 1.9;
// Amount of buffer, in radians, to leave to help avoid wrapping. I.e., any time
// that we are in kAvoidEdges mode, we will keep ourselves at least