pub struct TelemetryRecord<'a> {
pub dt: Duration,
pub command: &'a Command,
pub setpoint: &'a Setpoint,
pub state: &'a VehicleState,
pub control: &'a ControlOutput,
pub actuators: &'a ActuatorCommand,
pub saturation: Saturation,
pub failsafe: Option<FailsafeState>,
pub flight_mode: FlightModeReport,
pub wind: Option<WindEstimate>,
}Expand description
One control-loop tick, as handed to a TelemetryPublisher.
The loop assembles it after actuating, so every stage’s output is available. Fields borrow
from the loop and live only for the tick; publishers copy what they need to keep. New
fields can be added without changing the publish signature (struct literals, as in tests,
need the new field; testing::RecordedTick::as_record, behind the testing feature,
builds one from an owned copy).
§Examples
use std::time::Duration;
use stable_flight::{
ActuatorCommand, Command, ControlOutput, FlightModeReport, Saturation, Setpoint,
TelemetryPublisher, TelemetryRecord, VehicleState,
};
struct ThrustLogger;
impl TelemetryPublisher for ThrustLogger {
fn publish(&mut self, record: &TelemetryRecord) {
println!("{:?}: thrust {}", record.dt, record.control.thrust);
}
}
let command = Command::default();
let setpoint = Setpoint::Attitude(Default::default());
let state = VehicleState::default();
let control = ControlOutput::default();
let actuators = ActuatorCommand::default();
ThrustLogger.publish(&TelemetryRecord {
dt: Duration::from_millis(4),
command: &command,
setpoint: &setpoint,
state: &state,
control: &control,
actuators: &actuators,
saturation: Saturation::default(),
failsafe: None,
flight_mode: FlightModeReport::default(),
wind: None,
});Fields§
§dt: DurationNominal loop period (1 / target frequency), not measured elapsed time.
command: &'a CommandCommand the commander produced.
setpoint: &'a SetpointSetpoint guidance derived from command (neutral while disarmed).
state: &'a VehicleStateEstimated vehicle state the stabilizer acted on.
control: &'a ControlOutputStabilizer output (thrust and moments; zero while disarmed).
actuators: &'a ActuatorCommandMixer output sent to the actuators (ActuatorCommand::default while disarmed).
saturation: SaturationLimits guidance, the stabilizer, and the mixer hit this tick, merged
(Saturation::default while disarmed).
failsafe: Option<FailsafeState>Which commander a failsafe let fly this tick (Commander::failsafe); None without
a failsafe.
flight_mode: FlightModeReportThe flight mode guidance flew this tick (Guidance::flight_mode), and why it isn’t
the requested Command::regime when it can’t be. A disarmed tick, where guidance
doesn’t run, records FlightModeReport::copter_only.
wind: Option<WindEstimate>Guidance’s wind estimate (Guidance::wind); None without one.
Trait Implementations§
Source§impl<'a> Clone for TelemetryRecord<'a>
impl<'a> Clone for TelemetryRecord<'a>
impl<'a> Copy for TelemetryRecord<'a>
Source§impl<'a> Debug for TelemetryRecord<'a>
impl<'a> Debug for TelemetryRecord<'a>
Source§impl From<&TelemetryRecord<'_>> for RecordedTick
impl From<&TelemetryRecord<'_>> for RecordedTick
Source§fn from(record: &TelemetryRecord<'_>) -> Self
fn from(record: &TelemetryRecord<'_>) -> Self
Auto Trait Implementations§
impl<'a> Freeze for TelemetryRecord<'a>
impl<'a> RefUnwindSafe for TelemetryRecord<'a>
impl<'a> Send for TelemetryRecord<'a>
impl<'a> Sync for TelemetryRecord<'a>
impl<'a> Unpin for TelemetryRecord<'a>
impl<'a> UnsafeUnpin for TelemetryRecord<'a>
impl<'a> UnwindSafe for TelemetryRecord<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.