got the output check pulse thing working (I think)
diff --git a/frc971/input/input.gyp b/frc971/input/input.gyp
index c91a8ac..b7204d4 100644
--- a/frc971/input/input.gyp
+++ b/frc971/input/input.gyp
@@ -43,6 +43,7 @@
'<(AOS)/common/logging/logging.gyp:queue_logging',
'<(DEPTH)/frc971/control_loops/claw/claw.gyp:claw_loop',
'<(DEPTH)/frc971/control_loops/shooter/shooter.gyp:shooter_loop',
+ '<(DEPTH)/frc971/queues/queues.gyp:output_check',
],
},
],
diff --git a/frc971/input/sensor_receiver.cc b/frc971/input/sensor_receiver.cc
index 2c97508..b83dc4e 100644
--- a/frc971/input/sensor_receiver.cc
+++ b/frc971/input/sensor_receiver.cc
@@ -14,6 +14,7 @@
#include "frc971/queues/to_log.q.h"
#include "frc971/control_loops/shooter/shooter.q.h"
#include "frc971/control_loops/claw/claw.q.h"
+#include "frc971/queues/output_check.q.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
@@ -178,6 +179,19 @@
LOG(WARNING, "%" PRIu8 " analog errors\n", data->analog_errors);
}
+ if (data->main.output_check_pulse_length != 0) {
+ auto message = ::frc971::output_check_received.MakeMessage();
+ message->pulse_length =
+ static_cast<double>(data->main.output_check_pulse_length) / 100.0;
+ if (message->pulse_length > 2.7) {
+ LOG(WARNING, "insane PWM pulse length %fms\n", message->pulse_length);
+ } else {
+ message->pwm_value = (message->pulse_length - 0.5) / 2.0 * 255.0 + 0.5;
+ LOG_STRUCT(DEBUG, "received", *message);
+ message.Send();
+ }
+ }
+
other_sensors.MakeWithBuilder()
.sonar_distance(sonar_translate(data->main.ultrasonic_pulse_length))
.Send();
diff --git a/frc971/output/motor_writer.cc b/frc971/output/motor_writer.cc
index eefd7d6..fa3fe33 100644
--- a/frc971/output/motor_writer.cc
+++ b/frc971/output/motor_writer.cc
@@ -95,11 +95,13 @@
}
{
- auto message = ::frc971::output_check_queue.MakeMessage();
+ auto message = ::frc971::output_check_sent.MakeMessage();
++output_check_;
if (output_check_ == 0) output_check_ = 1;
SetRawPWMOutput(10, output_check_);
- message->sent_value = output_check_;
+ message->pwm_value = output_check_;
+ message->pulse_length =
+ static_cast<double>(message->pwm_value) / 255.0 * 2.0 + 0.5;
LOG_STRUCT(DEBUG, "sending", *message);
message.Send();
}
diff --git a/frc971/queues/output_check.q b/frc971/queues/output_check.q
index 0573426..11b3497 100644
--- a/frc971/queues/output_check.q
+++ b/frc971/queues/output_check.q
@@ -1,8 +1,14 @@
package frc971;
message OutputCheck {
- uint8_t sent_value;
+ // The 1-255 sent to the FPGA.
+ uint8_t pwm_value;
+ // The length of the pulse in milliseconds.
+ double pulse_length;
};
+
// Each message here represents a value that was sent to the cRIO.
// The sent timestamp of the message is when the value was sent.
-queue OutputCheck output_check_queue;
+queue OutputCheck output_check_sent;
+
+queue OutputCheck output_check_received;