fixes to make the new sensor stuff work
diff --git a/aos/crio/controls/ControlsManager.cpp b/aos/crio/controls/ControlsManager.cpp
index 906394f..762e8b6 100644
--- a/aos/crio/controls/ControlsManager.cpp
+++ b/aos/crio/controls/ControlsManager.cpp
@@ -13,6 +13,10 @@
namespace aos {
namespace crio {
+ControlsManager::ControlsManager() {
+ printf("aos::ControlsManager constructor done\n");
+}
+
// Everything gets an explicit Start call here before calling all of the init
// functions because it means that all static variables will be initialized
// before anything actually starts running. It also means that everything will
@@ -35,6 +39,9 @@
aos_call_init_functions();
LOG(INFO, "initialized\n");
+ CreateObjects();
+ LOG(INFO, "created objects\n");
+
RegisterControlLoops();
LOG(INFO, "registered control loops\n");
diff --git a/aos/crio/controls/ControlsManager.h b/aos/crio/controls/ControlsManager.h
index aa78587..5971f46 100644
--- a/aos/crio/controls/ControlsManager.h
+++ b/aos/crio/controls/ControlsManager.h
@@ -8,6 +8,8 @@
// to be passed to START_ROBOT_CLASS (a WPILib macro) to start all of the code.
class ControlsManager : public RobotBase {
public:
+ ControlsManager();
+
virtual void StartCompetition();
static ControlsManager &GetInstance() {
@@ -20,6 +22,7 @@
private:
// Hooks that subclasses have to implement to do the correct things at the
// correct times.
+ virtual void CreateObjects() = 0;
virtual void RegisterControlLoops() = 0;
virtual void StartSensorBroadcasters() = 0;
};
diff --git a/aos/crio/motor_server/crio_control_loop_runner-tmpl.h b/aos/crio/motor_server/crio_control_loop_runner-tmpl.h
index 4bb448f..b4b1c40 100644
--- a/aos/crio/motor_server/crio_control_loop_runner-tmpl.h
+++ b/aos/crio/motor_server/crio_control_loop_runner-tmpl.h
@@ -11,7 +11,9 @@
sensors::SensorBroadcaster<Values> *broadcaster,
sensors::SensorUnpackerInterface<Values> *unpacker)
: broadcaster_(broadcaster),
- unpacker_(unpacker) {}
+ unpacker_(unpacker) {
+ broadcaster_->RegisterControlLoopRunner(this);
+}
template<class Values>
void CRIOControlLoopRunner<Values>::AddControlLoop(
@@ -22,7 +24,7 @@
template<class Values>
void CRIOControlLoopRunner<Values>::Process(sensors::SensorData<Values> *data) {
- unpacker_->UnpackFrom(&data.values);
+ unpacker_->UnpackFrom(&data->values);
for (auto it = loops_.begin(); it != loops_.end(); ++it) {
(*it)->Iterate();
}
diff --git a/aos/crio/shared_libs/interrupt_bridge-tmpl.h b/aos/crio/shared_libs/interrupt_bridge-tmpl.h
index ef53dce..4550e7f 100644
--- a/aos/crio/shared_libs/interrupt_bridge-tmpl.h
+++ b/aos/crio/shared_libs/interrupt_bridge-tmpl.h
@@ -80,7 +80,7 @@
typename InterruptBridge<T>::Handler handler,
T *param, int priority)
: InterruptBridge<T>(handler, param, priority),
- period_(-1, -1) {}
+ period_(0, 0) {}
template<typename T>
void PeriodicNotifier<T>::StartPeriodic(time::Time period) {