mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
fix(safety,openxr,dvr,config): harden RC/firmware failsafes, OpenXR lifecycle, DVR StreamCopy, relay & persistent config
This commit is contained in:
1 parent
8028680f07
commit
d82a65d9e6
24 files changed
+2246
-638
No files matched your search
+27
-14
@@ -102,15 +102,6 @@ impl NomadHeadTracker {
|
||||
max_roll_deg: f32,
|
||||
protocol: NomadProtocol,
|
||||
) -> Result<Self> {
|
||||
let socket = UdpSocket::bind("0.0.0.0:0").map_err(|e| {
|
||||
log::error!(
|
||||
"[Wi-Fi Nomad] Impossible de créer le socket UDP sortant : {}",
|
||||
e
|
||||
);
|
||||
e
|
||||
})?;
|
||||
socket.set_nonblocking(true)?;
|
||||
|
||||
let trimmed_ip = nomad_ip.trim();
|
||||
let host_port = format!("{}:{}", trimmed_ip, nomad_port);
|
||||
let target = if let Ok(ip) = trimmed_ip.parse::<std::net::IpAddr>() {
|
||||
@@ -135,6 +126,16 @@ impl NomadHeadTracker {
|
||||
.ok_or_else(|| anyhow!("Aucune adresse IP résolue pour {}", host_port))?
|
||||
};
|
||||
|
||||
let bind_addr = if target.is_ipv6() { "[::]:0" } else { "0.0.0.0:0" };
|
||||
let socket = UdpSocket::bind(bind_addr).map_err(|e| {
|
||||
log::error!(
|
||||
"[Wi-Fi Nomad] Impossible de créer le socket UDP sortant : {}",
|
||||
e
|
||||
);
|
||||
e
|
||||
})?;
|
||||
socket.set_nonblocking(true)?;
|
||||
|
||||
log::info!(
|
||||
"[Wi-Fi Nomad] Émetteur prêt vers {} ({}) (Protocole: {})",
|
||||
host_port,
|
||||
@@ -160,13 +161,25 @@ impl NomadHeadTracker {
|
||||
|
||||
/// Réinitialise le centre du suivi de tête (Tare) sur la posture actuelle du casque
|
||||
pub fn recenter(&mut self, current_orientation: Quat) {
|
||||
self.zero_quat_inv = current_orientation.inverse();
|
||||
let safe_q = if current_orientation.is_finite()
|
||||
&& current_orientation.length_squared() > 1e-8
|
||||
{
|
||||
current_orientation.normalize()
|
||||
} else {
|
||||
Quat::IDENTITY
|
||||
};
|
||||
self.zero_quat_inv = safe_q.inverse();
|
||||
log::info!("[Head-Tracker] Centre (Tare) réinitialisé sur la position actuelle du casque.");
|
||||
}
|
||||
|
||||
/// Calcule Pan/Tilt/Roll depuis le quaternion OpenXR et envoie la trame UDP au Nomad
|
||||
pub fn send_pose(&mut self, current_orientation: Quat) -> Result<HeadPoseSample> {
|
||||
let relative = (self.zero_quat_inv * current_orientation).normalize();
|
||||
let raw_rel = self.zero_quat_inv * current_orientation;
|
||||
let relative = if raw_rel.is_finite() && raw_rel.length_squared() > 1e-8 {
|
||||
raw_rel.normalize()
|
||||
} else {
|
||||
Quat::IDENTITY
|
||||
};
|
||||
|
||||
let (yaw_rad, pitch_rad, roll_rad) = relative.to_euler(EulerRot::YXZ);
|
||||
|
||||
@@ -299,9 +312,9 @@ impl NomadHeadTracker {
|
||||
|
||||
pub fn encode_crsf_rc_channels(pan: u16, tilt: u16, roll: u16) -> [u8; 26] {
|
||||
let mut ch = [CRSF_CHANNEL_MID; 16];
|
||||
ch[0] = pan;
|
||||
ch[1] = tilt;
|
||||
ch[2] = roll;
|
||||
ch[0] = pan.clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX);
|
||||
ch[1] = tilt.clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX);
|
||||
ch[2] = roll.clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX);
|
||||
|
||||
let mut frame = [0u8; 26];
|
||||
frame[0] = 0xEE;
|
||||
|
||||
Reference in new issue
Block a user