Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

orb-ui: control the gimbal #240

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions orb-ui/src/engine/diamond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ impl Runner<DIAMOND_RING_LED_COUNT, DIAMOND_CENTER_LED_COUNT> {
capture_sound: sound::capture::CaptureLoopSound::default(),
is_api_mode: false,
paused: false,
gimbal: None,
}
}

Expand Down Expand Up @@ -939,6 +940,9 @@ impl EventHandler for Runner<DIAMOND_RING_LED_COUNT, DIAMOND_CENTER_LED_COUNT> {
self.sound
.queue(sound::Type::Melody(sound::Melody::BootUp), None)?;
}
Event::Gimbal { x, y } => {
self.gimbal = Some((*x, *y));
}
}
Ok(())
}
Expand Down Expand Up @@ -987,6 +991,25 @@ impl EventHandler for Runner<DIAMOND_RING_LED_COUNT, DIAMOND_CENTER_LED_COUNT> {
self.paused = true;
tracing::info!("UI paused in API mode");
}

if let Some((x, y)) = self.gimbal {
interface_tx.try_send(Message::JMessage(JetsonToMcu {
ack_number: 0,
payload: Some(jetson_to_mcu::Payload::MirrorAngle(
orb_messages::mcu_main::MirrorAngle {
horizontal_angle: 0,
vertical_angle: 0,
phi_angle_millidegrees: x,
theta_angle_millidegrees: y,
angle_type: orb_messages::mcu_main::MirrorAngleType::PhiTheta
as i32,
},
)),
}))?;

// send only once
self.gimbal = None;
}
Ok(())
}
}
10 changes: 10 additions & 0 deletions orb-ui/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,15 @@ event_enum! {
/// Plays boot-up complete sound for testing
#[event_enum(method = sound_test)]
SoundTest,

/// Set the gimbal position
/// angle x and y in millidegrees.
/// x controls the horizontal position
/// y controls the vertical position
#[event_enum(method = gimbal)]
Gimbal {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to document - what are the units, and are they absolute values or deltas?

x: u32, y: u32
},
}
}

Expand Down Expand Up @@ -477,6 +486,7 @@ struct Runner<const RING_LED_COUNT: usize, const CENTER_LED_COUNT: usize> {
is_api_mode: bool,
/// Pause engine
paused: bool,
gimbal: Option<(u32, u32)>,
}

#[async_trait]
Expand Down
4 changes: 4 additions & 0 deletions orb-ui/src/engine/pearl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ impl Runner<PEARL_RING_LED_COUNT, PEARL_CENTER_LED_COUNT> {
capture_sound: sound::capture::CaptureLoopSound::default(),
is_api_mode: false,
paused: false,
gimbal: None,
}
}

Expand Down Expand Up @@ -790,6 +791,9 @@ impl EventHandler for Runner<PEARL_RING_LED_COUNT, PEARL_CENTER_LED_COUNT> {
self.sound
.queue(sound::Type::Melody(sound::Melody::BootUp), None)?;
}
Event::Gimbal { x: _, y: _ } => {
// ignore
}
}
Ok(())
}
Expand Down
Loading