Prefix LOG and CHECK with AOS_
This prepares us for introducing glog more widely and transitioning
things over where they make sense.
Change-Id: Ic6c208882407bc2153fe875ffc736d66f5c8ade5
diff --git a/y2014/actors/autonomous_actor.cc b/y2014/actors/autonomous_actor.cc
index 76a037c..4e2c9aa 100644
--- a/y2014/actors/autonomous_actor.cc
+++ b/y2014/actors/autonomous_actor.cc
@@ -58,7 +58,7 @@
goal_message->centering = centering_power;
if (!goal_message.Send()) {
- LOG(WARNING, "sending claw goal failed\n");
+ AOS_LOG(WARNING, "sending claw goal failed\n");
}
}
@@ -69,7 +69,7 @@
goal_message->intake = 12.0;
goal_message->centering = 12.0;
if (!goal_message.Send()) {
- LOG(WARNING, "sending claw goal failed\n");
+ AOS_LOG(WARNING, "sending claw goal failed\n");
}
}
@@ -82,7 +82,7 @@
goal_message->intake = 4.0;
goal_message->centering = 1.0;
if (!goal_message.Send()) {
- LOG(WARNING, "sending claw goal failed\n");
+ AOS_LOG(WARNING, "sending claw goal failed\n");
}
}
@@ -93,19 +93,19 @@
goal_message->intake = 4.0;
goal_message->centering = 1.0;
if (!goal_message.Send()) {
- LOG(WARNING, "sending claw goal failed\n");
+ AOS_LOG(WARNING, "sending claw goal failed\n");
}
}
void AutonomousActor::SetShotPower(double power) {
- LOG(INFO, "Setting shot power to %f\n", power);
+ AOS_LOG(INFO, "Setting shot power to %f\n", power);
auto goal_message = shooter_goal_sender_.MakeMessage();
goal_message->shot_power = power;
goal_message->shot_requested = false;
goal_message->unload_requested = false;
goal_message->load_requested = false;
if (!goal_message.Send()) {
- LOG(WARNING, "sending shooter goal failed\n");
+ AOS_LOG(WARNING, "sending shooter goal failed\n");
}
}
@@ -161,10 +161,10 @@
hot_goal_fetcher_->Fetch();
if (hot_goal_fetcher_->get()) {
start_counts_ = *hot_goal_fetcher_->get();
- LOG_STRUCT(INFO, "counts reset to", start_counts_);
+ AOS_LOG_STRUCT(INFO, "counts reset to", start_counts_);
start_counts_valid_ = true;
} else {
- LOG(WARNING, "no hot goal message. ignoring\n");
+ AOS_LOG(WARNING, "no hot goal message. ignoring\n");
start_counts_valid_ = false;
}
}
@@ -172,7 +172,7 @@
void Update() {
hot_goal_fetcher_->Fetch();
if (hot_goal_fetcher_->get())
- LOG_STRUCT(INFO, "new counts", *hot_goal_fetcher_->get());
+ AOS_LOG_STRUCT(INFO, "new counts", *hot_goal_fetcher_->get());
}
bool left_triggered() const {
@@ -250,12 +250,12 @@
static const double kTurnAngle = 0.3;
const monotonic_clock::time_point start_time = monotonic_now();
- LOG(INFO, "Handling auto mode\n");
+ AOS_LOG(INFO, "Handling auto mode\n");
AutoVersion auto_version;
auto_mode_fetcher_.Fetch();
if (!auto_mode_fetcher_.get()) {
- LOG(WARNING, "not sure which auto mode to use\n");
+ AOS_LOG(WARNING, "not sure which auto mode to use\n");
auto_version = AutoVersion::kStraight;
} else {
static const double kSelectorMin = 0.2, kSelectorMax = 4.4;
@@ -269,7 +269,8 @@
auto_version = AutoVersion::kDoubleHot;
}
}
- LOG(INFO, "running auto %" PRIu8 "\n", static_cast<uint8_t>(auto_version));
+ AOS_LOG(INFO, "running auto %" PRIu8 "\n",
+ static_cast<uint8_t>(auto_version));
const ProfileParameters &drive_params =
(auto_version == AutoVersion::kStraight) ? kFastDrive : kSlowDrive;
@@ -284,37 +285,37 @@
Reset();
// Turn the claw on, keep it straight up until the ball has been grabbed.
- LOG(INFO, "Claw going up at %f\n",
- ::aos::time::DurationInSeconds(monotonic_now() - start_time));
+ AOS_LOG(INFO, "Claw going up at %f\n",
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
PositionClawVertically(12.0, 4.0);
SetShotPower(115.0);
// Wait for the ball to enter the claw.
this_thread::sleep_for(chrono::milliseconds(250));
if (ShouldCancel()) return true;
- LOG(INFO, "Readying claw for shot at %f\n",
- ::aos::time::DurationInSeconds(monotonic_now() - start_time));
+ AOS_LOG(INFO, "Readying claw for shot at %f\n",
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
if (ShouldCancel()) return true;
// Drive to the goal.
StartDrive(-kShootDistance, 0.0, drive_params, kFastTurn);
this_thread::sleep_for(chrono::milliseconds(750));
PositionClawForShot();
- LOG(INFO, "Waiting until drivetrain is finished\n");
+ AOS_LOG(INFO, "Waiting until drivetrain is finished\n");
WaitForDriveProfileDone();
if (ShouldCancel()) return true;
hot_goal_decoder.Update();
if (hot_goal_decoder.is_left()) {
- LOG(INFO, "first shot left\n");
+ AOS_LOG(INFO, "first shot left\n");
first_shot_left = true;
second_shot_left_default = false;
} else if (hot_goal_decoder.is_right()) {
- LOG(INFO, "first shot right\n");
+ AOS_LOG(INFO, "first shot right\n");
first_shot_left = false;
second_shot_left_default = true;
} else {
- LOG(INFO, "first shot defaulting left\n");
+ AOS_LOG(INFO, "first shot defaulting left\n");
first_shot_left = true;
second_shot_left_default = true;
}
@@ -337,8 +338,8 @@
}
// Shoot.
- LOG(INFO, "Shooting at %f\n",
- ::aos::time::DurationInSeconds(monotonic_now() - start_time));
+ AOS_LOG(INFO, "Shooting at %f\n",
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
Shoot();
this_thread::sleep_for(chrono::milliseconds(50));
@@ -349,8 +350,8 @@
WaitForDriveProfileDone();
if (ShouldCancel()) return true;
} else if (auto_version == AutoVersion::kSingleHot) {
- LOG(INFO, "auto done at %f\n",
- ::aos::time::DurationInSeconds(monotonic_now() - start_time));
+ AOS_LOG(INFO, "auto done at %f\n",
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
PositionClawVertically(0.0, 0.0);
return true;
}
@@ -358,22 +359,22 @@
{
if (ShouldCancel()) return true;
// Intake the new ball.
- LOG(INFO, "Claw ready for intake at %f\n",
- ::aos::time::DurationInSeconds(monotonic_now() - start_time));
+ AOS_LOG(INFO, "Claw ready for intake at %f\n",
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
PositionClawBackIntake();
StartDrive(kShootDistance + kPickupDistance, 0.0, drive_params, kFastTurn);
- LOG(INFO, "Waiting until drivetrain is finished\n");
+ AOS_LOG(INFO, "Waiting until drivetrain is finished\n");
WaitForDriveProfileDone();
if (ShouldCancel()) return true;
- LOG(INFO, "Wait for the claw at %f\n",
- ::aos::time::DurationInSeconds(monotonic_now() - start_time));
+ AOS_LOG(INFO, "Wait for the claw at %f\n",
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
if (!WaitUntilClawDone()) return true;
}
// Drive back.
{
- LOG(INFO, "Driving back at %f\n",
- ::aos::time::DurationInSeconds(monotonic_now() - start_time));
+ AOS_LOG(INFO, "Driving back at %f\n",
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
StartDrive(-(kShootDistance + kPickupDistance), 0.0, drive_params,
kFastTurn);
this_thread::sleep_for(chrono::milliseconds(300));
@@ -382,7 +383,7 @@
PositionClawUpClosed();
if (!WaitUntilClawDone()) return true;
PositionClawForShot();
- LOG(INFO, "Waiting until drivetrain is finished\n");
+ AOS_LOG(INFO, "Waiting until drivetrain is finished\n");
WaitForDriveProfileDone();
if (ShouldCancel()) return true;
if (!WaitUntilClawDone()) return true;
@@ -390,14 +391,14 @@
hot_goal_decoder.Update();
if (hot_goal_decoder.is_left()) {
- LOG(INFO, "second shot left\n");
+ AOS_LOG(INFO, "second shot left\n");
second_shot_left = true;
} else if (hot_goal_decoder.is_right()) {
- LOG(INFO, "second shot right\n");
+ AOS_LOG(INFO, "second shot right\n");
second_shot_left = false;
} else {
- LOG(INFO, "second shot defaulting %s\n",
- second_shot_left_default ? "left" : "right");
+ AOS_LOG(INFO, "second shot defaulting %s\n",
+ second_shot_left_default ? "left" : "right");
second_shot_left = second_shot_left_default;
}
if (auto_version == AutoVersion::kDoubleHot) {
@@ -410,8 +411,8 @@
this_thread::sleep_for(chrono::milliseconds(400));
}
- LOG(INFO, "Shooting at %f\n",
- ::aos::time::DurationInSeconds(monotonic_now() - start_time));
+ AOS_LOG(INFO, "Shooting at %f\n",
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
// Shoot
Shoot();
if (ShouldCancel()) return true;
diff --git a/y2014/actors/shoot_actor.cc b/y2014/actors/shoot_actor.cc
index 736632d..7fb4c05 100644
--- a/y2014/actors/shoot_actor.cc
+++ b/y2014/actors/shoot_actor.cc
@@ -47,7 +47,7 @@
bool ShootActor::IntakeOff() {
claw_goal_fetcher_.Fetch();
if (!claw_goal_fetcher_.get()) {
- LOG(WARNING, "no claw goal\n");
+ AOS_LOG(WARNING, "no claw goal\n");
// If it doesn't have a goal, then the intake isn't on so we don't have to
// turn it off.
return true;
@@ -60,7 +60,7 @@
goal_message->centering = 0.0;
if (!goal_message.Send()) {
- LOG(WARNING, "sending claw goal failed\n");
+ AOS_LOG(WARNING, "sending claw goal failed\n");
return false;
}
}
@@ -82,16 +82,16 @@
goal_message->unload_requested = false;
goal_message->load_requested = false;
if (!goal_message.Send()) {
- LOG(WARNING, "sending shooter goal failed\n");
+ AOS_LOG(WARNING, "sending shooter goal failed\n");
return false;
}
- LOG(INFO, "finished\n");
+ AOS_LOG(INFO, "finished\n");
return true;
}
void ShootActor::InnerRunAction() {
- LOG(INFO, "Shooting at the current angle and power.\n");
+ AOS_LOG(INFO, "Shooting at the current angle and power.\n");
// wait for claw to be ready
if (WaitUntil(::std::bind(&ShootActor::DoneSetupShot, this))) {
@@ -114,7 +114,7 @@
goal_message->unload_requested = false;
goal_message->load_requested = false;
if (!goal_message.Send()) {
- LOG(WARNING, "sending shooter goal failed\n");
+ AOS_LOG(WARNING, "sending shooter goal failed\n");
return;
}
}
@@ -134,25 +134,26 @@
claw_goal_fetcher_->bottom_angle) < 0.10) &&
(::std::abs(claw_status_fetcher_->separation -
claw_goal_fetcher_->separation_angle) < 0.4);
- LOG(DEBUG, "Claw is %sready zeroed %d bottom_velocity %f bottom %f sep %f\n",
- ans ? "" : "not ", claw_status_fetcher_->zeroed,
- ::std::abs(claw_status_fetcher_->bottom_velocity),
- ::std::abs(claw_status_fetcher_->bottom -
- claw_goal_fetcher_->bottom_angle),
- ::std::abs(claw_status_fetcher_->separation -
- claw_goal_fetcher_->separation_angle));
+ AOS_LOG(DEBUG,
+ "Claw is %sready zeroed %d bottom_velocity %f bottom %f sep %f\n",
+ ans ? "" : "not ", claw_status_fetcher_->zeroed,
+ ::std::abs(claw_status_fetcher_->bottom_velocity),
+ ::std::abs(claw_status_fetcher_->bottom -
+ claw_goal_fetcher_->bottom_angle),
+ ::std::abs(claw_status_fetcher_->separation -
+ claw_goal_fetcher_->separation_angle));
return ans;
}
bool ShootActor::ShooterIsReady() {
shooter_goal_fetcher_.Fetch();
- LOG(DEBUG, "Power error is %f - %f -> %f, ready %d\n",
- shooter_status_fetcher_->hard_stop_power,
- shooter_goal_fetcher_->shot_power,
- ::std::abs(shooter_status_fetcher_->hard_stop_power -
- shooter_goal_fetcher_->shot_power),
- shooter_status_fetcher_->ready);
+ AOS_LOG(DEBUG, "Power error is %f - %f -> %f, ready %d\n",
+ shooter_status_fetcher_->hard_stop_power,
+ shooter_goal_fetcher_->shot_power,
+ ::std::abs(shooter_status_fetcher_->hard_stop_power -
+ shooter_goal_fetcher_->shot_power),
+ shooter_status_fetcher_->ready);
return (::std::abs(shooter_status_fetcher_->hard_stop_power -
shooter_goal_fetcher_->shot_power) < 1.0) &&
shooter_status_fetcher_->ready;
@@ -164,7 +165,7 @@
// Make sure that both the shooter and claw have reached the necessary
// states.
if (ShooterIsReady() && ClawIsReady()) {
- LOG(INFO, "Claw and Shooter ready for shooting.\n");
+ AOS_LOG(INFO, "Claw and Shooter ready for shooting.\n");
return true;
}
@@ -174,7 +175,7 @@
bool ShootActor::DonePreShotOpen() {
claw_status_fetcher_.Fetch();
if (claw_status_fetcher_->separation > kClawShootingSeparation) {
- LOG(INFO, "Opened up enough to shoot.\n");
+ AOS_LOG(INFO, "Opened up enough to shoot.\n");
return true;
}
return false;
@@ -184,7 +185,7 @@
shooter_status_fetcher_.Fetch();
if (shooter_status_fetcher_.get() &&
shooter_status_fetcher_->shots > previous_shots_) {
- LOG(INFO, "Shot succeeded!\n");
+ AOS_LOG(INFO, "Shot succeeded!\n");
return true;
}
return false;
diff --git a/y2014/constants.cc b/y2014/constants.cc
index 6981e48..19be8f9 100644
--- a/y2014/constants.cc
+++ b/y2014/constants.cc
@@ -178,13 +178,13 @@
};
break;
default:
- LOG(FATAL, "unknown team #%" PRIu16 "\n", team);
+ AOS_LOG(FATAL, "unknown team #%" PRIu16 "\n", team);
}
}
const Values *DoGetValues() {
uint16_t team = ::aos::network::GetTeamNumber();
- LOG(INFO, "creating a Constants for team %" PRIu16 "\n", team);
+ AOS_LOG(INFO, "creating a Constants for team %" PRIu16 "\n", team);
return DoGetValuesForTeam(team);
}
diff --git a/y2014/control_loops/claw/claw.cc b/y2014/control_loops/claw/claw.cc
index 7a28a23..14dbf11 100644
--- a/y2014/control_loops/claw/claw.cc
+++ b/y2014/control_loops/claw/claw.cc
@@ -94,7 +94,7 @@
double max_voltage = is_zeroing_ ? kZeroingVoltage : kMaxVoltage;
if (::std::abs(u_bottom) > max_voltage || ::std::abs(u_top) > max_voltage) {
- LOG_MATRIX(DEBUG, "U at start", U());
+ AOS_LOG_MATRIX(DEBUG, "U at start", U());
// H * U <= k
// U = UPos + UVel
// H * (UPos + UVel) <= k
@@ -116,7 +116,7 @@
position_error << error(0, 0), error(1, 0);
Eigen::Matrix<double, 2, 1> velocity_error;
velocity_error << error(2, 0), error(3, 0);
- LOG_MATRIX(DEBUG, "error", error);
+ AOS_LOG_MATRIX(DEBUG, "error", error);
const auto &poly = is_zeroing_ ? U_Poly_zeroing_ : U_Poly_;
const Eigen::Matrix<double, 4, 2> pos_poly_H = poly.H() * position_K;
@@ -183,28 +183,28 @@
}
}
- LOG_MATRIX(DEBUG, "adjusted_pos_error", adjusted_pos_error);
+ AOS_LOG_MATRIX(DEBUG, "adjusted_pos_error", adjusted_pos_error);
mutable_U() = velocity_K * velocity_error + position_K * adjusted_pos_error;
- LOG_MATRIX(DEBUG, "U is now", U());
+ AOS_LOG_MATRIX(DEBUG, "U is now", U());
{
const auto values = constants::GetValues().claw;
if (top_known_) {
if (X_hat(0, 0) + X_hat(1, 0) > values.upper_claw.upper_limit && U(1, 0) > 0) {
- LOG(WARNING, "upper claw too high and moving up\n");
+ AOS_LOG(WARNING, "upper claw too high and moving up\n");
mutable_U(1, 0) = 0;
} else if (X_hat(0, 0) + X_hat(1, 0) < values.upper_claw.lower_limit &&
U(1, 0) < 0) {
- LOG(WARNING, "upper claw too low and moving down\n");
+ AOS_LOG(WARNING, "upper claw too low and moving down\n");
mutable_U(1, 0) = 0;
}
}
if (bottom_known_) {
if (X_hat(0, 0) > values.lower_claw.upper_limit && U(0, 0) > 0) {
- LOG(WARNING, "lower claw too high and moving up\n");
+ AOS_LOG(WARNING, "lower claw too high and moving up\n");
mutable_U(0, 0) = 0;
} else if (X_hat(0, 0) < values.lower_claw.lower_limit && U(0, 0) < 0) {
- LOG(WARNING, "lower claw too low and moving down\n");
+ AOS_LOG(WARNING, "lower claw too low and moving down\n");
mutable_U(0, 0) = 0;
}
}
@@ -318,7 +318,7 @@
double edge_encoder;
double edge_angle;
if (GetPositionOfEdge(claw_values, &edge_encoder, &edge_angle)) {
- LOG(INFO, "Calibration edge edge should be %f.\n", edge_angle);
+ AOS_LOG(INFO, "Calibration edge edge should be %f.\n", edge_angle);
SetCalibration(edge_encoder, edge_angle);
set_zeroing_state(zeroing_state);
return true;
@@ -333,9 +333,9 @@
if (GetPositionOfEdge(claw_values, &edge_encoder, &edge_angle)) {
const double calibration_error =
ComputeCalibrationChange(edge_encoder, edge_angle);
- LOG(INFO, "Top calibration error is %f\n", calibration_error);
+ AOS_LOG(INFO, "Top calibration error is %f\n", calibration_error);
if (::std::abs(calibration_error) > kRezeroThreshold) {
- LOG(WARNING, "rezeroing top\n");
+ AOS_LOG(WARNING, "rezeroing top\n");
SetCalibration(edge_encoder, edge_angle);
set_zeroing_state(ZeroedStateFeedbackLoop::UNKNOWN_POSITION);
}
@@ -350,9 +350,9 @@
if (GetPositionOfEdge(claw_values, &edge_encoder, &edge_angle)) {
const double calibration_error =
ComputeCalibrationChange(edge_encoder, edge_angle);
- LOG(INFO, "Bottom calibration error is %f\n", calibration_error);
+ AOS_LOG(INFO, "Bottom calibration error is %f\n", calibration_error);
if (::std::abs(calibration_error) > kRezeroThreshold) {
- LOG(WARNING, "rezeroing bottom\n");
+ AOS_LOG(WARNING, "rezeroing bottom\n");
SetCalibration(edge_encoder, edge_angle);
set_zeroing_state(ZeroedStateFeedbackLoop::UNKNOWN_POSITION);
}
@@ -365,7 +365,7 @@
double edge_encoder;
double edge_angle;
if (GetPositionOfEdge(claw_values, &edge_encoder, &edge_angle)) {
- LOG(INFO, "Calibration edge.\n");
+ AOS_LOG(INFO, "Calibration edge.\n");
SetCalibration(edge_encoder, edge_angle);
set_zeroing_state(zeroing_state);
return true;
@@ -437,20 +437,22 @@
if (SawFilteredPosedge(this_sensor, sensorA, sensorB)) {
if (min_hall_effect_off_angle_ == max_hall_effect_off_angle_) {
- LOG(WARNING, "%s: Uncertain which side, rejecting posedge\n", name_);
+ AOS_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;
if (this_sensor.posedge_value() < average_last_encoder) {
*edge_angle = angles.upper_decreasing_angle;
- LOG(INFO, "%s Posedge upper of %s -> %f posedge: %f avg_encoder: %f\n",
- name_, hall_effect_name, *edge_angle, this_sensor.posedge_value(),
- average_last_encoder);
+ AOS_LOG(INFO,
+ "%s Posedge upper of %s -> %f posedge: %f avg_encoder: %f\n",
+ name_, hall_effect_name, *edge_angle,
+ this_sensor.posedge_value(), average_last_encoder);
} else {
*edge_angle = angles.lower_angle;
- LOG(INFO, "%s Posedge lower of %s -> %f posedge: %f avg_encoder: %f\n",
- name_, hall_effect_name, *edge_angle, this_sensor.posedge_value(),
- average_last_encoder);
+ AOS_LOG(INFO,
+ "%s Posedge lower of %s -> %f posedge: %f avg_encoder: %f\n",
+ name_, hall_effect_name, *edge_angle,
+ this_sensor.posedge_value(), average_last_encoder);
}
*edge_encoder = this_sensor.posedge_value();
found_edge = true;
@@ -459,20 +461,22 @@
if (SawFilteredNegedge(this_sensor, sensorA, sensorB)) {
if (min_hall_effect_on_angle_ == max_hall_effect_on_angle_) {
- LOG(WARNING, "%s: Uncertain which side, rejecting negedge\n", name_);
+ AOS_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;
if (this_sensor.negedge_value() > average_last_encoder) {
*edge_angle = angles.upper_angle;
- LOG(INFO, "%s Negedge upper of %s -> %f negedge: %f avg_encoder: %f\n",
- name_, hall_effect_name, *edge_angle, this_sensor.negedge_value(),
- average_last_encoder);
+ AOS_LOG(INFO,
+ "%s Negedge upper of %s -> %f negedge: %f avg_encoder: %f\n",
+ name_, hall_effect_name, *edge_angle,
+ this_sensor.negedge_value(), average_last_encoder);
} else {
*edge_angle = angles.lower_decreasing_angle;
- LOG(INFO, "%s Negedge lower of %s -> %f negedge: %f avg_encoder: %f\n",
- name_, hall_effect_name, *edge_angle, this_sensor.negedge_value(),
- average_last_encoder);
+ AOS_LOG(INFO,
+ "%s Negedge lower of %s -> %f negedge: %f avg_encoder: %f\n",
+ name_, hall_effect_name, *edge_angle,
+ this_sensor.negedge_value(), average_last_encoder);
}
*edge_encoder = this_sensor.negedge_value();
found_edge = true;
@@ -546,12 +550,12 @@
void ClawLimitedLoop::ChangeTopOffset(double doffset) {
mutable_X_hat()(1, 0) += doffset;
- LOG(INFO, "Changing top offset by %f\n", doffset);
+ AOS_LOG(INFO, "Changing top offset by %f\n", doffset);
}
void ClawLimitedLoop::ChangeBottomOffset(double doffset) {
mutable_X_hat()(0, 0) += doffset;
mutable_X_hat()(1, 0) -= doffset;
- LOG(INFO, "Changing bottom offset by %f\n", doffset);
+ AOS_LOG(INFO, "Changing bottom offset by %f\n", doffset);
}
void LimitClawGoal(double *bottom_goal, double *top_goal,
@@ -559,45 +563,45 @@
// first update position based on angle limit
const double separation = *top_goal - *bottom_goal;
if (separation > values.claw.soft_max_separation) {
- LOG_STRUCT(DEBUG, "before", ClawPositionToLog(*top_goal, *bottom_goal));
+ AOS_LOG_STRUCT(DEBUG, "before", ClawPositionToLog(*top_goal, *bottom_goal));
const double dsep = (separation - values.claw.soft_max_separation) / 2.0;
*bottom_goal += dsep;
*top_goal -= dsep;
- LOG_STRUCT(DEBUG, "after", ClawPositionToLog(*top_goal, *bottom_goal));
+ AOS_LOG_STRUCT(DEBUG, "after", ClawPositionToLog(*top_goal, *bottom_goal));
}
if (separation < values.claw.soft_min_separation) {
- LOG_STRUCT(DEBUG, "before", ClawPositionToLog(*top_goal, *bottom_goal));
+ AOS_LOG_STRUCT(DEBUG, "before", ClawPositionToLog(*top_goal, *bottom_goal));
const double dsep = (separation - values.claw.soft_min_separation) / 2.0;
*bottom_goal += dsep;
*top_goal -= dsep;
- LOG_STRUCT(DEBUG, "after", ClawPositionToLog(*top_goal, *bottom_goal));
+ AOS_LOG_STRUCT(DEBUG, "after", ClawPositionToLog(*top_goal, *bottom_goal));
}
// now move both goals in unison
if (*bottom_goal < values.claw.lower_claw.lower_limit) {
- LOG_STRUCT(DEBUG, "before", ClawPositionToLog(*top_goal, *bottom_goal));
+ AOS_LOG_STRUCT(DEBUG, "before", ClawPositionToLog(*top_goal, *bottom_goal));
*top_goal += values.claw.lower_claw.lower_limit - *bottom_goal;
*bottom_goal = values.claw.lower_claw.lower_limit;
- LOG_STRUCT(DEBUG, "after", ClawPositionToLog(*top_goal, *bottom_goal));
+ AOS_LOG_STRUCT(DEBUG, "after", ClawPositionToLog(*top_goal, *bottom_goal));
}
if (*bottom_goal > values.claw.lower_claw.upper_limit) {
- LOG_STRUCT(DEBUG, "before", ClawPositionToLog(*top_goal, *bottom_goal));
+ AOS_LOG_STRUCT(DEBUG, "before", ClawPositionToLog(*top_goal, *bottom_goal));
*top_goal -= *bottom_goal - values.claw.lower_claw.upper_limit;
*bottom_goal = values.claw.lower_claw.upper_limit;
- LOG_STRUCT(DEBUG, "after", ClawPositionToLog(*top_goal, *bottom_goal));
+ AOS_LOG_STRUCT(DEBUG, "after", ClawPositionToLog(*top_goal, *bottom_goal));
}
if (*top_goal < values.claw.upper_claw.lower_limit) {
- LOG_STRUCT(DEBUG, "before", ClawPositionToLog(*top_goal, *bottom_goal));
+ AOS_LOG_STRUCT(DEBUG, "before", ClawPositionToLog(*top_goal, *bottom_goal));
*bottom_goal += values.claw.upper_claw.lower_limit - *top_goal;
*top_goal = values.claw.upper_claw.lower_limit;
- LOG_STRUCT(DEBUG, "after", ClawPositionToLog(*top_goal, *bottom_goal));
+ AOS_LOG_STRUCT(DEBUG, "after", ClawPositionToLog(*top_goal, *bottom_goal));
}
if (*top_goal > values.claw.upper_claw.upper_limit) {
- LOG_STRUCT(DEBUG, "before", ClawPositionToLog(*top_goal, *bottom_goal));
+ AOS_LOG_STRUCT(DEBUG, "before", ClawPositionToLog(*top_goal, *bottom_goal));
*bottom_goal -= *top_goal - values.claw.upper_claw.upper_limit;
*top_goal = values.claw.upper_claw.upper_limit;
- LOG_STRUCT(DEBUG, "after", ClawPositionToLog(*top_goal, *bottom_goal));
+ AOS_LOG_STRUCT(DEBUG, "after", ClawPositionToLog(*top_goal, *bottom_goal));
}
}
@@ -667,9 +671,9 @@
initial_separation_ =
top_claw_.absolute_position() - bottom_claw_.absolute_position();
}
- LOG_STRUCT(DEBUG, "absolute position",
- ClawPositionToLog(top_claw_.absolute_position(),
- bottom_claw_.absolute_position()));
+ AOS_LOG_STRUCT(DEBUG, "absolute position",
+ ClawPositionToLog(top_claw_.absolute_position(),
+ bottom_claw_.absolute_position()));
}
bool autonomous, enabled;
@@ -717,7 +721,7 @@
}
if (bottom_claw_.zeroing_state() != ZeroedStateFeedbackLoop::CALIBRATED) {
// always get the bottom claw to calibrated first
- LOG(DEBUG, "Calibrating the bottom of the claw\n");
+ AOS_LOG(DEBUG, "Calibrating the bottom of the claw\n");
if (!doing_calibration_fine_tune_) {
if (::std::abs(bottom_absolute_position() -
values.claw.start_fine_tune_pos) <
@@ -726,12 +730,12 @@
bottom_claw_goal_ += values.claw.claw_zeroing_speed * kDt;
top_claw_velocity_ = bottom_claw_velocity_ =
values.claw.claw_zeroing_speed;
- LOG(DEBUG, "Ready to fine tune the bottom\n");
+ AOS_LOG(DEBUG, "Ready to fine tune the bottom\n");
mode_ = FINE_TUNE_BOTTOM;
} else {
// send bottom to zeroing start
bottom_claw_goal_ = values.claw.start_fine_tune_pos;
- LOG(DEBUG, "Going to the start position for the bottom\n");
+ AOS_LOG(DEBUG, "Going to the start position for the bottom\n");
mode_ = PREP_FINE_TUNE_BOTTOM;
}
} else {
@@ -746,7 +750,7 @@
doing_calibration_fine_tune_ = false;
bottom_claw_goal_ = values.claw.start_fine_tune_pos;
top_claw_velocity_ = bottom_claw_velocity_ = 0.0;
- LOG(DEBUG, "Found a limit, starting over.\n");
+ AOS_LOG(DEBUG, "Found a limit, starting over.\n");
mode_ = PREP_FINE_TUNE_BOTTOM;
}
@@ -760,14 +764,15 @@
bottom_claw_.set_zeroing_state(ZeroedStateFeedbackLoop::CALIBRATED);
// calibrated so we are done fine tuning bottom
doing_calibration_fine_tune_ = false;
- LOG(DEBUG, "Calibrated the bottom correctly!\n");
+ AOS_LOG(DEBUG, "Calibrated the bottom correctly!\n");
} else if (bottom_claw_.calibration().last_value()) {
- LOG(DEBUG, "Aborting bottom fine tune because sensor triggered\n");
+ AOS_LOG(DEBUG,
+ "Aborting bottom fine tune because sensor triggered\n");
doing_calibration_fine_tune_ = false;
bottom_claw_.set_zeroing_state(
ZeroedStateFeedbackLoop::UNKNOWN_POSITION);
} else {
- LOG(DEBUG, "Fine tuning\n");
+ AOS_LOG(DEBUG, "Fine tuning\n");
}
}
// now set the top claw to track
@@ -783,12 +788,12 @@
top_claw_goal_ += values.claw.claw_zeroing_speed * kDt;
top_claw_velocity_ = bottom_claw_velocity_ =
values.claw.claw_zeroing_speed;
- LOG(DEBUG, "Ready to fine tune the top\n");
+ AOS_LOG(DEBUG, "Ready to fine tune the top\n");
mode_ = FINE_TUNE_TOP;
} else {
// send top to zeroing start
top_claw_goal_ = values.claw.start_fine_tune_pos;
- LOG(DEBUG, "Going to the start position for the top\n");
+ AOS_LOG(DEBUG, "Going to the start position for the top\n");
mode_ = PREP_FINE_TUNE_TOP;
}
} else {
@@ -802,7 +807,7 @@
doing_calibration_fine_tune_ = false;
top_claw_goal_ = values.claw.start_fine_tune_pos;
top_claw_velocity_ = bottom_claw_velocity_ = 0.0;
- LOG(DEBUG, "Found a limit, starting over.\n");
+ AOS_LOG(DEBUG, "Found a limit, starting over.\n");
mode_ = PREP_FINE_TUNE_TOP;
}
@@ -816,9 +821,9 @@
top_claw_.set_zeroing_state(ZeroedStateFeedbackLoop::CALIBRATED);
// calibrated so we are done fine tuning top
doing_calibration_fine_tune_ = false;
- LOG(DEBUG, "Calibrated the top correctly!\n");
+ AOS_LOG(DEBUG, "Calibrated the top correctly!\n");
} else if (top_claw_.calibration().last_value()) {
- LOG(DEBUG, "Aborting top fine tune because sensor triggered\n");
+ AOS_LOG(DEBUG, "Aborting top fine tune because sensor triggered\n");
doing_calibration_fine_tune_ = false;
top_claw_.set_zeroing_state(
ZeroedStateFeedbackLoop::UNKNOWN_POSITION);
@@ -852,7 +857,7 @@
bottom_claw_goal_ += values.claw.claw_zeroing_off_speed * kDt;
top_claw_velocity_ = bottom_claw_velocity_ =
values.claw.claw_zeroing_off_speed;
- LOG(DEBUG, "Bottom is known.\n");
+ AOS_LOG(DEBUG, "Bottom is known.\n");
}
} else {
// We don't know where either claw is. Slowly start moving down to find
@@ -862,7 +867,7 @@
bottom_claw_goal_ -= values.claw.claw_zeroing_off_speed * kDt;
top_claw_velocity_ = bottom_claw_velocity_ =
-values.claw.claw_zeroing_off_speed;
- LOG(DEBUG, "Both are unknown.\n");
+ AOS_LOG(DEBUG, "Both are unknown.\n");
}
}
@@ -902,7 +907,7 @@
if (has_top_claw_goal_ && has_bottom_claw_goal_) {
claw_.mutable_R() << bottom_claw_goal_, top_claw_goal_ - bottom_claw_goal_,
bottom_claw_velocity_, top_claw_velocity_ - bottom_claw_velocity_;
- LOG_MATRIX(DEBUG, "actual goal", claw_.R());
+ AOS_LOG_MATRIX(DEBUG, "actual goal", claw_.R());
// Only cap power when one of the halves of the claw is moving slowly and
// could wind up.
@@ -937,12 +942,13 @@
claw_.R(3, 0);
claw_.mutable_U() = claw_.controller().K() * (R - claw_.X_hat());
capped_goal_ = true;
- 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));
+ AOS_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));
} else if (claw_.uncapped_average_voltage() <
-values.claw.max_zeroing_voltage) {
double dx_bot =
@@ -959,7 +965,7 @@
claw_.R(3, 0);
claw_.mutable_U() = claw_.controller().K() * (R - claw_.X_hat());
capped_goal_ = true;
- LOG(DEBUG, "Moving the goal by %f to prevent windup\n", dx);
+ AOS_LOG(DEBUG, "Moving the goal by %f to prevent windup\n", dx);
}
} break;
}
diff --git a/y2014/control_loops/claw/claw_lib_test.cc b/y2014/control_loops/claw/claw_lib_test.cc
index c88daa8..41dbfca 100644
--- a/y2014/control_loops/claw/claw_lib_test.cc
+++ b/y2014/control_loops/claw/claw_lib_test.cc
@@ -59,8 +59,8 @@
void Reinitialize(double initial_top_position,
double initial_bottom_position) {
- LOG(INFO, "Reinitializing to {top: %f, bottom: %f}\n", initial_top_position,
- initial_bottom_position);
+ AOS_LOG(INFO, "Reinitializing to {top: %f, bottom: %f}\n",
+ initial_top_position, initial_bottom_position);
claw_plant_->mutable_X(0, 0) = initial_bottom_position;
claw_plant_->mutable_X(1, 0) = initial_top_position - initial_bottom_position;
claw_plant_->mutable_X(2, 0) = 0.0;
@@ -120,8 +120,8 @@
double pos[2] = {GetAbsolutePosition(TOP_CLAW),
GetAbsolutePosition(BOTTOM_CLAW)};
- LOG(DEBUG, "Physical claws are at {top: %f, bottom: %f}\n", pos[TOP_CLAW],
- pos[BOTTOM_CLAW]);
+ AOS_LOG(DEBUG, "Physical claws are at {top: %f, bottom: %f}\n",
+ pos[TOP_CLAW], pos[BOTTOM_CLAW]);
const constants::Values& values = constants::GetValues();
@@ -143,12 +143,12 @@
++position->posedge_count;
if (last_angle < pair.lower_angle) {
- LOG(DEBUG, "%s: Positive lower edge on %s hall effect\n", claw_name,
- hall_effect_name);
+ AOS_LOG(DEBUG, "%s: Positive lower edge on %s hall effect\n", claw_name,
+ hall_effect_name);
position->posedge_value = pair.lower_angle - initial_position;
} else {
- LOG(DEBUG, "%s: Positive upper edge on %s hall effect\n", claw_name,
- hall_effect_name);
+ AOS_LOG(DEBUG, "%s: Positive upper edge on %s hall effect\n", claw_name,
+ hall_effect_name);
position->posedge_value = pair.upper_angle - initial_position;
}
}
@@ -156,12 +156,12 @@
++position->negedge_count;
if (angle < pair.lower_angle) {
- LOG(DEBUG, "%s: Negative lower edge on %s hall effect\n", claw_name,
- hall_effect_name);
+ AOS_LOG(DEBUG, "%s: Negative lower edge on %s hall effect\n", claw_name,
+ hall_effect_name);
position->negedge_value = pair.lower_angle - initial_position;
} else {
- LOG(DEBUG, "%s: Negative upper edge on %s hall effect\n", claw_name,
- hall_effect_name);
+ AOS_LOG(DEBUG, "%s: Negative upper edge on %s hall effect\n", claw_name,
+ hall_effect_name);
position->negedge_value = pair.upper_angle - initial_position;
}
}
diff --git a/y2014/control_loops/shooter/shooter.cc b/y2014/control_loops/shooter/shooter.cc
index d1ef2a5..bf14aad 100644
--- a/y2014/control_loops/shooter/shooter.cc
+++ b/y2014/control_loops/shooter/shooter.cc
@@ -35,17 +35,17 @@
// against last cycle's voltage.
if (X_hat(2, 0) > last_voltage_ + 4.0) {
voltage_ -= X_hat(2, 0) - (last_voltage_ + 4.0);
- LOG(DEBUG, "Capping due to runaway\n");
+ AOS_LOG(DEBUG, "Capping due to runaway\n");
} else if (X_hat(2, 0) < last_voltage_ - 4.0) {
voltage_ += X_hat(2, 0) - (last_voltage_ - 4.0);
- LOG(DEBUG, "Capping due to runaway\n");
+ AOS_LOG(DEBUG, "Capping due to runaway\n");
}
voltage_ = std::min(max_voltage_, voltage_);
voltage_ = std::max(-max_voltage_, voltage_);
mutable_U(0, 0) = voltage_ - old_voltage;
- LOG_STRUCT(
+ AOS_LOG_STRUCT(
DEBUG, "shooter_output",
::y2014::control_loops::ShooterVoltageToLog(X_hat(2, 0), voltage_));
@@ -67,8 +67,8 @@
mutable_R(0, 0) -= dx;
}
capped_goal_ = true;
- LOG_STRUCT(DEBUG, "to prevent windup",
- ::y2014::control_loops::ShooterMovingGoal(dx));
+ AOS_LOG_STRUCT(DEBUG, "to prevent windup",
+ ::y2014::control_loops::ShooterMovingGoal(dx));
} else if (uncapped_voltage() < -max_voltage_) {
double dx;
if (index() == 0) {
@@ -82,8 +82,8 @@
mutable_R(0, 0) -= dx;
}
capped_goal_ = true;
- LOG_STRUCT(DEBUG, "to prevent windup",
- ::y2014::control_loops::ShooterMovingGoal(dx));
+ AOS_LOG_STRUCT(DEBUG, "to prevent windup",
+ ::y2014::control_loops::ShooterMovingGoal(dx));
} else {
capped_goal_ = false;
}
@@ -110,10 +110,10 @@
if (index() == 0) {
mutable_R(2, 0) += -plant().A(1, 0) / plant().A(1, 2) * (doffset);
}
- LOG_STRUCT(DEBUG, "sensor edge (fake?)",
- ::y2014::control_loops::ShooterChangeCalibration(
- encoder_val, known_position, old_position, absolute_position(),
- previous_offset, offset_));
+ AOS_LOG_STRUCT(DEBUG, "sensor edge (fake?)",
+ ::y2014::control_loops::ShooterChangeCalibration(
+ encoder_val, known_position, old_position,
+ absolute_position(), previous_offset, offset_));
}
ShooterMotor::ShooterMotor(::aos::EventLoop *event_loop,
@@ -137,20 +137,21 @@
(kMaxExtension - values.shooter.upper_limit) *
(kMaxExtension - values.shooter.upper_limit));
if (power < 0) {
- LOG_STRUCT(WARNING, "negative power",
- ::y2014::control_loops::PowerAdjustment(power, 0));
+ AOS_LOG_STRUCT(WARNING, "negative power",
+ ::y2014::control_loops::PowerAdjustment(power, 0));
power = 0;
} else if (power > maxpower) {
- LOG_STRUCT(WARNING, "power too high",
- ::y2014::control_loops::PowerAdjustment(power, maxpower));
+ AOS_LOG_STRUCT(WARNING, "power too high",
+ ::y2014::control_loops::PowerAdjustment(power, maxpower));
power = maxpower;
}
double mp = kMaxExtension * kMaxExtension - (power + power) / kSpringConstant;
double new_pos = 0.10;
if (mp < 0) {
- LOG(ERROR,
- "Power calculation has negative number before square root (%f).\n", mp);
+ AOS_LOG(ERROR,
+ "Power calculation has negative number before square root (%f).\n",
+ mp);
} else {
new_pos = kMaxExtension - ::std::sqrt(mp);
}
@@ -167,7 +168,7 @@
void ShooterMotor::CheckCalibrations(
const ::y2014::control_loops::ShooterQueue::Position *position) {
- CHECK_NOTNULL(position);
+ AOS_CHECK_NOTNULL(position);
const constants::Values &values = constants::GetValues();
// TODO(austin): Validate that this is the right edge.
@@ -184,7 +185,7 @@
position->pusher_proximal.posedge_value,
values.shooter.pusher_proximal.upper_angle);
- LOG(DEBUG, "Setting calibration using proximal sensor\n");
+ AOS_LOG(DEBUG, "Setting calibration using proximal sensor\n");
zeroed_ = true;
}
} else {
@@ -204,7 +205,7 @@
position->pusher_distal.posedge_value,
values.shooter.pusher_distal.upper_angle);
- LOG(DEBUG, "Setting calibration using distal sensor\n");
+ AOS_LOG(DEBUG, "Setting calibration using distal sensor\n");
zeroed_ = true;
}
} else {
@@ -221,14 +222,14 @@
::y2014::control_loops::ShooterQueue::Status *status) {
const monotonic_clock::time_point monotonic_now = event_loop()->monotonic_now();
if (goal && ::std::isnan(goal->shot_power)) {
- state_ = STATE_ESTOP;
- LOG(ERROR, "Estopping because got a shot power of NAN.\n");
+ state_ = STATE_ESTOP;
+ AOS_LOG(ERROR, "Estopping because got a shot power of NAN.\n");
}
// we must always have these or we have issues.
if (status == NULL) {
if (output) output->voltage = 0;
- LOG(ERROR, "Thought I would just check for null and die.\n");
+ AOS_LOG(ERROR, "Thought I would just check for null and die.\n");
return;
}
status->ready = false;
@@ -303,8 +304,8 @@
state_ = STATE_REQUEST_LOAD;
} else {
shooter_loop_disable = true;
- LOG(DEBUG,
- "Not moving on until the latch has moved to avoid a crash\n");
+ AOS_LOG(DEBUG,
+ "Not moving on until the latch has moved to avoid a crash\n");
}
} else {
// If we can't start yet because we don't know where we are, set the
@@ -419,7 +420,7 @@
(load_timeout_ + chrono::milliseconds(500) <
monotonic_now)) {
state_ = STATE_ESTOP;
- LOG(ERROR, "Estopping because took too long to load.\n");
+ AOS_LOG(ERROR, "Estopping because took too long to load.\n");
}
}
}
@@ -446,8 +447,8 @@
// up the latch.
shooter_.SetGoalPosition(values.shooter.lower_limit, 0.0);
if (position) {
- LOG(DEBUG, "Waiting on latch: plunger %d, latch: %d\n",
- position->plunger, position->latch);
+ AOS_LOG(DEBUG, "Waiting on latch: plunger %d, latch: %d\n",
+ position->plunger, position->latch);
}
latch_piston_ = true;
@@ -461,10 +462,10 @@
shooter_.SetGoalPosition(PowerToPosition(goal->shot_power), 0.0);
}
- LOG(DEBUG, "PDIFF: absolute_position: %.2f, pow: %.2f\n",
- shooter_.absolute_position(),
- goal ? PowerToPosition(goal->shot_power)
- : ::std::numeric_limits<double>::quiet_NaN());
+ AOS_LOG(DEBUG, "PDIFF: absolute_position: %.2f, pow: %.2f\n",
+ shooter_.absolute_position(),
+ goal ? PowerToPosition(goal->shot_power)
+ : ::std::numeric_limits<double>::quiet_NaN());
if (goal &&
::std::abs(shooter_.absolute_position() -
PowerToPosition(goal->shot_power)) < 0.001 &&
@@ -483,7 +484,7 @@
}
break;
case STATE_READY:
- LOG(DEBUG, "In ready\n");
+ AOS_LOG(DEBUG, "In ready\n");
// Wait until the brake is set, and a shot is requested or the shot power
// is changed.
if (monotonic_now > shooter_brake_set_time_) {
@@ -491,9 +492,9 @@
// We have waited long enough for the brake to set, turn the shooter
// control loop off.
shooter_loop_disable = true;
- LOG(DEBUG, "Brake is now set\n");
+ AOS_LOG(DEBUG, "Brake is now set\n");
if (goal && goal->shot_requested && !disabled) {
- LOG(DEBUG, "Shooting now\n");
+ AOS_LOG(DEBUG, "Shooting now\n");
shooter_loop_disable = true;
shot_end_time_ = monotonic_now + kShotEndTimeout;
firing_starting_position_ = shooter_.absolute_position();
@@ -508,7 +509,7 @@
// TODO(austin): Do we want to set the brake here or after shooting?
// Depends on air usage.
status->ready = false;
- LOG(DEBUG, "Preparing shot again.\n");
+ AOS_LOG(DEBUG, "Preparing shot again.\n");
state_ = STATE_PREPARE_SHOT;
}
@@ -596,7 +597,7 @@
// We have been stuck trying to unload for way too long, give up and
// turn everything off.
state_ = STATE_ESTOP;
- LOG(ERROR, "Estopping because took too long to unload.\n");
+ AOS_LOG(ERROR, "Estopping because took too long to unload.\n");
}
brake_piston_ = false;
@@ -642,7 +643,7 @@
break;
case STATE_ESTOP:
- LOG(WARNING, "estopped\n");
+ AOS_LOG(WARNING, "estopped\n");
// Totally lost, go to a safe state.
shooter_loop_disable = true;
latch_piston_ = true;
@@ -651,9 +652,9 @@
}
if (!shooter_loop_disable) {
- LOG_STRUCT(DEBUG, "running the loop",
- ::y2014::control_loops::ShooterStatusToLog(
- shooter_.goal_position(), shooter_.absolute_position()));
+ AOS_LOG_STRUCT(DEBUG, "running the loop",
+ ::y2014::control_loops::ShooterStatusToLog(
+ shooter_.goal_position(), shooter_.absolute_position()));
if (!cap_goal) {
shooter_.set_max_voltage(12.0);
}
@@ -678,12 +679,13 @@
}
if (position) {
- LOG_STRUCT(DEBUG, "internal state",
- ::y2014::control_loops::ShooterStateToLog(
- shooter_.absolute_position(), shooter_.absolute_velocity(),
- state_, position->latch, position->pusher_proximal.current,
- position->pusher_distal.current, position->plunger,
- brake_piston_, latch_piston_));
+ AOS_LOG_STRUCT(
+ DEBUG, "internal state",
+ ::y2014::control_loops::ShooterStateToLog(
+ shooter_.absolute_position(), shooter_.absolute_velocity(), state_,
+ position->latch, position->pusher_proximal.current,
+ position->pusher_distal.current, position->plunger, brake_piston_,
+ latch_piston_));
last_position_ = *position;
diff --git a/y2014/control_loops/shooter/shooter.h b/y2014/control_loops/shooter/shooter.h
index 01096a0..e755b0f 100644
--- a/y2014/control_loops/shooter/shooter.h
+++ b/y2014/control_loops/shooter/shooter.h
@@ -79,8 +79,8 @@
}
void SetGoalPosition(double desired_position, double desired_velocity) {
- LOG(DEBUG, "Goal position: %f Goal velocity: %f\n", desired_position,
- desired_velocity);
+ AOS_LOG(DEBUG, "Goal position: %f Goal velocity: %f\n", desired_position,
+ desired_velocity);
mutable_R() << desired_position - kPositionOffset, desired_velocity,
(-plant().A(1, 0) / plant().A(1, 2) *
diff --git a/y2014/control_loops/shooter/shooter_lib_test.cc b/y2014/control_loops/shooter/shooter_lib_test.cc
index b6883ad..f910b6d 100644
--- a/y2014/control_loops/shooter/shooter_lib_test.cc
+++ b/y2014/control_loops/shooter/shooter_lib_test.cc
@@ -61,7 +61,7 @@
constexpr static double kPositionOffset = kMaxExtension;
void Reinitialize(double initial_position) {
- LOG(INFO, "Reinitializing to {pos: %f}\n", initial_position);
+ AOS_LOG(INFO, "Reinitializing to {pos: %f}\n", initial_position);
StateFeedbackPlant<2, 1, 1> *plant = shooter_plant_.get();
initial_position_ = initial_position;
plant->mutable_X(0, 0) = initial_position_ - kPositionOffset;
@@ -93,9 +93,9 @@
::y2014::control_loops::ShooterQueue::Position *position) {
const constants::Values &values = constants::GetValues();
- position->position = GetPosition();
+ position->position = GetPosition();
- LOG(DEBUG, "Physical shooter at {%f}\n", GetAbsolutePosition());
+ AOS_LOG(DEBUG, "Physical shooter at {%f}\n", GetAbsolutePosition());
// Signal that the hall effect sensor has been triggered if it is within
// the correct range.
@@ -132,12 +132,14 @@
if (sensor->current && !last_sensor.current) {
++sensor->posedge_count;
if (last_position.position + initial_position_ < limits.lower_angle) {
- LOG(DEBUG, "Posedge value on lower edge of sensor, count is now %d\n",
- sensor->posedge_count);
+ AOS_LOG(DEBUG,
+ "Posedge value on lower edge of sensor, count is now %d\n",
+ sensor->posedge_count);
sensor->posedge_value = limits.lower_angle - initial_position_;
} else {
- LOG(DEBUG, "Posedge value on upper edge of sensor, count is now %d\n",
- sensor->posedge_count);
+ AOS_LOG(DEBUG,
+ "Posedge value on upper edge of sensor, count is now %d\n",
+ sensor->posedge_count);
sensor->posedge_value = limits.upper_angle - initial_position_;
}
}
@@ -229,11 +231,11 @@
U << last_voltage_;
shooter_plant_->Update(U);
}
- LOG(DEBUG, "Plant index is %d\n", shooter_plant_->index());
+ AOS_LOG(DEBUG, "Plant index is %d\n", shooter_plant_->index());
// Handle latch hall effect
if (!latch_piston_state_ && latch_delay_count_ > 0) {
- LOG(DEBUG, "latching simulation: %dp\n", latch_delay_count_);
+ AOS_LOG(DEBUG, "latching simulation: %dp\n", latch_delay_count_);
if (latch_delay_count_ == 1) {
latch_piston_state_ = true;
EXPECT_GE(constants::GetValues().shooter.latch_max_safe_position,
@@ -242,7 +244,7 @@
}
latch_delay_count_--;
} else if (latch_piston_state_ && latch_delay_count_ < 0) {
- LOG(DEBUG, "latching simulation: %dn\n", latch_delay_count_);
+ AOS_LOG(DEBUG, "latching simulation: %dn\n", latch_delay_count_);
if (latch_delay_count_ == -1) {
latch_piston_state_ = false;
if (GetAbsolutePosition() > 0.002) {
@@ -616,7 +618,7 @@
shooter_motor_.state() != ShooterMotor::STATE_READY_UNLOAD) {
RunFor(dt());
if (shooter_motor_.state() == ShooterMotor::STATE_UNLOAD_MOVE) {
- LOG(DEBUG, "State is UnloadMove\n");
+ AOS_LOG(DEBUG, "State is UnloadMove\n");
--kicked_delay;
if (kicked_delay == 0) {
shooter_motor_.shooter_.mutable_R(0, 0) -= 100;
@@ -659,7 +661,7 @@
shooter_motor_.state() != ShooterMotor::STATE_READY_UNLOAD) {
RunFor(dt());
if (shooter_motor_.state() == ShooterMotor::STATE_UNLOAD_MOVE) {
- LOG(DEBUG, "State is UnloadMove\n");
+ AOS_LOG(DEBUG, "State is UnloadMove\n");
--kicked_delay;
if (kicked_delay == 0) {
shooter_motor_.shooter_.mutable_R(0, 0) += 0.1;
diff --git a/y2014/hot_goal_reader.cc b/y2014/hot_goal_reader.cc
index a772633..773397d 100644
--- a/y2014/hot_goal_reader.cc
+++ b/y2014/hot_goal_reader.cc
@@ -28,10 +28,10 @@
if (my_socket == -1) {
my_socket = socket(AF_INET, SOCK_STREAM, 0);
if (my_socket == -1) {
- PLOG(WARNING, "socket(AF_INET, SOCK_STREAM, 0) failed");
+ AOS_PLOG(WARNING, "socket(AF_INET, SOCK_STREAM, 0) failed");
continue;
} else {
- LOG(INFO, "opened socket (is %d)\n", my_socket);
+ AOS_LOG(INFO, "opened socket (is %d)\n", my_socket);
sockaddr_in address, *sockaddr_pointer;
memset(&address, 0, sizeof(address));
address.sin_family = AF_INET;
@@ -40,15 +40,15 @@
sockaddr_pointer = &address;
memcpy(&address_pointer, &sockaddr_pointer, sizeof(void *));
if (bind(my_socket, address_pointer, sizeof(address)) == -1) {
- PLOG(WARNING, "bind(%d, %p, %zu) failed",
- my_socket, &address, sizeof(address));
+ AOS_PLOG(WARNING, "bind(%d, %p, %zu) failed", my_socket, &address,
+ sizeof(address));
close(my_socket);
my_socket = -1;
continue;
}
if (listen(my_socket, 1) == -1) {
- PLOG(WARNING, "listen(%d, 1) failed", my_socket);
+ AOS_PLOG(WARNING, "listen(%d, 1) failed", my_socket);
close(my_socket);
my_socket = -1;
continue;
@@ -58,10 +58,10 @@
int connection = accept4(my_socket, nullptr, nullptr, SOCK_NONBLOCK);
if (connection == -1) {
- PLOG(WARNING, "accept(%d, nullptr, nullptr) failed", my_socket);
+ AOS_PLOG(WARNING, "accept(%d, nullptr, nullptr) failed", my_socket);
continue;
}
- LOG(INFO, "accepted (is %d)\n", connection);
+ AOS_LOG(INFO, "accepted (is %d)\n", connection);
while (connection != -1) {
fd_set fds;
@@ -76,8 +76,8 @@
uint8_t data;
ssize_t read_bytes = read(connection, &data, sizeof(data));
if (read_bytes != sizeof(data)) {
- LOG(WARNING, "read %zd bytes instead of %zd\n", read_bytes,
- sizeof(data));
+ AOS_LOG(WARNING, "read %zd bytes instead of %zd\n", read_bytes,
+ sizeof(data));
break;
}
if (data & 0x01) ++right_count;
@@ -85,21 +85,20 @@
auto message = hot_goal_sender.MakeMessage();
message->left_count = left_count;
message->right_count = right_count;
- LOG_STRUCT(DEBUG, "sending", *message);
+ AOS_LOG_STRUCT(DEBUG, "sending", *message);
message.Send();
} break;
case 0:
- LOG(WARNING, "read on %d timed out\n", connection);
+ AOS_LOG(WARNING, "read on %d timed out\n", connection);
close(connection);
connection = -1;
break;
default:
- PLOG(FATAL,
- "select(%d, %p, nullptr, nullptr, %p) failed",
- connection + 1, &fds, &timeout_timeval);
+ AOS_PLOG(FATAL, "select(%d, %p, nullptr, nullptr, %p) failed",
+ connection + 1, &fds, &timeout_timeval);
}
}
}
- LOG(FATAL, "finished???\n");
+ AOS_LOG(FATAL, "finished???\n");
}
diff --git a/y2014/joystick_reader.cc b/y2014/joystick_reader.cc
index 24ac312..29cb354 100644
--- a/y2014/joystick_reader.cc
+++ b/y2014/joystick_reader.cc
@@ -234,93 +234,93 @@
if (data.IsPressed(kIntakeOpenPosition)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kFlippedIntakeOpenGoal);
} else if (data.IsPressed(kIntakePosition)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kFlippedIntakeGoal);
} else if (data.IsPressed(kVerticalTuck)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kVerticalTuckGoal);
} else if (data.IsPressed(kTuck)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kFlippedTuckGoal);
} else if (data.PosEdge(kLongShot)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kFlippedLongShotGoal);
} else if (data.PosEdge(kCloseShot)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kFlippedMediumShotGoal);
} else if (data.PosEdge(kFenderShot)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kFlippedShortShotGoal);
} else if (data.PosEdge(kHumanPlayerShot)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kFlippedHumanShotGoal);
} else if (data.PosEdge(kUserLeft)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kFlipped254PassGoal);
} else if (data.PosEdge(kUserRight)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kFlippedDemoShotGoal);
} else if (data.PosEdge(kTrussShot)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kFlippedTrussShotGoal);
}
} else {
if (data.IsPressed(kIntakeOpenPosition)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kIntakeOpenGoal);
} else if (data.IsPressed(kIntakePosition)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kIntakeGoal);
} else if (data.IsPressed(kVerticalTuck)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kVerticalTuckGoal);
} else if (data.IsPressed(kTuck)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kTuckGoal);
} else if (data.PosEdge(kLongShot)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kLongShotGoal);
} else if (data.PosEdge(kCloseShot)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kCloseShotGoal);
} else if (data.PosEdge(kFenderShot)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kFenderShotGoal);
} else if (data.PosEdge(kHumanPlayerShot)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kHumanShotGoal);
} else if (data.PosEdge(kUserLeft)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(k254PassGoal);
} else if (data.PosEdge(kUserRight)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kDemoShotGoal);
} else if (data.PosEdge(kTrussShot)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
SetGoal(kTrussShotGoal);
}
}
@@ -333,7 +333,7 @@
if (data.IsPressed(kUnload) || data.IsPressed(kReload)) {
CancelAllActions();
- LOG(DEBUG, "Canceling\n");
+ AOS_LOG(DEBUG, "Canceling\n");
intake_power_ = 0.0;
velocity_compensation_ = 0.0;
}
@@ -356,7 +356,7 @@
goal_angle +=
SpeedToAngleOffset(drivetrain_status_fetcher_->robot_speed);
} else {
- LOG_INTERVAL(no_drivetrain_status_);
+ AOS_LOG_INTERVAL(no_drivetrain_status_);
}
if (moving_for_shot_) {
@@ -390,7 +390,7 @@
goal_message->centering = intaking ? 12.0 : 0.0;
if (!goal_message.Send()) {
- LOG(WARNING, "sending claw goal failed\n");
+ AOS_LOG(WARNING, "sending claw goal failed\n");
}
}
@@ -401,7 +401,7 @@
goal_message->unload_requested = data.IsPressed(kUnload);
goal_message->load_requested = data.IsPressed(kReload);
if (!goal_message.Send()) {
- LOG(WARNING, "sending shooter goal failed\n");
+ AOS_LOG(WARNING, "sending shooter goal failed\n");
}
}
}
diff --git a/y2014/wpilib_interface.cc b/y2014/wpilib_interface.cc
index d4d7ad6..7952adc 100644
--- a/y2014/wpilib_interface.cc
+++ b/y2014/wpilib_interface.cc
@@ -478,13 +478,13 @@
void Loop(const int iterations) {
if (iterations != 1) {
- LOG(DEBUG, "Solenoids skipped %d iterations\n", iterations - 1);
+ AOS_LOG(DEBUG, "Solenoids skipped %d iterations\n", iterations - 1);
}
{
shooter_.Fetch();
if (shooter_.get()) {
- LOG_STRUCT(DEBUG, "solenoids", *shooter_);
+ AOS_LOG_STRUCT(DEBUG, "solenoids", *shooter_);
shooter_latch_->Set(!shooter_->latch_piston);
shooter_brake_->Set(!shooter_->brake_piston);
}
@@ -493,7 +493,7 @@
{
drivetrain_.Fetch();
if (drivetrain_.get()) {
- LOG_STRUCT(DEBUG, "solenoids", *drivetrain_);
+ AOS_LOG_STRUCT(DEBUG, "solenoids", *drivetrain_);
drivetrain_left_->Set(!drivetrain_->left_high);
drivetrain_right_->Set(!drivetrain_->right_high);
}
@@ -513,7 +513,7 @@
pcm_->Flush();
to_log.read_solenoids = pcm_->GetAll();
- LOG_STRUCT(DEBUG, "pneumatics info", to_log);
+ AOS_LOG_STRUCT(DEBUG, "pneumatics info", to_log);
}
}
@@ -545,12 +545,12 @@
private:
virtual void Write(const ShooterQueue::Output &output) override {
- LOG_STRUCT(DEBUG, "will output", output);
+ AOS_LOG_STRUCT(DEBUG, "will output", output);
shooter_talon_->SetSpeed(output.voltage / 12.0);
}
virtual void Stop() override {
- LOG(WARNING, "shooter output too old\n");
+ AOS_LOG(WARNING, "shooter output too old\n");
shooter_talon_->SetDisabled();
}
@@ -590,7 +590,7 @@
private:
virtual void Write(const ClawQueue::Output &output) override {
- LOG_STRUCT(DEBUG, "will output", output);
+ AOS_LOG_STRUCT(DEBUG, "will output", output);
intake1_talon_->SetSpeed(output.intake_voltage / 12.0);
intake2_talon_->SetSpeed(output.intake_voltage / 12.0);
bottom_claw_talon_->SetSpeed(-output.bottom_claw_voltage / 12.0);
@@ -600,7 +600,7 @@
}
virtual void Stop() override {
- LOG(WARNING, "claw output too old\n");
+ AOS_LOG(WARNING, "claw output too old\n");
intake1_talon_->SetDisabled();
intake2_talon_->SetDisabled();
bottom_claw_talon_->SetDisabled();