Bringup main robot
This gets all mechanisms zeroed and running.
Many profiles are still heavily detuned.
Catapult motors are moved to the CANivore bus.
Change-Id: I38a1845f804bd490d5fff285c636010ac8ea2c27
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/y2024/control_loops/superstructure/collision_avoidance.h b/y2024/control_loops/superstructure/collision_avoidance.h
index 8fd14d7..fe36090 100644
--- a/y2024/control_loops/superstructure/collision_avoidance.h
+++ b/y2024/control_loops/superstructure/collision_avoidance.h
@@ -31,12 +31,9 @@
bool operator!=(const Status &s) const { return !(*this == s); }
};
- // Reference angles between which the turret will be careful
- static constexpr double kCollisionZoneTurret = M_PI * 7.0 / 18.0;
-
// For the turret, 0 rad is pointing straight forwards
- static constexpr double kMinCollisionZoneTurret = 0.07;
- static constexpr double kMaxCollisionZoneTurret = 2.1;
+ static constexpr double kMinCollisionZoneTurret = 0.15;
+ static constexpr double kMaxCollisionZoneTurret = 1.15;
// Maximum position of the intake to avoid collisions
static constexpr double kCollisionZoneIntake = 1.6;
diff --git a/y2024/control_loops/superstructure/shooter.cc b/y2024/control_loops/superstructure/shooter.cc
index 3216b69..532109e 100644
--- a/y2024/control_loops/superstructure/shooter.cc
+++ b/y2024/control_loops/superstructure/shooter.cc
@@ -192,7 +192,7 @@
//
// Correct handles resetting our state when disabled.
const bool disabled = catapult_.Correct(nullptr, position->catapult(),
- shooter_goal == nullptr);
+ catapult_output == nullptr);
catapult_.set_enable_profile(true);
// We want a trajectory which accelerates up over the first portion of the
diff --git a/y2024/control_loops/superstructure/superstructure_can_position.fbs b/y2024/control_loops/superstructure/superstructure_can_position.fbs
index efe0db2..e809adf 100644
--- a/y2024/control_loops/superstructure/superstructure_can_position.fbs
+++ b/y2024/control_loops/superstructure/superstructure_can_position.fbs
@@ -38,6 +38,8 @@
// CAN Position of the extend roller fancon
extend_roller:frc971.control_loops.CANTalonFX (id: 10);
+ catapult_one:frc971.control_loops.CANTalonFX (id: 11);
+ catapult_two:frc971.control_loops.CANTalonFX (id: 12);
}
root_type CANPosition;
diff --git a/y2024/control_loops/superstructure/superstructure_lib_test.cc b/y2024/control_loops/superstructure/superstructure_lib_test.cc
index eb58424..853979c 100644
--- a/y2024/control_loops/superstructure/superstructure_lib_test.cc
+++ b/y2024/control_loops/superstructure/superstructure_lib_test.cc
@@ -514,9 +514,9 @@
i++;
RunFor(dt());
superstructure_status_fetcher_.Fetch();
- // 2 Seconds
+ // 10 Seconds
- ASSERT_LE(i, 2.0 / ::aos::time::DurationInSeconds(dt()));
+ ASSERT_LE(i, 10.0 / ::aos::time::DurationInSeconds(dt()));
// Since there is a delay when sending running, make sure we have a
// status before checking it.
@@ -826,49 +826,6 @@
CheckIfZeroed();
}
-// Tests Climber in multiple scenarios
-TEST_F(SuperstructureTest, ClimberTest) {
- SetEnabled(true);
- WaitUntilZeroed();
-
- superstructure_plant_.climber()->InitializePosition(
- frc971::constants::Range::FromFlatbuffer(
- simulated_robot_constants_->common()->climber()->range())
- .middle());
-
- WaitUntilZeroed();
-
- {
- auto builder = superstructure_goal_sender_.MakeBuilder();
-
- Goal::Builder goal_builder = builder.MakeBuilder<Goal>();
-
- goal_builder.add_climber_goal(ClimberGoal::FULL_EXTEND);
-
- ASSERT_EQ(builder.Send(goal_builder.Finish()), aos::RawSender::Error::kOk);
- }
-
- RunFor(chrono::seconds(5));
-
- VerifyNearGoal();
-
- WaitUntilZeroed();
-
- {
- auto builder = superstructure_goal_sender_.MakeBuilder();
-
- Goal::Builder goal_builder = builder.MakeBuilder<Goal>();
-
- goal_builder.add_climber_goal(ClimberGoal::RETRACT);
-
- ASSERT_EQ(builder.Send(goal_builder.Finish()), aos::RawSender::Error::kOk);
- }
-
- RunFor(chrono::seconds(5));
-
- VerifyNearGoal();
-}
-
// Tests intake and transfer in multiple scenarios
TEST_F(SuperstructureTest, IntakeGoal) {
SetEnabled(true);
@@ -980,7 +937,7 @@
WaitUntilZeroed();
constexpr double kTurretGoal = 2.0;
- constexpr double kAltitudeGoal = 0.5;
+ constexpr double kAltitudeGoal = 0.55;
set_alliance(aos::Alliance::kRed);
SendDrivetrainStatus(0.0, {0.0, 5.0}, 0.0);
@@ -1017,7 +974,8 @@
0.01);
EXPECT_NEAR(superstructure_status_fetcher_->shooter()->altitude()->position(),
- 0.0, 0.01);
+ simulated_robot_constants_->common()->altitude_loading_position(),
+ 0.01);
EXPECT_EQ(superstructure_status_fetcher_->shooter()->catapult_state(),
CatapultState::READY);
@@ -1052,7 +1010,8 @@
0.01);
EXPECT_NEAR(superstructure_status_fetcher_->shooter()->altitude()->position(),
- 0.0, 0.01);
+ simulated_robot_constants_->common()->altitude_loading_position(),
+ 0.01);
EXPECT_EQ(superstructure_status_fetcher_->shooter()->catapult_state(),
CatapultState::READY);
@@ -1217,7 +1176,9 @@
// Wait until the bot finishes auto-aiming.
WaitUntilNear(kTurretGoal, kAltitudeGoal);
- RunFor(chrono::milliseconds(10));
+ RunFor(chrono::seconds(10));
+
+ ASSERT_TRUE(superstructure_status_fetcher_.Fetch());
// Make sure it stays at firing for a bit.
EXPECT_EQ(superstructure_status_fetcher_->shooter()->catapult_state(),
@@ -1502,13 +1463,6 @@
ASSERT_EQ(builder.Send(goal_builder.Finish()), aos::RawSender::Error::kOk);
}
- RunFor(100 * dt());
-
- ASSERT_TRUE(superstructure_status_fetcher_.Fetch());
-
- EXPECT_EQ(superstructure_status_fetcher_->extend_status(),
- ExtendStatus::MOVING);
-
RunFor(chrono::seconds(5));
ASSERT_TRUE(superstructure_status_fetcher_.Fetch());
@@ -1585,7 +1539,7 @@
ASSERT_EQ(builder.Send(goal_builder.Finish()), aos::RawSender::Error::kOk);
}
- RunFor(chrono::seconds(5));
+ RunFor(chrono::seconds(10));
VerifyNearGoal();
@@ -1599,7 +1553,7 @@
ASSERT_EQ(builder.Send(goal_builder.Finish()), aos::RawSender::Error::kOk);
}
- RunFor(chrono::seconds(5));
+ RunFor(chrono::seconds(10));
VerifyNearGoal();
@@ -1613,7 +1567,7 @@
ASSERT_EQ(builder.Send(goal_builder.Finish()), aos::RawSender::Error::kOk);
}
- RunFor(chrono::seconds(5));
+ RunFor(chrono::seconds(10));
VerifyNearGoal();
diff --git a/y2024/control_loops/superstructure/superstructure_output.fbs b/y2024/control_loops/superstructure/superstructure_output.fbs
index 37796ba..24970d0 100644
--- a/y2024/control_loops/superstructure/superstructure_output.fbs
+++ b/y2024/control_loops/superstructure/superstructure_output.fbs
@@ -2,6 +2,7 @@
table Output {
// Voltage of rollers on intake
+ // Positive means intaking a game piece.
intake_roller_voltage:double (id: 0);
// Voltage of intake pivot
diff --git a/y2024/control_loops/superstructure/superstructure_position.fbs b/y2024/control_loops/superstructure/superstructure_position.fbs
index 4f4b75b..b1facba 100644
--- a/y2024/control_loops/superstructure/superstructure_position.fbs
+++ b/y2024/control_loops/superstructure/superstructure_position.fbs
@@ -5,11 +5,14 @@
table Position {
// Values of the encoder and potentiometer at the intake pivot
- // Zero is extended outwards and level, positive is retracted inward.
+ // Zero is when the lowest extent of the lexan is level with the
+ // bellypan, positive is retracted inward.
intake_pivot:frc971.AbsolutePosition (id: 0);
// Values of the encoder and potentiometer at the turret
- // Zero is facing forward, positive is rotated right.
+ // Zero is facing backwards, positive is rotated counter-clockwise.
+ // I.e., zero is at approximately the loading position for getting
+ // the game piece from the extend into the catapult.
turret:frc971.PotAndAbsolutePosition (id: 1);
// Values of the encoder and potentiometer at the altitude
@@ -17,22 +20,25 @@
altitude:frc971.PotAndAbsolutePosition (id: 2);
// Values of the encoder and potentiometer at the catapult
- // Zero is edge of pivot plate parallel to edge of gusset.
- // Positive is rotated counter-clockwise, to launch game piece.
+ // Zero is when the note is fully seated in the catapult and the catapult
+ // arm is just touching the note. Positive is rotated counter-clockwise, to
+ // launch game piece.
catapult:frc971.PotAndAbsolutePosition (id: 3);
// True means there is a game piece in the transfer.
transfer_beambreak:bool (id: 4);
// Values of the encoder and potentiometer at the climber.
- // Zero is fully retracted, positive is extended upward.
+ // Zero is fully extended, with top of the highest slider aligned with the
+ // caps on the tubes for the climber.
+ // Positive is more extended.
climber:frc971.PotAndAbsolutePosition (id: 5);
// True if there is a game piece in the catapult
catapult_beambreak:bool (id: 6);
// Values of the encoder and potentiometer at the extend motor
- // Zero is fully retracted, positive is extended outward.
+ // Zero is fully retracted, positive is extended upward.
extend:frc971.PotAndAbsolutePosition (id: 7);
// True means there is a game piece in the extend.