Skip to main content

TelemetryRecord

Struct TelemetryRecord 

Source
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: Duration

Nominal loop period (1 / target frequency), not measured elapsed time.

§command: &'a Command

Command the commander produced.

§setpoint: &'a Setpoint

Setpoint guidance derived from command (neutral while disarmed).

§state: &'a VehicleState

Estimated vehicle state the stabilizer acted on.

§control: &'a ControlOutput

Stabilizer output (thrust and moments; zero while disarmed).

§actuators: &'a ActuatorCommand

Mixer output sent to the actuators (ActuatorCommand::default while disarmed).

§saturation: Saturation

Limits 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: FlightModeReport

The 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>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for TelemetryRecord<'a>

Source§

impl<'a> Debug for TelemetryRecord<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&TelemetryRecord<'_>> for RecordedTick

Source§

fn from(record: &TelemetryRecord<'_>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Forget for TelemetryRecord<'a>

§

impl<'a> Freeze for TelemetryRecord<'a>

§

impl<'a> Move 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.