removed some more old code
The old stuff for locking onto which packets to receive from sensors (it
was too general, done in a way more complicated than necessary way, and
didn't really work).
diff --git a/aos/build/aos_all.gyp b/aos/build/aos_all.gyp
index 95aaaa5..5caa6b7 100644
--- a/aos/build/aos_all.gyp
+++ b/aos/build/aos_all.gyp
@@ -20,12 +20,9 @@
'../common/common.gyp:queue_test',
'../common/common.gyp:die_test',
'../common/util/util.gyp:trapezoid_profile_test',
- '../common/sensors/sensors.gyp:sensor_receiver_test',
'../common/glibusb/glibusb.gyp:gbuffer_test',
'../common/glibusb/glibusb.gyp:glibusb_test',
'Common',
- # TODO(brians): move this to Common
- '<(AOS)/common/sensors/sensors.gyp:sensors_test',
],
},
{
diff --git a/aos/common/sensors/sensor_packer.h b/aos/common/sensors/sensor_packer.h
deleted file mode 100644
index cfcf045..0000000
--- a/aos/common/sensors/sensor_packer.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef AOS_COMMON_SENSORS_SENSOR_PACKER_H_
-#define AOS_COMMON_SENSORS_SENSOR_PACKER_H_
-
-namespace aos {
-namespace sensors {
-
-// An interface that handles reading input data and putting it into the sensor
-// values struct.
-// See sensors.h for an overview of where this fits in.
-template<class Values>
-class SensorPackerInterface {
- public:
- virtual ~SensorPackerInterface() {}
-
- // Reads the inputs (from WPILib etc) and writes the data into *values.
- virtual void PackInto(Values *values) = 0;
-};
-
-} // namespace sensors
-} // namespace aos
-
-#endif // AOS_COMMON_SENSORS_SENSOR_PACKER_H_
diff --git a/aos/common/sensors/sensor_receiver-tmpl.h b/aos/common/sensors/sensor_receiver-tmpl.h
deleted file mode 100644
index b260de8..0000000
--- a/aos/common/sensors/sensor_receiver-tmpl.h
+++ /dev/null
@@ -1,264 +0,0 @@
-#include "aos/common/inttypes.h"
-#include "aos/common/network_port.h"
-
-namespace aos {
-namespace sensors {
-
-template<class Values>
-const time::Time SensorReceiver<Values>::kJitterDelay =
- time::Time::InSeconds(0.003);
-// Not a multiple of kSensorSendFrequency to unwedge ourself if we hit some bug
-// where it needs to get off of that frequency to work.
-template<class Values>
-const time::Time SensorReceiver<Values>::kGiveupTime =
- time::Time::InSeconds(0.1555);
-
-template<class Values>
-SensorReceiver<Values>::SensorReceiver(
- SensorUnpackerInterface<Values> *unpacker)
- : unpacker_(unpacker),
- start_time_(0, 0),
- last_good_time_(0, 0) {
- Unsynchronize();
-}
-
-template<class Values>
-void SensorReceiver<Values>::RunIteration() {
- if (synchronized_) {
- if (ReceiveData()) {
- LOG(DEBUG, "receive said to try a reset\n");
- Unsynchronize();
- } else {
- // TODO(brians): resync on crio reboots (and update the times...)
- if (GoodPacket()) {
- unpacker_->UnpackFrom(&data_.values);
- last_good_time_ = time::Time::Now();
- } else {
- if ((time::Time::Now() - last_good_time_) > kGiveupTime) {
- LOG(INFO, "resetting because didn't get a good one in too long\n");
- Unsynchronize();
- } else {
- // We got a packet, but it wasn't an interesting one.
- }
- }
- }
- } else {
- LOG(INFO, "resetting to try receiving data\n");
- Reset();
- if (Synchronize()) {
- LOG(INFO, "synchronized successfully\n");
- synchronized_ = true;
- before_better_cycles_ = after_better_cycles_ = 0;
- last_good_time_ = time::Time::Now();
- } else {
- LOG(INFO, "synchronization failed\n");
- }
- }
-}
-
-template<class Values>
-bool SensorReceiver<Values>::GoodPacket() {
- bool good;
- // If it's a multiple of kSensorSendFrequency from start_count_.
- if (((data_.count - start_count_) % kSendsPerCycle) == 0) {
- if (((data_.count - start_count_) / kSendsPerCycle) >=
- ((NextLoopTime() - start_time_).ToNSec() / kLoopFrequency.ToNSec())) {
- good = true;
-#if 0
- if (((data_.count - start_count_) / kSendsPerCycle % 20) == 0) {
- LOG(DEBUG, "dropping one for fun\n");
- good = false;
- }
-#endif
- } else {
- LOG(INFO,
- "packet %" PRId32 " late. is packet #%d, wanted #%" PRId64 " now\n",
- data_.count, (data_.count - start_count_) / kSendsPerCycle,
- (NextLoopTime() - start_time_).ToNSec() / kLoopFrequency.ToNSec());
- good = false;
- }
- } else {
- good = false;
- }
-
- static time::Time last_time(0, 0);
- time::Time now = time::Time::Now();
- time::Time next_goal_time = NextLoopTime() - kJitterDelay;
- // If this is the packet after the right one.
- if (((data_.count - start_count_ - 1) % kSendsPerCycle) == 0) {
- // If this one is much closer than the last one (aka the one that we used).
- if ((now - next_goal_time).abs() * 11 / 10 <
- (last_time - next_goal_time).abs()) {
- LOG(DEBUG, "next one better than one being used %d\n",
- after_better_cycles_);
- if (after_better_cycles_ > kBadCyclesToSwitch) {
- LOG(INFO, "switching to the packet after\n");
- ++start_count_;
- before_better_cycles_ = after_better_cycles_ = 0;
- } else {
- ++after_better_cycles_;
- }
- } else {
- after_better_cycles_ = 0;
- }
- }
- // If this is the right packet.
- if (((data_.count - start_count_) % kSendsPerCycle) == 0) {
- // If the last one was closer than this one (aka the one that we used).
- if ((last_time - next_goal_time).abs() * 11 / 10 <
- (now - next_goal_time).abs()) {
- LOG(DEBUG, "previous better than one being used %d\n",
- before_better_cycles_);
- if (before_better_cycles_ > kBadCyclesToSwitch) {
- LOG(INFO, "switching to the packet before\n");
- --start_count_;
- before_better_cycles_ = after_better_cycles_ = 0;
- } else {
- ++before_better_cycles_;
- }
- } else {
- before_better_cycles_ = 0;
- }
- }
- last_time = now;
-
- return good;
-}
-
-// Looks for when the timestamps transition from before where we want to after
-// and then picks whichever one was closer. After that, reads kTestCycles and
-// makes sure that at most 1 is bad.
-template<class Values>
-bool SensorReceiver<Values>::Synchronize() {
- time::Time old_received_time(0, 0);
- const time::Time start_time = time::Time::Now();
- // When we want to send out the next set of values.
- time::Time goal_time = NextLoopTime(start_time) - kJitterDelay;
- if (goal_time <= start_time) {
- goal_time += kLoopFrequency;
- }
- assert(goal_time > start_time);
- while (true) {
- if (ReceiveData()) return false;
- time::Time received_time = time::Time::Now();
- if (received_time >= goal_time) {
- // If this was the very first one we got, try again.
- if (old_received_time == time::Time(0, 0)){
- LOG(INFO, "first one we got was too late\n");
- return false;
- }
-
- assert(old_received_time < goal_time);
-
- // If the most recent one is closer than the last one.
- if ((received_time - goal_time).abs() <
- (old_received_time - goal_time).abs()) {
- start_count_ = data_.count;
- } else {
- start_count_ = data_.count - 1;
- }
- start_time_ = goal_time;
-
- int bad_count = 0;
- for (int i = 0; i < kTestCycles;) {
- ReceiveData();
- received_time = time::Time::Now();
- if (GoodPacket()) {
- LOG(DEBUG, "checking packet count=%" PRId32
- " received at %" PRId32 "s%" PRId32 "ns\n",
- data_.count, received_time.sec(), received_time.nsec());
- // If |the difference between the goal time for this numbered packet
- // and the time we actually got this one| is too big.
- if (((goal_time +
- kSensorSendFrequency * (data_.count - start_count_)) -
- received_time).abs() > kSensorSendFrequency) {
- LOG(INFO, "rejected time of the last good packet. "
- "got %" PRId32 "s%" PRId32 "ns."
- " wanted %" PRId32 "s%" PRId32 "ns\n",
- received_time.sec(), received_time.nsec(),
- goal_time.sec(), goal_time.nsec());
- ++bad_count;
- }
- ++i;
- }
- if (bad_count > 1) {
- LOG(WARNING, "got multiple packets with bad timestamps\n");
- return false;
- }
- }
-
- Synchronized(goal_time + kLoopFrequency * kTestCycles);
- return true;
- }
-
- old_received_time = received_time;
- }
-}
-
-template<class Values>
-bool SensorReceiver<Values>::ReceiveData() {
- int old_count = data_.count;
- if (DoReceiveData()) return true;
-
- if (data_.count < 0) {
- LOG(FATAL, "data count overflowed. currently %" PRId32 "\n", data_.count);
- }
- if (data_.count < old_count) {
- LOG(INFO, "count reset. was %" PRId32 ", now %" PRId32 "\n",
- old_count, data_.count);
- return true;
- }
- if (data_.count < start_count_) {
- LOG(INFO, "count reset. started at %" PRId32 ", now %" PRId32 "\n",
- start_count_, data_.count);
- }
- LOG(DEBUG, "received data count %" PRId32 "\n", data_.count);
- return false;
-}
-
-template<class Values>
-void SensorReceiver<Values>::Unsynchronize() {
- synchronized_ = false;
- before_better_cycles_ = after_better_cycles_ = 0;
-}
-
-template<class Values>
-const time::Time NetworkSensorReceiver<Values>::kWarmupTime =
- time::Time::InSeconds(0.075);
-
-template<class Values>
-NetworkSensorReceiver<Values>::NetworkSensorReceiver(
- SensorUnpackerInterface<Values> *unpacker)
- : SensorReceiver<Values>(unpacker),
- socket_(NetworkPort::kSensors) {}
-
-template<class Values>
-void NetworkSensorReceiver<Values>::Reset() {
- LOG(INFO, "beginning warm up\n");
- time::Time start = time::Time::Now();
- while ((time::Time::Now() - start) < kWarmupTime) {
- socket_.Receive(this->data(), sizeof(*this->data()));
- }
- LOG(INFO, "done warming up\n");
-}
-
-template<class Values>
-bool NetworkSensorReceiver<Values>::DoReceiveData() {
- while (true) {
- if (socket_.Receive(this->data(), sizeof(*this->data())) ==
- sizeof(*this->data())) {
- this->data()->checksum = ntoh(this->data()->checksum);
- if (!this->data()->CheckChecksum()) {
- LOG(WARNING, "got a bad packet\n");
- continue;
- }
-
- this->data()->NetworkToHost();
- return false;
- }
- LOG(WARNING, "received incorrect amount of data\n");
- }
-}
-
-} // namespace sensors
-} // namespace aos
diff --git a/aos/common/sensors/sensor_receiver.h b/aos/common/sensors/sensor_receiver.h
deleted file mode 100644
index 16b72ac..0000000
--- a/aos/common/sensors/sensor_receiver.h
+++ /dev/null
@@ -1,121 +0,0 @@
-#ifndef AOS_COMMON_SENSORS_SENSOR_RECEIVER_H_
-#define AOS_COMMON_SENSORS_SENSOR_RECEIVER_H_
-
-#include "aos/common/sensors/sensor_unpacker.h"
-#include "aos/common/network/ReceiveSocket.h"
-#include "aos/common/sensors/sensors.h"
-#include "aos/common/time.h"
-#include "aos/common/gtest_prod.h"
-
-namespace aos {
-namespace sensors {
-namespace testing {
-
-FORWARD_DECLARE_TEST_CASE(SensorReceiverTest, Simple);
-FORWARD_DECLARE_TEST_CASE(SensorReceiverTest, BadStartup2);
-FORWARD_DECLARE_TEST_CASE(SensorReceiverTest, StartTimeAndCountMismatch);
-
-} // namespace testing
-
-// A class that handles receiving sensor values from the cRIO.
-// See sensors.h for an overview of where this fits in.
-//
-// Abstract class to make testing the complex logic for choosing which data to
-// use easier.
-template<class Values>
-class SensorReceiver {
- public:
- // Does not take ownership of unpacker.
- SensorReceiver(SensorUnpackerInterface<Values> *unpacker);
-
- void RunIteration();
-
- protected:
- SensorData<Values> *data() { return &data_; }
-
- private:
- // How long before the control loops run to aim for receiving sensor data (to
- // prevent jitter if some packets arrive up to this much later).
- static const time::Time kJitterDelay;
- // How many cycles not to send data out to make sure that we're in phase
- // (during this time, the code verifies that <= 1 cycle is not within 1
- // cycle's time of kJitterDelay).
- static const int kTestCycles = 8;
- // How many cycles that we need (consecutively) of another packet being closer
- // to the right time than the ones we're reading before we switch.
- static const int kBadCyclesToSwitch = 8;
- // If we don't get a good packet in this long, then we Synchronize() again.
- static const time::Time kGiveupTime;
-
- FRIEND_TEST_NAMESPACE(SensorReceiverTest, Simple, testing);
- FRIEND_TEST_NAMESPACE(SensorReceiverTest, BadStartup2, testing);
- FRIEND_TEST_NAMESPACE(SensorReceiverTest, StartTimeAndCountMismatch, testing);
-
- // Subclasses need to implement this to read 1 set of data (blocking until it
- // is available) into data().
- // It needs to have the correct byte order etc and not be corrupted
- // (subclasses can check the checksum if they want).
- // Returns whether or not to Reset() and try synchronizing again.
- virtual bool DoReceiveData() = 0;
-
- // Optional: if subclasses can do anything to reinitialize after there are
- // problems, they should do it here.
- // This will be called right before calling DoReceiveData() the first time.
- virtual void Reset() {}
-
- // Optional: if subclasses want to be notified when this is first convinced
- // that it has a good packet, they should do whatever here.
- virtual void Synchronized(time::Time /*last_packet_ideal_time*/) {}
-
- // Returns whether the current packet looks like a good one to use.
- bool GoodPacket();
-
- // Synchronizes with incoming packets and sets start_count_ to where we
- // started reading.
- // Returns whether it succeeded in locking on.
- bool Synchronize();
- // Receives a set of values and makes sure that it's sane.
- // Returns whether to start over again with timing.
- bool ReceiveData();
- void Unsynchronize();
-
- SensorUnpackerInterface<Values> *const unpacker_;
- SensorData<Values> data_;
- // The count that we started out (all other sent packets will be multiples of
- // this).
- int32_t start_count_;
- // When start_count_ "should" have been received. Used for checking to make
- // sure that we don't send out a packet late.
- time::Time start_time_;
- bool synchronized_;
- int before_better_cycles_, after_better_cycles_;
- // The time of the last packet that we sent out.
- time::Time last_good_time_;
-
- DISALLOW_COPY_AND_ASSIGN(SensorReceiver<Values>);
-};
-
-// A SensorReceiver that receives data from a SensorBroadcaster.
-template<class Values>
-class NetworkSensorReceiver : public SensorReceiver<Values> {
- public:
- NetworkSensorReceiver(SensorUnpackerInterface<Values> *unpacker);
-
- private:
- // How long to read data as fast as possible for (to clear out buffers etc).
- static const time::Time kWarmupTime;
-
- virtual bool DoReceiveData();
- virtual void Reset();
-
- ReceiveSocket socket_;
-
- DISALLOW_COPY_AND_ASSIGN(NetworkSensorReceiver<Values>);
-};
-
-} // namespace sensors
-} // namespace aos
-
-#include "aos/common/sensors/sensor_receiver-tmpl.h"
-
-#endif // AOS_COMMON_SENSORS_SENSOR_RECEIVER_H_
diff --git a/aos/common/sensors/sensor_receiver_test.cc b/aos/common/sensors/sensor_receiver_test.cc
deleted file mode 100644
index 5032dfd..0000000
--- a/aos/common/sensors/sensor_receiver_test.cc
+++ /dev/null
@@ -1,159 +0,0 @@
-#include "aos/common/sensors/sensor_receiver.h"
-
-#include "gtest/gtest.h"
-
-#include "aos/common/sensors/sensors.h"
-#include "aos/common/time.h"
-#include "aos/common/queue_testutils.h"
-
-using ::aos::time::Time;
-
-namespace aos {
-namespace sensors {
-namespace testing {
-
-struct TestValues {
- int count;
- int more_data;
-};
-class TestSensorReceiver : public SensorReceiver<TestValues>,
- public SensorUnpackerInterface<TestValues> {
- public:
- TestSensorReceiver()
- : SensorReceiver<TestValues>(this),
- resets_(0),
- unpacks_(0) {
- data()->count = 0;
- }
-
- void Reset() {
- LOG(DEBUG, "reset for the %dth time\n", ++resets_);
- }
- bool DoReceiveData() {
- last_received_count_ = ++data()->count;
- data()->values.count = last_received_count_;
- Time::IncrementMockTime(kSensorSendFrequency);
- data()->FillinChecksum();
- data()->HostToNetwork();
- return false;
- }
-
- int resets() { return resets_; }
- int unpacks() { return unpacks_; }
- using SensorReceiver<TestValues>::data;
-
- void ResetFakeData() {
- data()->count = 0;
- }
-
- void UnpackFrom(TestValues *data) {
- // Make sure that it didn't lose one that we gave it.
- EXPECT_EQ(last_received_count_, data->count);
- ++unpacks_;
- LOG(DEBUG, "%dth unpack\n", unpacks_);
- }
-
- private:
- int resets_;
- int unpacks_;
- int last_received_count_;
-};
-
-class SensorReceiverTest : public ::testing::Test {
- protected:
- SensorReceiverTest() {
- ::aos::common::testing::EnableTestLogging();
- Time::EnableMockTime(Time(971, 254));
- }
-
- TestSensorReceiver &receiver() { return receiver_; }
-
- private:
- TestSensorReceiver receiver_;
-};
-
-TEST_F(SensorReceiverTest, Simple) {
- static const int kIterations = 53;
- for (int i = 0; i < kIterations; ++i) {
- receiver().RunIteration();
- }
- EXPECT_EQ(1, receiver().resets());
- // expected value is kIterations/kSendsPerCycle (rounded up) (the number of
- // times that it should get a good one) - 1 (to compensate for the iteration
- // when it synced itself up)
- EXPECT_EQ((kIterations + kSendsPerCycle - 1) / kSendsPerCycle - 1,
- receiver().unpacks());
-}
-
-TEST_F(SensorReceiverTest, CRIOReboot) {
- for (int i = 0; i < 50; ++i) {
- receiver().RunIteration();
- if (i == 27) {
- receiver().ResetFakeData();
- time::Time::IncrementMockTime(time::Time::InSeconds(20));
- }
- }
- EXPECT_EQ(2, receiver().resets());
- EXPECT_GE(receiver().unpacks(), 4);
-}
-
-TEST_F(SensorReceiverTest, CRIOSkew) {
- for (int i = 0; i < 505; ++i) {
- receiver().RunIteration();
- time::Time::IncrementMockTime(time::Time(0, 4000));
- }
- // TODO(brians) verify here that it actually corrects (happens twice with
- // current constants)
- EXPECT_EQ(1, receiver().resets());
- EXPECT_EQ(50, receiver().unpacks());
-}
-
-TEST_F(SensorReceiverTest, BadStartup1) {
- time::Time::SetMockTime(NextLoopTime() - Time(0, 100));
- for (int i = 0; i < 55; ++i) {
- receiver().RunIteration();
- }
- EXPECT_EQ(1, receiver().resets());
- EXPECT_EQ(5, receiver().unpacks());
-}
-
-TEST_F(SensorReceiverTest, BadStartup2) {
- time::Time::SetMockTime(NextLoopTime() -
- SensorReceiver<TestValues>::kJitterDelay -
- time::Time(0, 1));
- for (int i = 0; i < 55; ++i) {
- receiver().RunIteration();
- }
- EXPECT_EQ(2, receiver().resets());
- EXPECT_EQ(5, receiver().unpacks());
-}
-
-TEST_F(SensorReceiverTest, BadStartup3) {
- time::Time::SetMockTime(NextLoopTime() -
- time::Time::InSeconds(0.002) +
- kLoopFrequency / 20);
- for (int i = 0; i < 55; ++i) {
- receiver().RunIteration();
- }
- EXPECT_EQ(1, receiver().resets());
- EXPECT_EQ(5, receiver().unpacks());
-}
-
-// I think that it somehow got this way once and never recovered.
-// It should never get this way, but if it does, it should recover.
-TEST_F(SensorReceiverTest, StartTimeAndCountMismatch) {
- for (int i = 0; i < 1005; ++i) {
- receiver().RunIteration();
- if (i == 3) {
- receiver().start_count_ += 10;
- }
- }
- EXPECT_EQ(2, receiver().resets());
- EXPECT_GT(receiver().unpacks(), 30);
-}
-
-// TODO(brians) finish writing tests and commenting them and the code
-
-} // namespace testing
-} // namespace sensors
-} // namespace aos
diff --git a/aos/common/sensors/sensor_sink.h b/aos/common/sensors/sensor_sink.h
deleted file mode 100644
index 760f90e..0000000
--- a/aos/common/sensors/sensor_sink.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef AOS_COMMON_SENSORS_SENSOR_SINK_H_
-#define AOS_COMMON_SENSORS_SENSOR_SINK_H_
-
-#include "aos/common/sensors/sensors.h"
-
-namespace aos {
-namespace sensors {
-
-// Generic class for something that can do something with sensor data.
-template<class Values>
-class SensorSinkInterface {
- public:
- virtual ~SensorSinkInterface() {}
-
- virtual void Process(SensorData<Values> *data) = 0;
-};
-
-} // namespace sensors
-} // namespace aos
-
-#endif // AOS_COMMON_SENSORS_SENSOR_SINK_H_
diff --git a/aos/common/sensors/sensor_unpacker.h b/aos/common/sensors/sensor_unpacker.h
deleted file mode 100644
index b19e0c6..0000000
--- a/aos/common/sensors/sensor_unpacker.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef AOS_COMMON_SENSORS_SENSOR_UNPACKER_H_
-#define AOS_COMMON_SENSORS_SENSOR_UNPACKER_H_
-
-namespace aos {
-namespace sensors {
-
-// An interface that handles taking data from the sensor Values struct and
-// putting it into queues (for control loops etc).
-// See sensors.h for an overview of where this fits in.
-template<class Values>
-class SensorUnpackerInterface {
- public:
- virtual ~SensorUnpackerInterface() {}
-
- // Takes the data in *values and writes it out into queues etc.
- virtual void UnpackFrom(Values *values) = 0;
-};
-
-} // namespace sensors
-} // namespace aos
-
-#endif // AOS_COMMON_SENSORS_SENSOR_UNPACKER_H_
diff --git a/aos/common/sensors/sensors.cc b/aos/common/sensors/sensors.cc
deleted file mode 100644
index 60f411f..0000000
--- a/aos/common/sensors/sensors.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-#include "aos/common/sensors/sensors.h"
-
-namespace aos {
-namespace sensors {
-
-const time::Time kSensorSendFrequency =
- ::aos::control_loops::kLoopFrequency / kSendsPerCycle;
-
-namespace {
-
-// Table grabbed from <http://gcc.gnu.org/svn/gcc/trunk/libiberty/crc32.c>.
-const uint32_t crc32_table[] = {
- 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9,
- 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
- 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
- 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
- 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9,
- 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
- 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011,
- 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd,
- 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
- 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5,
- 0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81,
- 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
- 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49,
- 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
- 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1,
- 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d,
- 0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae,
- 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
- 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16,
- 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca,
- 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde,
- 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02,
- 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066,
- 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
- 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e,
- 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692,
- 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6,
- 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a,
- 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e,
- 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
- 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686,
- 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a,
- 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637,
- 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
- 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f,
- 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
- 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47,
- 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b,
- 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
- 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623,
- 0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7,
- 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
- 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f,
- 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
- 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7,
- 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b,
- 0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f,
- 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
- 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640,
- 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c,
- 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8,
- 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24,
- 0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30,
- 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
- 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088,
- 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654,
- 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0,
- 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c,
- 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18,
- 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
- 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0,
- 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
- 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
- 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
-};
-
-} // namespace
-uint32_t CalculateChecksum(char *buf, size_t size) {
- uint32_t ret = ~0;
- for (size_t i = 0; i < size; ++i) {
- ret = (ret << 8) ^ crc32_table[((ret >> 24) ^ buf[i]) & 255];
- }
- return ~ret;
-}
-
-} // namespace sensors
-} // namespace aos
diff --git a/aos/common/sensors/sensors.gyp b/aos/common/sensors/sensors.gyp
deleted file mode 100644
index b8a2092..0000000
--- a/aos/common/sensors/sensors.gyp
+++ /dev/null
@@ -1,76 +0,0 @@
-{
- 'targets': [
- {
- 'target_name': 'sensor_sink',
- 'type': 'static_library',
- 'sources': [
- ],
- 'dependencies': [
- 'sensors',
- ],
- 'export_dependent_settings': [
- 'sensors',
- ],
- },
- {
- 'target_name': 'sensors',
- 'type': 'static_library',
- 'sources': [
- 'sensors.cc'
- ],
- 'dependencies': [
- '<(AOS)/common/common.gyp:time',
- '<(AOS)/common/common.gyp:controls',
- ],
- 'export_dependent_settings': [
- '<(AOS)/common/common.gyp:time',
- '<(AOS)/common/common.gyp:controls',
- ],
- },
- {
- 'target_name': 'sensors_test',
- 'type': '<(aos_target)',
- 'sources': [
- 'sensors_test.cc',
- ],
- 'dependencies': [
- '<(EXTERNALS):gtest',
- 'sensors',
- '<(AOS)/common/common.gyp:queue_testutils',
- ],
- },
- {
- 'target_name': 'sensor_receiver',
- 'type': 'static_library',
- 'sources': [
- #'sensor_receiver-tmpl.h'
- ],
- 'dependencies': [
- '<(AOS)/common/network/network.gyp:socket',
- 'sensors',
- '<(AOS)/common/common.gyp:time',
- '<(AOS)/common/common.gyp:gtest_prod',
- ],
- 'export_dependent_settings': [
- '<(AOS)/common/network/network.gyp:socket',
- 'sensors',
- '<(AOS)/common/common.gyp:time',
- '<(AOS)/common/common.gyp:gtest_prod',
- ],
- },
- {
- 'target_name': 'sensor_receiver_test',
- 'type': 'executable',
- 'sources': [
- 'sensor_receiver_test.cc',
- ],
- 'dependencies': [
- '<(EXTERNALS):gtest',
- 'sensor_receiver',
- '<(AOS)/common/common.gyp:time',
- 'sensors',
- '<(AOS)/common/common.gyp:queue_testutils',
- ],
- },
- ],
-}
diff --git a/aos/common/sensors/sensors.h b/aos/common/sensors/sensors.h
deleted file mode 100644
index 78fd8a9..0000000
--- a/aos/common/sensors/sensors.h
+++ /dev/null
@@ -1,83 +0,0 @@
-#ifndef AOS_COMMON_SENSORS_SENSORS_H_
-#define AOS_COMMON_SENSORS_SENSORS_H_
-
-#include "aos/common/time.h"
-#include "aos/common/byteorder.h"
-#include "aos/common/control_loop/ControlLoop.h"
-#include "aos/common/inttypes.h"
-
-namespace aos {
-// This namespace contains all of the stuff for dealing with reading sensors and
-// communicating it to everything that needs it. There are 4 main classes whose
-// instances actually process the data. They must all be registered in the
-// appropriate ::aos::crio::ControlsManager hooks.
-//
-// SensorPackers get run on the cRIO to read inputs (from WPILib or elsewhere)
-// and put the values into the Values struct (which is templated for all of the
-// classes that use it).
-// SensorUnpackers get run on both the atom and the cRIO to take the data from
-// the Values struct and put them into queues for control loops etc.
-// SensorBroadcasters (on the cRIO) send the data to a SensorReceiver (on the
-// atom) to pass to its SensorUnpacker there.
-// CRIOControlLoopRunners register with a SensorBroadcaster to get called right
-// after reading the sensor data so that they can immediately pass it so a
-// SensorUnpacker and then run their control loops.
-// The actual SensorPacker and SensorUnpacker classes have the Interface suffix
-// on them.
-namespace sensors {
-
-// How many times per ::aos::control_loops::kLoopFrequency sensor
-// values get sent out by the cRIO.
-// This must evenly divide that frequency into multiples of sysClockRateGet().
-const int kSendsPerCycle = 10;
-// ::aos::control_loops::kLoopFrequency / kSendsPerCycle for
-// convenience.
-extern const time::Time kSensorSendFrequency;
-using ::aos::control_loops::kLoopFrequency;
-using ::aos::control_loops::NextLoopTime;
-
-uint32_t CalculateChecksum(char *buf, size_t size);
-
-// This is the struct that actually gets sent over the UDP socket.
-template<class Values>
-struct SensorData {
- // All of the other 4-byte chunks in the message bitwise-exclusive-ORed
- // together. Needed because it seems like nobody else checks... (vxworks not
- // sending the UDP checksum or (not very likely) linux not checking it).
- // TODO(brians): static_assert that this is at the front
- uint32_t checksum;
-
- Values values;
- // Starts at 0 and goes up.
- int32_t count;
-
- void NetworkToHost() {
- count = ntoh(count);
- }
- void HostToNetwork() {
- count = hton(count);
- }
-
- void FillinChecksum() {
- checksum = CalculateChecksum(reinterpret_cast<char *>(this) +
- sizeof(checksum),
- sizeof(*this) - sizeof(checksum));
- }
- // Returns whether or not checksum is correct.
- bool CheckChecksum() {
- uint32_t expected = CalculateChecksum(reinterpret_cast<char *>(this) +
- sizeof(checksum),
- sizeof(*this) - sizeof(checksum));
- if (checksum != expected) {
- LOG(INFO, "expected %" PRIx32 " but got %" PRIx32 "\n",
- expected, checksum);
- return false;
- }
- return true;
- }
-} __attribute__((packed));
-
-} // namespace sensors
-} // namespace aos
-
-#endif // AOS_COMMON_SENSORS_SENSORS_H_
diff --git a/aos/common/sensors/sensors_test.cc b/aos/common/sensors/sensors_test.cc
deleted file mode 100644
index 0df93c9..0000000
--- a/aos/common/sensors/sensors_test.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-#include "aos/common/sensors/sensors.h"
-
-#include <stdint.h>
-
-#include "gtest/gtest.h"
-
-#include "aos/common/queue_testutils.h"
-
-namespace aos {
-namespace sensors {
-namespace testing {
-
-struct TestValues {
- int32_t data1, data2;
-};
-
-TEST(SensorDataTest, Checksum) {
- ::aos::common::testing::EnableTestLogging();
-
- SensorData<TestValues> data;
- data.values.data1 = 0;
- data.values.data2 = 5;
- data.FillinChecksum();
- EXPECT_TRUE(data.CheckChecksum());
- data.values.data1 = 1;
- EXPECT_FALSE(data.CheckChecksum());
- data.values.data1 = 0xFFFFFFFF;
- EXPECT_FALSE(data.CheckChecksum());
- data.values.data1 = 0;
- EXPECT_TRUE(data.CheckChecksum());
- data.values.data1 = 5;
- data.values.data2 = 0;
- EXPECT_FALSE(data.CheckChecksum());
-}
-
-} // namespace testing
-} // namespace sensors
-} // namespace aos
diff --git a/frc971/input/gyro_board_reader.cc b/frc971/input/gyro_board_reader.cc
index f701898..a094c4e 100644
--- a/frc971/input/gyro_board_reader.cc
+++ b/frc971/input/gyro_board_reader.cc
@@ -1,7 +1,8 @@
#include <libusb-1.0/libusb.h>
-#include <memory>
#include <string.h>
+#include <memory>
+
#include "aos/common/inttypes.h"
#include "aos/atom_code/init.h"
#include "aos/common/logging/logging.h"
diff --git a/frc971/input/input.gyp b/frc971/input/input.gyp
index 4f57cbf..225a855 100644
--- a/frc971/input/input.gyp
+++ b/frc971/input/input.gyp
@@ -37,7 +37,6 @@
'<(AOS)/atom_code/atom_code.gyp:init',
'<(AOS)/build/aos.gyp:logging',
'<(AOS)/common/common.gyp:time',
- '<(AOS)/common/sensors/sensors.gyp:sensor_receiver',
'<(AOS)/common/glibusb/glibusb.gyp:glibusb',
'<(AOS)/common/glibusb/glibusb.gyp:gbuffer',
],