Skip to main content

SitlAutopilot

Struct SitlAutopilot 

Source
pub struct SitlAutopilot { /* private fields */ }
Expand description

A hardware-free autopilot stand-in for software-in-the-loop testing.

It behaves like the parts of an autopilot a ground station first talks to: it emits a Heartbeat on demand, answers a CommandLong with a CommandAck, and speaks both sides of the mission protocol, receiving an uploaded plan and serving it back on download. Wire it to one end of a MemoryLink::pair and drive a ground-station Connection or a Vehicle on the other to exercise the full connect, command, mission, and telemetry path in a test.

Implementations§

Source§

impl SitlAutopilot

Source

pub fn new(link: MemoryLink, system_id: u8, component_id: u8) -> Self

Creates a SITL autopilot on a link, sending as the given system and component.

§Arguments
  • link - the autopilot’s end of a linked pair.
  • system_id - the vehicle’s system id.
  • component_id - the autopilot component id.
§Returns

The autopilot, with signing off.

Source

pub fn load_mission(&mut self, items: &[MissionItemInt])

Preloads the plan the autopilot serves on a mission download.

§Arguments
  • items - the mission items to store.
Source

pub fn secured(self, signer: Signer, verifier: Verifier) -> Self

Signs the autopilot’s outgoing frames and verifies incoming ones with the same key.

§Arguments
  • signer - the signer for outgoing frames.
  • verifier - the verifier for incoming signed frames.
§Returns

The autopilot, for chaining.

Source

pub async fn emit_heartbeat(&mut self) -> Result<()>

Emits a heartbeat announcing the vehicle as an active quadrotor.

§Returns

Ok(()) once the heartbeat has been sent.

§Errors

Returns a link error if the heartbeat cannot be written.

Source

pub async fn serve_once(&mut self) -> Result<Frame>

Reads one frame and answers it the way an autopilot would.

A command is acknowledged as accepted; a mission upload is received and stored; a mission download is served from the stored plan. Any other frame is read and left unanswered. Call it in a loop to keep the autopilot responsive.

§Returns

The frame that was read.

§Errors

Returns the same errors as Connection::recv and Connection::send.

Auto Trait Implementations§

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> 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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.