pub struct Vehicle<L> { /* private fields */ }Expand description
A MAVLink vehicle over a ByteLink, exposed through the pamoja device model.
A vehicle sends as a ground station (its own system and component id) and addresses a target
vehicle. The target is learned from the first heartbeat unless it is pinned with
with_target. Attach signing with
with_signer and with_verifier.
Implementations§
Source§impl<L: ByteLink> Vehicle<L>
impl<L: ByteLink> Vehicle<L>
Sourcepub fn new(link: L, system_id: u8, component_id: u8) -> Self
pub fn new(link: L, system_id: u8, component_id: u8) -> Self
Creates a vehicle client sending as the given ground-station identity.
The target vehicle defaults to system 1, component 1, and is updated from the first
heartbeat seen during connect.
§Arguments
link- the byte link to the vehicle.system_id- this ground station’s system id.component_id- this ground station’s component id.
§Returns
The vehicle client, with signing off.
Sourcepub fn with_target(self, system_id: u8, component_id: u8) -> Self
pub fn with_target(self, system_id: u8, component_id: u8) -> Self
Sourcepub fn with_signer(self, signer: Signer) -> Self
pub fn with_signer(self, signer: Signer) -> Self
Sourcepub fn with_verifier(self, verifier: Verifier) -> Self
pub fn with_verifier(self, verifier: Verifier) -> Self
Sourcepub fn target_system(&self) -> u8
pub fn target_system(&self) -> u8
Sourcepub fn target_component(&self) -> u8
pub fn target_component(&self) -> u8
Sourcepub async fn send_heartbeat(&mut self) -> CoreResult<()>
pub async fn send_heartbeat(&mut self) -> CoreResult<()>
Sends a ground-station heartbeat, which some autopilots require before they accept commands.
§Returns
Ok(()) once the heartbeat has been sent.
§Errors
Returns Error::Transport if the frame cannot be sent.
Sourcepub async fn recv(&mut self) -> CoreResult<Report>
pub async fn recv(&mut self) -> CoreResult<Report>
Reads the next telemetry report from the vehicle.
Unlike [Telemetry::next_frame], this treats a closed link as an error rather than an
end of stream.
§Returns
The next decoded Report.
§Errors
Returns Error::Closed if the link ends, or
Error::Transport on a link fault.
Sourcepub async fn send_command(
&mut self,
command: u16,
params: [f32; 7],
) -> CoreResult<u8>
pub async fn send_command( &mut self, command: u16, params: [f32; 7], ) -> CoreResult<u8>
Sends a command to the vehicle and awaits its result, retransmitting on timeout.
The command is sent as a COMMAND_LONG and matched to its COMMAND_ACK. An
in-progress acknowledgement extends the wait; a missing acknowledgement resends the
command with an incremented confirmation, up to the retry budget.
§Arguments
command- theMAV_CMDid.params- the seven command parameters.
§Returns
The MAV_RESULT the vehicle reported, including a
rejection such as DENIED.
§Errors
Returns Error::Transport if the command is not
acknowledged within the retry budget or the link faults.
Sourcepub async fn arm(&mut self, arm: bool) -> CoreResult<u8>
pub async fn arm(&mut self, arm: bool) -> CoreResult<u8>
Arms or disarms the vehicle.
§Arguments
arm-trueto arm,falseto disarm.
§Returns
The MAV_RESULT of the arm command.
§Errors
As send_command.
Sourcepub async fn set_mode(
&mut self,
base_mode: u8,
custom_mode: u32,
) -> CoreResult<u8>
pub async fn set_mode( &mut self, base_mode: u8, custom_mode: u32, ) -> CoreResult<u8>
Requests a mode change.
§Arguments
base_mode- theMAV_MODE_FLAGbase-mode bits.custom_mode- the autopilot-specific custom mode.
§Returns
The MAV_RESULT of the mode command.
§Errors
As send_command.
Sourcepub async fn takeoff(&mut self, altitude: f32) -> CoreResult<u8>
pub async fn takeoff(&mut self, altitude: f32) -> CoreResult<u8>
Commands a takeoff to an altitude.
§Arguments
altitude- the target altitude, in metres.
§Returns
The MAV_RESULT of the takeoff command.
§Errors
As send_command.
Sourcepub async fn request_message(&mut self, message_id: u32) -> CoreResult<u8>
pub async fn request_message(&mut self, message_id: u32) -> CoreResult<u8>
Asks the vehicle to emit one message, by id.
§Arguments
message_id- the id of the message to request.
§Returns
The MAV_RESULT of the request.
§Errors
As send_command.
Sourcepub async fn set_message_interval(
&mut self,
message_id: u32,
interval_us: i32,
) -> CoreResult<u8>
pub async fn set_message_interval( &mut self, message_id: u32, interval_us: i32, ) -> CoreResult<u8>
Sets how often the vehicle streams a message.
§Arguments
message_id- the id of the message.interval_us- the send interval, in microseconds, or-1to disable.
§Returns
The MAV_RESULT of the request.
§Errors
As send_command.
Sourcepub async fn upload_mission(
&mut self,
items: &[MissionItemInt],
) -> CoreResult<()>
pub async fn upload_mission( &mut self, items: &[MissionItemInt], ) -> CoreResult<()>
Uploads a mission plan to the vehicle.
Runs the mission protocol’s sender role: announces the count, answers each item request, and completes on the vehicle’s acknowledgement, retransmitting on timeout.
§Arguments
items- the mission items, in sequence order; the target ids, sequence numbers, and mission type are stamped on for you.
§Returns
Ok(()) once the vehicle accepts the plan.
§Errors
Returns Error::Transport if the transfer times out or
the vehicle rejects the plan.
Sourcepub async fn download_mission(&mut self) -> CoreResult<Vec<MissionItemInt>>
pub async fn download_mission(&mut self) -> CoreResult<Vec<MissionItemInt>>
Downloads the vehicle’s mission plan.
Runs the mission protocol’s receiver role: requests the count, requests each item in order, re-requests an out-of-order item, and acknowledges completion, retransmitting on timeout.
§Returns
The mission items, in sequence order.
§Errors
Returns Error::Transport if the transfer times out or
the link faults.