cleaned up lots of logging
There were many LOGs that made more sense as LOG_STRUCTs to save space,
reduce CPU usage, and make it a bit more obvious what they're saying.
diff --git a/frc971/control_loops/claw/claw.cc b/frc971/control_loops/claw/claw.cc
index 7334166..b07d75b 100755
--- a/frc971/control_loops/claw/claw.cc
+++ b/frc971/control_loops/claw/claw.cc
@@ -6,6 +6,7 @@
#include "aos/common/control_loop/control_loops.q.h"
#include "aos/common/logging/logging.h"
+#include "aos/common/logging/queue_logging.h"
#include "frc971/constants.h"
#include "frc971/control_loops/claw/claw_motor_plant.h"
@@ -75,9 +76,9 @@
const double k_max_voltage = is_zeroing_ ? kZeroingVoltage : kMaxVoltage;
if (max_value > k_max_voltage) {
- LOG(DEBUG, "Capping U because max is %f\n", max_value);
U = U * k_max_voltage / max_value;
- LOG(DEBUG, "Capping U is now %f %f\n", U(0, 0), U(1, 0));
+ LOG(DEBUG, "Capping U is now %f %f (max is %f)\n",
+ U(0, 0), U(1, 0), max_value);
}
}
@@ -238,7 +239,7 @@
if (SawFilteredPosedge(this_sensor, sensorA, sensorB)) {
if (min_hall_effect_off_angle_ == max_hall_effect_off_angle_) {
- LOG(INFO, "%s: Uncertain which side, rejecting posedge\n", name_);
+ LOG(WARNING, "%s: Uncertain which side, rejecting posedge\n", name_);
} else {
const double average_last_encoder =
(min_hall_effect_off_angle_ + max_hall_effect_off_angle_) / 2.0;
@@ -260,7 +261,7 @@
if (SawFilteredNegedge(this_sensor, sensorA, sensorB)) {
if (min_hall_effect_on_angle_ == max_hall_effect_on_angle_) {
- LOG(INFO, "%s: Uncertain which side, rejecting negedge\n", name_);
+ LOG(WARNING, "%s: Uncertain which side, rejecting negedge\n", name_);
} else {
const double average_last_encoder =
(min_hall_effect_on_angle_ + max_hall_effect_on_angle_) / 2.0;
@@ -450,8 +451,9 @@
initial_separation_ =
top_claw_.absolute_position() - bottom_claw_.absolute_position();
}
- LOG(DEBUG, "Claw position is (top: %f bottom: %f\n",
- top_claw_.absolute_position(), bottom_claw_.absolute_position());
+ LOG_STRUCT(DEBUG, "absolute position",
+ ClawPositionToLog(top_claw_.absolute_position(),
+ bottom_claw_.absolute_position()));
}
const bool autonomous = ::aos::robot_state->autonomous;
@@ -675,8 +677,8 @@
if (position != nullptr) {
separation = position->top.position - position->bottom.position;
}
- LOG(DEBUG, "Goal is %f (bottom) %f, separation is %f\n", claw_.R(0, 0),
- claw_.R(1, 0), separation);
+ LOG_STRUCT(DEBUG, "actual goal",
+ ClawGoalToLog(claw_.R(0, 0), claw_.R(1, 0), separation));
// Only cap power when one of the halves of the claw is moving slowly and
// could wind up.
@@ -702,8 +704,9 @@
bottom_claw_goal_ -= dx;
top_claw_goal_ -= dx;
capped_goal_ = true;
- LOG(DEBUG, "Moving the goal by %f to prevent windup\n", dx);
- LOG(DEBUG, "Uncapped is %f, max is %f, difference is %f\n",
+ LOG(DEBUG, "Moving the goal by %f to prevent windup."
+ " Uncapped is %f, max is %f, difference is %f\n",
+ dx,
claw_.uncapped_average_voltage(), values.claw.max_zeroing_voltage,
(claw_.uncapped_average_voltage() -
values.claw.max_zeroing_voltage));
diff --git a/frc971/control_loops/claw/claw.gyp b/frc971/control_loops/claw/claw.gyp
index 8bb94c0..588ce79 100644
--- a/frc971/control_loops/claw/claw.gyp
+++ b/frc971/control_loops/claw/claw.gyp
@@ -29,6 +29,7 @@
'<(AOS)/common/common.gyp:controls',
'<(DEPTH)/frc971/frc971.gyp:constants',
'<(DEPTH)/frc971/control_loops/control_loops.gyp:state_feedback_loop',
+ '<(AOS)/common/logging/logging.gyp:queue_logging',
],
'export_dependent_settings': [
'claw_loop',
diff --git a/frc971/control_loops/claw/claw.q b/frc971/control_loops/claw/claw.q
index 38e7efb..3225d2f 100644
--- a/frc971/control_loops/claw/claw.q
+++ b/frc971/control_loops/claw/claw.q
@@ -73,3 +73,14 @@
};
queue_group ClawGroup claw_queue_group;
+
+struct ClawPositionToLog {
+ double top;
+ double bottom;
+};
+
+struct ClawGoalToLog {
+ double bottom_pos;
+ double bottom_vel;
+ double separation;
+};