Struct MultiRotorClient

Source
pub struct MultiRotorClient { /* private fields */ }

Implementations§

Source§

impl MultiRotorClient

Source

pub async fn connect( addrs: &str, vehicle_name: &'static str, ) -> NetworkResult<Self>

Source

pub async fn reset(&self) -> NetworkResult<bool>

Reset the vehicle to its original starting state

Note that you must call enable_api_control and arm_disarm again after the call to reset

Source

pub async fn ping(&self) -> NetworkResult<bool>

If connection is established then this call will return True otherwise the request will be blocked until timeout (default value)

Source

pub async fn confirm_connection(&self) -> NetworkResult<bool>

Source

pub async fn enable_api_control(&self, is_enabled: bool) -> NetworkResult<bool>

Enables or disables API control for vehicle corresponding to vehicle_name

args: is_enabled (bool): True to enable, False to disable API control vehicle_name (Option): Name of the vehicle to send this command to

Source

pub async fn is_api_control_enabled( &self, is_enabled: bool, ) -> NetworkResult<bool>

Returns true if API control is established.

If false (which is default) then API calls would be ignored. After a successful call to enableApiControl, isApiControlEnabled should return true.

args: vehicle_name (Option): Name of the vehicle to send this command to

Source

pub async fn arm_disarm(&self, arm: bool) -> NetworkResult<bool>

Returns true if API control is established.

If false (which is default) then API calls would be ignored. After a successful call to enableApiControl, isApiControlEnabled should return true.

args: arm (bool): True to arm, False to disarm the vehicle vehicle_name (Option): Name of the vehicle to send this command to

Source

pub async fn hover_async(&self) -> NetworkResult<bool>

High level control API

Hover the vehicle in place

Source

pub async fn get_home_geo_point(&self) -> Result<GeoPoint, NetworkError>

Get the Home location of the vehicle

Source

pub async fn take_off_async(&self, timeout_sec: f32) -> NetworkResult<bool>

High level control API

Takeoff vehicle to 3m above ground. Vehicle should not be moving when this API is used

Args: timeout_sec (Option): Timeout for the vehicle to reach desired altitude

Source

pub async fn land_async(&self, timeout_sec: f32) -> NetworkResult<bool>

High level control API

Safely land the vehicle in a vertical only movement. This function should close to the ground

Args: timeout_sec (Option): Timeout for the vehicle to land

Source

pub async fn go_home_async(&self, timeout_sec: f32) -> NetworkResult<bool>

High level control API

Return vehicle to Home i.e. Launch location The vehicle should be in the viscinity of home when this function is called

Args: timeout_sec (Option): Timeout for the vehicle to reach desired altitude

Source

pub async fn move_by_velocity_body_frame_async( &self, velocity: Velocity3, duration: f32, drivetrain: DrivetrainType, yaw_mode: YawMode, ) -> NetworkResult<bool>

High level control API

Set 3D velocity vector in vehicle’s local NED frame

Args: velocity (Velocity3): desired velocity in the X,Y,Z axis’s of the vehicle’s local NED frame. duration (f32): Desired amount of time (seconds), to send this command for drivetrain (DrivetrainType): when ForwardOnly, vehicle rotates itself so that its front is always facing the direction of travel. If MaxDegreeOfFreedom then it doesn’t do that (crab-like movement) yaw_mode (YawMode, Degree): Specifies if vehicle should face at given angle (is_rate=False) or should be rotating around its axis at given rate (is_rate=True)

Source

pub async fn move_by_velocity_z_body_frame_async( &self, velocity: Velocity2, z: f32, duration: f32, drivetrain: DrivetrainType, yaw_mode: YawMode, ) -> NetworkResult<bool>

High level control API

Set 2D velocity vector in vehicle’s local NED frame, with desired Z altitude.

Args: velocity (Velocity2): desired velocity in the X,Y axis’s of the vehicle’s local NED frame. z (f32): desired Z value (in local NED frame of the vehicle) duration (f32): desired amount of time (seconds), to send this command for drivetrain (DrivetrainType): when ForwardOnly, vehicle rotates itself so that its front is always facing the direction of travel. If MaxDegreeOfFreedom then it doesn’t do that (crab-like movement) yaw_mode (YawMode, Degree): specifies if vehicle should face at given angle (is_rate=False) or should be rotating around its axis at given rate (is_rate=True)

Source

pub async fn set_velocity_controller_gains( &self, velocity_gains: LinearControllerGains, ) -> NetworkResult<bool>

Set PID gains for the velocity controller, move_by_velocity_async().

  • Sets velocity controller gains for moveByVelocityAsync().
  • This function should only be called if the default velocity control PID gains need to be modified.
  • Passing VelocityControllerGains() sets gains to default airsim values.

args: velocity_gains (LinearControllerGains): - Correspond to the world X, Y, Z axes. - Pass LinearControllerGains() to reset gains to default recommended values. - Modifying velocity controller gains will have an affect on the behaviour of move_on_spline_async() and move_on_spline_vel_constraints_async(), as they both use velocity control to track the trajectory.

Source

pub async fn move_by_velocity_async( &self, velocity: Velocity3, duration: f32, drivetrain: DrivetrainType, yaw_mode: YawMode, ) -> NetworkResult<bool>

High level control API

Set 3D velocity vector in vehicle’s local NED frame

Args: velocity (Velocity3): desired velocity X,Y,Z in world (NED) axis duration (f32): desired amount of time (seconds), to send this command for drivetrain (DrivetrainType): when ForwardOnly, vehicle rotates itself so that its front is always facing the direction of travel. If MaxDegreeOfFreedom then it doesn’t do that (crab-like movement) yaw_mode (YawMode, Degree): specifies if vehicle should face at given angle (is_rate=False) or should be rotating around its axis at given rate (is_rate=True)

Source

pub async fn move_by_velocity_z_async( &self, velocity: Velocity2, z: f32, duration: f32, drivetrain: DrivetrainType, yaw_mode: YawMode, ) -> NetworkResult<bool>

High level control API

Set 2D velocity vector in vehicle’s local NED frame, with desired Z attitude.

Args: velocity (Velocity2): desired velocity in the X,Y axis’s of the vehicle’s local NED frame. z (f32): desired Z value (in local NED frame of the vehicle) duration (f32): desired amount of time (seconds), to send this command for drivetrain (DrivetrainType): when ForwardOnly, vehicle rotates itself so that its front is always facing the direction of travel. If MaxDegreeOfFreedom then it doesn’t do that (crab-like movement) yaw_mode (YawMode, Degree): specifies if vehicle should face at given angle (is_rate=False) or should be rotating around its axis at given rate (is_rate=True)

Source

pub async fn set_position_controller_gains( &self, position_gains: LinearControllerGains, ) -> NetworkResult<bool>

Set PID gains for the position controller, move_to_position_async()

This function should only be called if the default position control PID gains need to be modified.

args: position_gains (LinearControllerGains): - Correspond to the X, Y, Z axes. - Pass PositionControllerGains() to reset gains to default recommended values.

Source

pub async fn move_to_position_async( &self, position: Position3, velocity: f32, timeout_sec: f32, drivetrain: DrivetrainType, yaw_mode: YawMode, lookahead: Option<f32>, adaptive_lookahead: Option<f32>, ) -> NetworkResult<bool>

High level control API

Send desired goal position to default PID vehicle controller

Args: position (Position3): goal position of the vehicle controller velocity (f32): desired velocity in NED frame of the vehicle timeout_sec (32): Timeout for the vehicle to reach desired goal position drivetrain (DrivetrainType): when ForwardOnly, vehicle rotates itself so that its front is always facing the direction of travel. If MaxDegreeOfFreedom then it doesn’t do that (crab-like movement) yaw_mode (YawMode, Degree): Specifies if vehicle should face at given angle (is_rate=False) or should be rotating around its axis at given rate (is_rate=True) lookahead (Option): defaults to -1 adaptive_lookahead (Option): defaults to 0

Source

pub async fn move_on_path_async( &self, path: Path, velocity: f32, timeout_sec: f32, drivetrain: DrivetrainType, yaw_mode: YawMode, lookahead: Option<f32>, adaptive_lookahead: Option<f32>, ) -> NetworkResult<bool>

High level control API

Send desired goal position to default PID vehicle controller

Args: position (Position3): goal position of the vehicle controller velocity (f32): desired velocity in NED frame of the vehicle timeout_sec (32): Timeout for the vehicle to reach desired goal position drivetrain (DrivetrainType): when ForwardOnly, vehicle rotates itself so that its front is always facing the direction of travel. If MaxDegreeOfFreedom then it doesn’t do that (crab-like movement) yaw_mode (YawMode, Degree): Specifies if vehicle should face at given angle (is_rate=False) or should be rotating around its axis at given rate (is_rate=True) lookahead (Option): defaults to -1 adaptive_lookahead (Option): defaults to 0

Source

pub async fn move_to_gps_async( &self, geopoint: GeoPoint, velocity: f32, timeout_sec: f32, drivetrain: DrivetrainType, yaw_mode: YawMode, lookahead: Option<f32>, adaptive_lookahead: Option<f32>, ) -> NetworkResult<bool>

High level control API

Send desired goal position to default PID vehicle controller

Args: position (Position3): goal position of the vehicle controller velocity (f32): desired velocity in NED frame of the vehicle timeout_sec (32): Timeout for the vehicle to reach desired goal position drivetrain (DrivetrainType): when ForwardOnly, vehicle rotates itself so that its front is always facing the direction of travel. If MaxDegreeOfFreedom then it doesn’t do that (crab-like movement) yaw_mode (YawMode, Degree): Specifies if vehicle should face at given angle (is_rate=False) or should be rotating around its axis at given rate (is_rate=True) lookahead (Option): defaults to -1 adaptive_lookahead (Option): defaults to 0

Source

pub async fn move_to_z_async( &self, z: f32, velocity: f32, timeout_sec: f32, yaw_mode: YawMode, lookahead: Option<f32>, adaptive_lookahead: Option<f32>, ) -> NetworkResult<bool>

High level control API

Move to a desired altitude Z (in local NED frame of the vehicle) with a desired velocity

Args: z (f32): desired Z value (in local NED frame of the vehicle) velocity (f32): desired velocity in NED frame of the vehicle timeout_sec (32): Timeout for the vehicle to reach desired goal altitude Z yaw_mode (YawMode, Degree): Specifies if vehicle should face at given angle (is_rate=False) or should be rotating around its axis at given rate (is_rate=True) lookahead (Option): defaults to -1 adaptive_lookahead (Option): defaults to 0

Source

pub async fn move_by_manual_async( &self, v_max: Velocity3, z_min: f32, duration: f32, drivetrain: DrivetrainType, yaw_mode: YawMode, ) -> NetworkResult<bool>

Low level control API

Set the vehicle in a manual mode state. Parameters sets up the constraints on velocity and minimum altitude while flying. If RC state is detected to violate these constraintsthen that RC state would be ignored.

Call this method followed by move_by_rc method to remote control the vehicle

Args: v_max (Velocity3): max velocity allowed in X, Y, Z direction z_min (f32): min Z (altitude) allowed for vehicle position duration (f32): after this duration vehicle would switch back to non-manual mode drivetrain (DrivetrainType): when ForwardOnly, vehicle rotates itself so that its front is always facing the direction of travel. If MaxDegreeOfFreedom then it doesn’t do that (crab-like movement) yaw_mode (YawMode, Degree): specifies if vehicle should face at given angle (is_rate=False) or should be rotating around its axis at given rate (is_rate=True)

Source

pub async fn move_by_rc(&self, rc_data: RCData) -> NetworkResult<()>

Low level control API

Remote control the robot in joystick mode

args: rc_data (RCData): remote control commands

Source

pub async fn move_by_motor_pwms_async( &self, pwm: PWM, duration: f32, ) -> NetworkResult<bool>

Low level control API

Directly control the motors using PWM values convert thrust to pwm: https://github.com/microsoft/AirSim/issues/2592

args: pwm (PWM): pwm signals for each indivual rotor (4 rotors in total) duration (f32): desired amount of time (seconds), to send this command for

Source

pub async fn set_angle_rate_controller_gains( &self, angle_rate_gains: AngularControllerGains, ) -> NetworkResult<bool>

Set PID gains for the angle rate controller

  • Modifying these gains will have an affect on ALL move*() APIs. This is because any velocity setpoint is converted to an angle level setpoint which is tracked with an angle level controllers. That angle level setpoint is itself tracked with and angle rate controller.
  • This function should only be called if the default angle rate control PID gains need to be modified.

args: angle_rate_gains (AngularControllerGains): - Correspond to the roll, pitch, yaw axes, defined in the body frame. - Pass AngularControllerGains() to reset gains to default recommended values.

Source

pub async fn set_angle_level_controller_gains( &self, angle_level_gains: AngularControllerGains, ) -> NetworkResult<bool>

Set PID gains for the angle level controller

  • Sets angle level controller gains (used by any API setting angle references - for ex: move_by_roll_pitch_yaw_z_async(), move_by_roll_pitch_yaw_throttle_async(), etc)
  • Modifying these gains will also affect the behaviour of move_by_velocity_async() API. This is because the AirSim flight controller will track velocity setpoints by converting them to angle set points.
  • This function should only be called if the default angle level control PID gains need to be modified.
  • Passing AngularControllerGains() sets gains to default airsim values.

args: angle_level_gains (AngularControllerGains): - Correspond to the roll, pitch, yaw axes, defined in the body frame. - Pass AngleLevelControllerGains() to reset gains to default recommended values.

Source

pub async fn move_by_roll_pitch_yaw_z_async( &self, rotation: Orientation3, z: f32, duration: f32, ) -> NetworkResult<bool>

Low level control API

Set an desired (absolute, not relative) attitude and altitude

args: rotation (Orientation3): Roll angle, pitch angle, and yaw angle set points are given in radians, in the ENU body frame. z (f32): altitude z is given in local NED frame of the vehicle. duration (f32): Desired amount of time (seconds), to send this command for

Source

pub async fn move_by_roll_pitch_yaw_throttle_async( &self, rotation: Orientation3, throttle_z: f32, duration: f32, ) -> NetworkResult<bool>

Low level control API

Set an desired (absolute, not relative) attitude and throttle in z-direction

args: rotation (Orientation3): Roll angle, pitch angle, and yaw angle set points are given in radians, in the ENU body frame. throttle_z (f32): Desired throttle (between 0.0 to 1.0) in Z duration (f32): Desired amount of time (seconds), to send this command for

Source

pub async fn move_by_roll_pitch_yawrate_throttle_async( &self, rotation: Orientation2, yaw_rate: f32, throttle_z: f32, duration: f32, ) -> NetworkResult<bool>

Low level control API

Set an desired (absolute, not relative) attitude, yaw rate and throttle in z-direction

args: rotation (Orientation2): Desired roll and pitch angle set points are given in radians, in the ENU body frame. yaw_rate (f32): Desired yaw rate, in radian per second. throttle_z (f32): Desired throttle (between 0.0 to 1.0) in Z duration (f32): Desired amount of time (seconds), to send this command for

Source

pub async fn move_by_roll_pitch_yawrate_z_async( &self, rotation: Orientation2, yaw_rate: f32, z: f32, duration: f32, ) -> NetworkResult<bool>

Low level control API

Set an desired (absolute, not relative) attitude, yaw rate and altitude Z (absolute, not relative)

args: rotation (Orientation2): Desired roll and pitch angle set points are given in radians, in the ENU body frame. yaw_rate (f32): Desired yaw rate, in radian per second. z (f32): altitude z is given in local NED frame of the vehicle. duration (f32): Desired amount of time (seconds), to send this command for

Source

pub async fn move_by_angle_rates_z_async( &self, rotation_rates: Orientation3, z: f32, duration: f32, ) -> NetworkResult<bool>

Low level control API

Set an desired (absolute, not relative) attitude, yaw rate and altitude Z (absolute, not relative)

args: rotation_rates (Orientation2): Roll rate, pitch rate, and yaw rate set points are given in radians, in the body frame. yaw_rate (f32): Desired yaw rate, in radian per second. z (f32): altitude z is given in local NED frame of the vehicle. duration (f32): Desired amount of time (seconds), to send this command for

Source

pub async fn move_by_angle_rates_throttle_async( &self, rotation_rates: Orientation3, throttle: f32, duration: f32, ) -> NetworkResult<bool>

Low level control API

Set an desired (absolute, not relative) attitude, yaw rate and altitude Z (absolute, not relative)

args: rotation_rates (Orientation2): Roll rate, pitch rate, and yaw rate set points are given in radians, in the body frame. yaw_rate (f32): Desired yaw rate, in radian per second. throttle (f32): Desired throttle (between 0.0 to 1.0) duration (f32): Desired amount of time (seconds), to send this command for

Source

pub async fn get_multirotor_state(&self) -> NetworkResult<MultiRotorState>

Get the kinematic state of the multirotor vehicle

Source

pub async fn get_rotor_states(&self) -> NetworkResult<RotorStates>

Used to obtain the current state of all a multirotor’s rotors. The state includes the speeds, thrusts and torques for all rotors.

Source

pub async fn sim_get_image( &self, camera_name: &str, image_type: ImageType, external: Option<bool>, ) -> Result<CompressedImage, NetworkError>

Camera API

Returns binary string literal of compressed png image in presented as an vector of bytes

Returns bytes of png format image which can be dumped into abinary file to create .png image See https://microsoft.github.io/AirSim/image_apis/ for details

args: vehicle_name (Option<&str>): Name of the vehicle to send this command to camera_name (String): Name of the camera, for backwards compatibility, ID numbers such as 0,1,etc. can also be used image_type (ImageType): Type of image required external (Option): Whether the camera is an External Camera

Source

pub async fn sim_get_images( &self, _requests: ImageRequests, _external: Option<bool>, ) -> Result<(), NetworkError>

Camera API

Get multiple images See https://microsoft.github.io/AirSim/image_apis/ for details and examples

Args: requests (ImageRequests): Images required vehicle_name (Option<&str>): Name of vehicle associated with the camera external (Option): Whether the camera is an External Camera

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more