Compare commits

..

3 Commits

Author SHA1 Message Date
d4bc537cbd
rotctl: actually quit when receiving the quit message 2024-07-18 21:47:50 -07:00
8037568f38
rotctl: add autopark functionality
Since gpredict doesn't have a park button or anything, this will just
automatically park the antenna when the gpredict rotator controller
disconnects. This may or may not actually be a good idea. We will see.
2024-07-18 21:47:50 -07:00
61c10df63d
controller: restructure control loop
This should have been multiple commits, but it isn't. Sue me. This
change has two main goals:

1. Sample feedback at the beginning of the control loop iteration so
   that it is always up-to-date when we are computing the actual drive
   outputs. This means we're doing twice the amount of communication
   with the labjack (previously, setting the output and reading the
   feedback was done with a singe command). However, this makes the
   loop structure much more standard, and it means that we aren't
   constantly operating on feedback that is stale by one loop
   interval.

2. Sample feedback into a (configurable size) buffer. This lets us
   operate on aggregated feedback rather than on a single instantaneous
   data point. Right now, feedback is computed as a moving average,
   which acts as a rudimentary low-pass filter, reducing spurious
   single-loop actions due to feedback spikes or other noise. However,
   the other reason to aggregate some backwards data is that it will
   let us do automatic stall detection in a simple way, although that
   is not currently done.
2024-07-18 21:47:50 -07:00
2 changed files with 6 additions and 4 deletions

View File

@ -92,7 +92,7 @@ pub fn validate(self: Config, err_writer: anytype) !void {
rotctl: RotControlConfig = .{
.listen_address = "127.0.0.1",
.listen_port = 4533,
.autopark = true,
.autopark = false,
},
labjack: LabjackConfig = .{
.device = .autodetect,

View File

@ -366,10 +366,12 @@ const Controller = struct {
continue;
};
self.lock.lock();
defer self.lock.unlock();
{
self.lock.lock();
defer self.lock.unlock();
self.setPosition(self.feedback_buffer.get());
self.setPosition(self.feedback_buffer.get());
}
switch (self.current_state) {
.initializing, .idle => {