pub struct MultiRotorClient { /* private fields */ }
Implementations§
Source§impl MultiRotorClient
impl MultiRotorClient
pub async fn connect( addrs: &str, vehicle_name: &'static str, ) -> NetworkResult<Self>
Sourcepub async fn reset(&self) -> NetworkResult<bool>
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
Sourcepub async fn ping(&self) -> NetworkResult<bool>
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)
pub async fn confirm_connection(&self) -> NetworkResult<bool>
Sourcepub async fn enable_api_control(&self, is_enabled: bool) -> NetworkResult<bool>
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
Sourcepub async fn is_api_control_enabled(
&self,
is_enabled: bool,
) -> NetworkResult<bool>
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
Sourcepub async fn arm_disarm(&self, arm: bool) -> NetworkResult<bool>
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
Sourcepub async fn hover_async(&self) -> NetworkResult<bool>
pub async fn hover_async(&self) -> NetworkResult<bool>
High level control API
Hover the vehicle in place
Sourcepub async fn get_home_geo_point(&self) -> Result<GeoPoint, NetworkError>
pub async fn get_home_geo_point(&self) -> Result<GeoPoint, NetworkError>
Get the Home location of the vehicle
Sourcepub async fn take_off_async(&self, timeout_sec: f32) -> NetworkResult<bool>
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
Sourcepub async fn land_async(&self, timeout_sec: f32) -> NetworkResult<bool>
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
Sourcepub async fn go_home_async(&self, timeout_sec: f32) -> NetworkResult<bool>
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
Sourcepub async fn move_by_velocity_body_frame_async(
&self,
velocity: Velocity3,
duration: f32,
drivetrain: DrivetrainType,
yaw_mode: YawMode,
) -> NetworkResult<bool>
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)
Sourcepub async fn move_by_velocity_z_body_frame_async(
&self,
velocity: Velocity2,
z: f32,
duration: f32,
drivetrain: DrivetrainType,
yaw_mode: YawMode,
) -> NetworkResult<bool>
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)
Sourcepub async fn set_velocity_controller_gains(
&self,
velocity_gains: LinearControllerGains,
) -> NetworkResult<bool>
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.
Sourcepub async fn move_by_velocity_async(
&self,
velocity: Velocity3,
duration: f32,
drivetrain: DrivetrainType,
yaw_mode: YawMode,
) -> NetworkResult<bool>
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)
Sourcepub async fn move_by_velocity_z_async(
&self,
velocity: Velocity2,
z: f32,
duration: f32,
drivetrain: DrivetrainType,
yaw_mode: YawMode,
) -> NetworkResult<bool>
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)
Sourcepub async fn set_position_controller_gains(
&self,
position_gains: LinearControllerGains,
) -> NetworkResult<bool>
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.
Sourcepub 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>
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-1
adaptive_lookahead (Option0
Sourcepub 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>
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-1
adaptive_lookahead (Option0
Sourcepub 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>
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-1
adaptive_lookahead (Option0
Sourcepub 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>
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-1
adaptive_lookahead (Option0
Sourcepub async fn move_by_manual_async(
&self,
v_max: Velocity3,
z_min: f32,
duration: f32,
drivetrain: DrivetrainType,
yaw_mode: YawMode,
) -> NetworkResult<bool>
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)
Sourcepub async fn move_by_rc(&self, rc_data: RCData) -> NetworkResult<()>
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
Sourcepub async fn move_by_motor_pwms_async(
&self,
pwm: PWM,
duration: f32,
) -> NetworkResult<bool>
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
Sourcepub async fn set_angle_rate_controller_gains(
&self,
angle_rate_gains: AngularControllerGains,
) -> NetworkResult<bool>
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.
Sourcepub async fn set_angle_level_controller_gains(
&self,
angle_level_gains: AngularControllerGains,
) -> NetworkResult<bool>
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.
Sourcepub async fn move_by_roll_pitch_yaw_z_async(
&self,
rotation: Orientation3,
z: f32,
duration: f32,
) -> NetworkResult<bool>
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
Sourcepub async fn move_by_roll_pitch_yaw_throttle_async(
&self,
rotation: Orientation3,
throttle_z: f32,
duration: f32,
) -> NetworkResult<bool>
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
Sourcepub async fn move_by_roll_pitch_yawrate_throttle_async(
&self,
rotation: Orientation2,
yaw_rate: f32,
throttle_z: f32,
duration: f32,
) -> NetworkResult<bool>
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
Sourcepub async fn move_by_roll_pitch_yawrate_z_async(
&self,
rotation: Orientation2,
yaw_rate: f32,
z: f32,
duration: f32,
) -> NetworkResult<bool>
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
Sourcepub async fn move_by_angle_rates_z_async(
&self,
rotation_rates: Orientation3,
z: f32,
duration: f32,
) -> NetworkResult<bool>
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
Sourcepub async fn move_by_angle_rates_throttle_async(
&self,
rotation_rates: Orientation3,
throttle: f32,
duration: f32,
) -> NetworkResult<bool>
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
Sourcepub async fn get_multirotor_state(&self) -> NetworkResult<MultiRotorState>
pub async fn get_multirotor_state(&self) -> NetworkResult<MultiRotorState>
Get the kinematic state of the multirotor vehicle
Sourcepub async fn get_rotor_states(&self) -> NetworkResult<RotorStates>
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.
Sourcepub async fn sim_get_image(
&self,
camera_name: &str,
image_type: ImageType,
external: Option<bool>,
) -> Result<CompressedImage, NetworkError>
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
Sourcepub async fn sim_get_images(
&self,
_requests: ImageRequests,
_external: Option<bool>,
) -> Result<(), NetworkError>
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