Remove usage of CHECK_NOTNULL
We want to switch to absl logging instead of glog. gtest and ceres are
going there, and we already have absl as a dependency. ABSL doesn't
have CHECK_NOTNULL, and we can move things over in an easier to review
fashion.
Change-Id: Ifd9a11ec34a2357cec43f88dba015db9c28ed2cf
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/y2023/control_loops/drivetrain/target_selector.cc b/y2023/control_loops/drivetrain/target_selector.cc
index bc1fb90..22a5140 100644
--- a/y2023/control_loops/drivetrain/target_selector.cc
+++ b/y2023/control_loops/drivetrain/target_selector.cc
@@ -78,7 +78,7 @@
[possible_grids, hint]() {
aos::SizedArray<const localizer::ScoringRow *, 3> rows;
for (const localizer::ScoringGrid *grid : possible_grids) {
- CHECK_NOTNULL(grid);
+ CHECK(grid != nullptr);
switch (hint->row()) {
case RowSelectionHint::BOTTOM:
rows.push_back(grid->bottom());
@@ -95,7 +95,7 @@
}();
aos::SizedArray<const frc971::vision::Position *, 3> positions;
for (const localizer::ScoringRow *row : possible_rows) {
- CHECK_NOTNULL(row);
+ CHECK(row != nullptr);
switch (hint->spot()) {
case SpotSelectionHint::LEFT:
positions.push_back(row->left_cone());
diff --git a/y2023/control_loops/superstructure/superstructure.cc b/y2023/control_loops/superstructure/superstructure.cc
index 0ee1061..bfb7a9d 100644
--- a/y2023/control_loops/superstructure/superstructure.cc
+++ b/y2023/control_loops/superstructure/superstructure.cc
@@ -134,10 +134,14 @@
if (reading > kInvalidReading || !std::isfinite(reading)) {
return std::nullopt;
}
- const TimeOfFlight *calibration = CHECK_NOTNULL(
- CHECK_NOTNULL(constants_fetcher_.constants().robot())->tof());
+ auto robot = constants_fetcher_.constants().robot();
+ CHECK(robot != nullptr);
+ const TimeOfFlight *calibration =
+ constants_fetcher_.constants().robot()->tof();
+ CHECK(calibration != nullptr);
// TODO(james): Use a generic interpolation table class.
- auto table = CHECK_NOTNULL(calibration->interpolation_table());
+ auto table = calibration->interpolation_table();
+ CHECK(table != nullptr);
CHECK_EQ(2u, table->size());
double x1 = table->Get(0)->tof_reading();
double x2 = table->Get(1)->tof_reading();
diff --git a/y2023/joystick_reader.cc b/y2023/joystick_reader.cc
index 45418bc..6e62c5b 100644
--- a/y2023/joystick_reader.cc
+++ b/y2023/joystick_reader.cc
@@ -533,7 +533,8 @@
auto builder = target_selector_hint_sender_.MakeBuilder();
auto hint_builder = builder.MakeBuilder<TargetSelectorHint>();
hint_builder.add_substation_pickup(true);
- hint_builder.add_robot_side(CHECK_NOTNULL(current_setpoint_)->side);
+ CHECK(current_setpoint_ != nullptr);
+ hint_builder.add_robot_side(current_setpoint_->side);
if (builder.Send(hint_builder.Finish()) != aos::RawSender::Error::kOk) {
AOS_LOG(ERROR, "Sending target selector hint failed.\n");
}
@@ -542,7 +543,8 @@
auto hint_builder = builder.MakeBuilder<TargetSelectorHint>();
hint_builder.add_row(placing_row.value());
hint_builder.add_spot(placing_spot.value());
- hint_builder.add_robot_side(CHECK_NOTNULL(current_setpoint_)->side);
+ CHECK(current_setpoint_ != nullptr);
+ hint_builder.add_robot_side(current_setpoint_->side);
if (builder.Send(hint_builder.Finish()) != aos::RawSender::Error::kOk) {
AOS_LOG(ERROR, "Sending target selector hint failed.\n");
}
diff --git a/y2023/localizer/localizer.cc b/y2023/localizer/localizer.cc
index 6f9a16b..a00ebe6 100644
--- a/y2023/localizer/localizer.cc
+++ b/y2023/localizer/localizer.cc
@@ -264,12 +264,12 @@
switch (utils_.Alliance()) {
case aos::Alliance::kRed:
- ignore_tags =
- CHECK_NOTNULL(constants_fetcher_.constants().ignore_targets()->red());
+ ignore_tags = constants_fetcher_.constants().ignore_targets()->red();
+ CHECK(ignore_tags != nullptr);
break;
case aos::Alliance::kBlue:
- ignore_tags = CHECK_NOTNULL(
- constants_fetcher_.constants().ignore_targets()->blue());
+ ignore_tags = constants_fetcher_.constants().ignore_targets()->blue();
+ CHECK(ignore_tags != nullptr);
break;
case aos::Alliance::kInvalid:
return true;
diff --git a/y2023/wpilib_interface.cc b/y2023/wpilib_interface.cc
index 492d44b..d0d952c 100644
--- a/y2023/wpilib_interface.cc
+++ b/y2023/wpilib_interface.cc
@@ -133,7 +133,7 @@
// device temp is not timesynced so don't add it to the list of signals
device_temp_.SetUpdateFrequency(kCANUpdateFreqHz);
- CHECK_NOTNULL(signals);
+ CHECK(signals != nullptr);
supply_voltage_.SetUpdateFrequency(kCANUpdateFreqHz);
signals->push_back(&supply_voltage_);