adds the code used for the controller demo

This commit is contained in:
2026-08-20 19:59:27 -07:00
parent d9728b8680
commit fa4c6e8495
12 changed files with 362 additions and 108 deletions
+9 -4
View File
@@ -23,6 +23,7 @@ use nautilus_common::command::set_pwm::SetPwm;
const MAX_DATETIME: DateTime<Utc> = DateTime::from_timestamp_nanos(i64::MAX);
const PIN_PRIORITY: u8 = 1;
const RCS_PRIORITY: u8 = 1;
const DRIVE_PRIORITY: u8 = 1;
pub struct CommandHandler<'a> {
@@ -66,12 +67,12 @@ impl From<RcsCommand> for SetRcs {
#[derive(IntoCommandDefinition)]
struct PwmCommand {
duty_cycle: u8
throttle: f64
}
impl From<PwmCommand> for SetPwm {
fn from(value: PwmCommand) -> Self {
Self {
duty_cycle: value.duty_cycle
throttle: value.throttle
}
}
}
@@ -158,10 +159,14 @@ impl<'a> CommandHandler<'a> {
{
let outgoing_commands_tx = outgoing_commands_tx.clone();
commands.push(self.cmd.register_handler("pwm.set", move |_, cmd: PwmCommand| -> anyhow::Result<_> {
commands.push(self.cmd.register_handler("drive.throttle.set", move |header, cmd: PwmCommand| -> anyhow::Result<_> {
trace!("Sending Pwm Set Command");
outgoing_commands_tx.try_send_command("/pwm/set", &SetPwm::from(cmd))?;
outgoing_commands_tx.try_send_command("/drive/throttle/set", &ValidPriorityCommand {
inner: SetPwm::from(cmd),
valid_until: header.timestamp + TimeDelta::seconds(5),
priority: DRIVE_PRIORITY,
})?;
Ok("Command Executed Successfully".to_string())
}));