moved the outputs being killed detection to the right place
diff --git a/aos/common/common.gyp b/aos/common/common.gyp
index becf20f..d6bb27a 100644
--- a/aos/common/common.gyp
+++ b/aos/common/common.gyp
@@ -181,6 +181,7 @@
'<(AOS)/common/logging/logging.gyp:queue_logging',
'<(AOS)/common/util/util.gyp:log_interval',
'<(DEPTH)/bbb_cape/src/bbb/bbb.gyp:sensor_generation',
+ '<(DEPTH)/frc971/queues/queues.gyp:output_check',
],
'export_dependent_settings': [
'<(AOS)/common/messages/messages.gyp:robot_state',
@@ -191,6 +192,7 @@
'<(AOS)/common/logging/logging.gyp:queue_logging',
'<(AOS)/common/util/util.gyp:log_interval',
'<(DEPTH)/bbb_cape/src/bbb/bbb.gyp:sensor_generation',
+ '<(DEPTH)/frc971/queues/queues.gyp:output_check',
],
},
{
diff --git a/aos/common/controls/control_loop-tmpl.h b/aos/common/controls/control_loop-tmpl.h
index baf352b..404425a 100644
--- a/aos/common/controls/control_loop-tmpl.h
+++ b/aos/common/controls/control_loop-tmpl.h
@@ -6,6 +6,7 @@
#include "aos/common/util/phased_loop.h"
#include "bbb/sensor_generation.q.h"
+#include "frc971/queues/output_check.q.h"
namespace aos {
namespace control_loops {
@@ -120,6 +121,21 @@
}
}
+ ::frc971::output_check_received.FetchLatest();
+ // True if we're enabled but the motors aren't working.
+ // The 100ms is the result of disabling the robot while it's putting out a lot
+ // of power and looking at the time delay between the last PWM pulse and the
+ // battery voltage coming back up.
+ const bool motors_off = !::frc971::output_check_received.get() ||
+ !::frc971::output_check_received.IsNewerThanMS(100);
+ motors_off_log_.Print();
+ if (motors_off) {
+ if (!::aos::robot_state.get() || ::aos::robot_state->enabled) {
+ LOG_INTERVAL(motors_off_log_);
+ }
+ outputs_enabled = false;
+ }
+
// Run the iteration.
aos::ScopedMessagePtr<StatusType> status =
control_loop_->status.MakeMessage();
diff --git a/aos/common/controls/control_loop.h b/aos/common/controls/control_loop.h
index becb080..a79f1e6 100644
--- a/aos/common/controls/control_loop.h
+++ b/aos/common/controls/control_loop.h
@@ -175,6 +175,8 @@
SimpleLogInterval no_sensor_generation_ =
SimpleLogInterval(kStaleLogInterval, ERROR,
"no sensor_generation message");
+ SimpleLogInterval motors_off_log_ =
+ SimpleLogInterval(kStaleLogInterval, WARNING, "motors disabled");
};
} // namespace control_loops
diff --git a/frc971/control_loops/shooter/shooter.cc b/frc971/control_loops/shooter/shooter.cc
index 6c1935b..aabfca5 100755
--- a/frc971/control_loops/shooter/shooter.cc
+++ b/frc971/control_loops/shooter/shooter.cc
@@ -10,7 +10,6 @@
#include "frc971/constants.h"
#include "frc971/control_loops/shooter/shooter_motor_plant.h"
-#include "frc971/queues/output_check.q.h"
namespace frc971 {
namespace control_loops {
@@ -195,17 +194,6 @@
const bool disabled =
!::aos::robot_state.get() || !::aos::robot_state->enabled;
- output_check_received.FetchLatest();
- // True if we're enabled but the motors aren't working.
- // TODO(brians): Make this more general.
- // The 100ms is the result of disabling the robot while it's putting out a lot
- // of power and looking at the time delay between the last PWM pulse and the
- // battery voltage coming back up.
- const bool motors_off =
- !disabled && (!output_check_received.get() ||
- !output_check_received.IsNewerThanMS(100));
- motors_off_log_.Print();
- if (motors_off) LOG_INTERVAL(motors_off_log_);
// If true, move the goal if we saturate.
bool cap_goal = false;
@@ -331,7 +319,7 @@
// useful sensor data.
latch_piston_ = true;
}
- if (motors_off) {
+ if (output == nullptr) {
load_timeout_ += ::aos::control_loops::kLoopFrequency;
}
// Go to 0, which should be the latch position, or trigger a hall effect
@@ -643,7 +631,7 @@
}
// We don't really want to output anything if we went through everything
// assuming the motors weren't working.
- if (output && !motors_off) output->voltage = shooter_.voltage();
+ if (output) output->voltage = shooter_.voltage();
} else {
shooter_.Update(true);
shooter_.ZeroPower();
diff --git a/frc971/control_loops/shooter/shooter.gyp b/frc971/control_loops/shooter/shooter.gyp
index 23380df..10e0f4e 100755
--- a/frc971/control_loops/shooter/shooter.gyp
+++ b/frc971/control_loops/shooter/shooter.gyp
@@ -31,8 +31,6 @@
'<(DEPTH)/frc971/frc971.gyp:constants',
'<(DEPTH)/frc971/control_loops/control_loops.gyp:state_feedback_loop',
'<(AOS)/common/logging/logging.gyp:queue_logging',
- '<(AOS)/common/util/util.gyp:log_interval',
- '<(DEPTH)/frc971/queues/queues.gyp:output_check',
],
'export_dependent_settings': [
'shooter_loop',
diff --git a/frc971/control_loops/shooter/shooter.h b/frc971/control_loops/shooter/shooter.h
index e2d4b93..a909d40 100755
--- a/frc971/control_loops/shooter/shooter.h
+++ b/frc971/control_loops/shooter/shooter.h
@@ -6,7 +6,6 @@
#include "aos/common/controls/control_loop.h"
#include "frc971/control_loops/state_feedback_loop.h"
#include "aos/common/time.h"
-#include "aos/common/util/log_interval.h"
#include "frc971/constants.h"
#include "frc971/control_loops/shooter/shooter_motor_plant.h"
@@ -208,10 +207,6 @@
bool last_distal_current_;
bool last_proximal_current_;
- ::aos::util::SimpleLogInterval motors_off_log_ =
- ::aos::util::SimpleLogInterval(::aos::time::Time::InSeconds(0.05),
- WARNING, "motors disabled");
-
DISALLOW_COPY_AND_ASSIGN(ShooterMotor);
};