Skip to main content

WebSocket drone client for AeroSim

Project description

aerosim_drone

Simple WebSocket client for AeroSim Drone.

Installation

pip install aerosim_drone

Usage

from aerosim_drone import Drone

drone = Drone()
drone.connect()
drone.arm()

Drone Class Methods

Models

Drone Class Methods


๐Ÿ”น arm(self)

Arms the drone
:return: None

Example

from aerosim_drone import Drone

drone = Drone()
drone.arm()

๐Ÿ”น connect(self)

No description provided.

Example

from aerosim_drone import Drone

drone = Drone()
drone.connect()

๐Ÿ”น disconnect(self)

No description provided.

Example

from aerosim_drone import Drone

drone = Drone()
drone.disconnect()

๐Ÿ”น get_detections(self) -> aerosim_drone.messages.detections.Detections

Get last received detections

Detections
โ””โ”€โ”€ detections: List[GateDetection]
    โ”œโ”€โ”€ index: int
    โ”œโ”€โ”€ distance: float
    โ”œโ”€โ”€ gate: Gate
    โ”‚   โ”œโ”€โ”€ type: GateType
    โ”‚   โ”‚   โ”œโ”€โ”€ Square (0)
    โ”‚   โ”‚   โ”œโ”€โ”€ Cone (1)
    โ”‚   โ”‚   โ”œโ”€โ”€ EmptySquare (2)
    โ”‚   โ”‚   โ””โ”€โ”€ Arc (3)
    โ”‚   โ””โ”€โ”€ color: GateColor
    โ”‚       โ”œโ”€โ”€ Red (0)
    โ”‚       โ””โ”€โ”€ Green (1)
    โ””โ”€โ”€ position: Position
        โ”œโ”€โ”€ x: float
        โ”œโ”€โ”€ y: float
        โ””โ”€โ”€ z: float

Returns: Detections

Example

from aerosim_drone import Drone

drone = Drone()
drone.Connect()
drone.Arm()
detections = drone.get_detections()

๐Ÿ”น get_telemetry(self) -> aerosim_drone.messages.telemetry.Telemetry

Get last received telemetry

Telemetry
โ”œโ”€โ”€ frame_id: str
โ”œโ”€โ”€ connected: bool
โ”œโ”€โ”€ armed: bool
โ”œโ”€โ”€ mode: FlightMode
โ”‚   โ”œโ”€โ”€ StabilizedManual (0)
โ”‚   โ”œโ”€โ”€ Acro (1)
โ”‚   โ”œโ”€โ”€ Rattitude (2)
โ”‚   โ”œโ”€โ”€ Altctl (3)
โ”‚   โ”œโ”€โ”€ Posctl (4)
โ”‚   โ”œโ”€โ”€ Offboard (5)
โ”‚   โ”œโ”€โ”€ AutoMission (6)
โ”‚   โ”œโ”€โ”€ AutoRtl (7)
โ”‚   โ””โ”€โ”€ AutoLand (8)
โ”œโ”€โ”€ x: float
โ”œโ”€โ”€ y: float
โ”œโ”€โ”€ z: float
โ”œโ”€โ”€ lat: float
โ”œโ”€โ”€ lon: float
โ”œโ”€โ”€ alt: float
โ”œโ”€โ”€ vx: float
โ”œโ”€โ”€ vy: float
โ”œโ”€โ”€ vz: float
โ”œโ”€โ”€ roll: float
โ”œโ”€โ”€ pitch: float
โ”œโ”€โ”€ yaw: float
โ”œโ”€โ”€ roll_rate: float
โ”œโ”€โ”€ pitch_rate: float
โ”œโ”€โ”€ yaw_rate: float
โ”œโ”€โ”€ voltage: float
โ””โ”€โ”€ cell_voltage: float

Returns: Telemetry

Example

from aerosim_drone import Drone

drone = Drone()
drone.Connect()
drone.Arm()
telemetry = drone.get_telemetry()

๐Ÿ”น land(self)

Lands the drone
:return: None

Example

from aerosim_drone import Drone

drone = Drone()
drone.land()

๐Ÿ”น navigate(self, x: float, y: float, z: float, speed: float, frame_id: str = 'map', auto_arm: bool = False)

Fly to the designated point in a straight line.

:param x: Coordinate x
:param y: Coordinate y
:param z:Coordinate z
:param speed: Flight speed (setpoint speed) (m/s)
:param frame_id: Coordinate system for values x, y, z and yaw. Example: map, body, aruco_map. Default value: map.
:param auto_arm: Switch the drone to OFFBOARD and arm automatically (the drone will take off)
:return: None

Parameters

Name Type Default
x float ``
y float ``
z float ``
speed float ``
frame_id str map
auto_arm bool False

Example

from aerosim_drone import Drone

drone = Drone()
drone.navigate(x, y, z, speed, frame_id, auto_arm)

๐Ÿ”น navigate_global(self, lat: float, lon: float, z: float, yaw: float, speed: float, frame_id: str = 'map', auto_arm: bool = False)

Flying in a straight line to a point in the global coordinate system (latitude/longitude).

:param lat: Latitude
:param lon: Longitude
:param z: Altitude (m)
:param yaw: Yaw angle (radians)
:param speed: Flight speed (setpoint speed) (m/s)
:param frame_id: Coordinate system for values x, y, z and yaw. Example: map, body, aruco_map. Default value: map.
:param auto_arm: Switch the drone to OFFBOARD and arm automatically (the drone will take off)
:return: None

Parameters

Name Type Default
lat float ``
lon float ``
z float ``
yaw float ``
speed float ``
frame_id str map
auto_arm bool False

Example

from aerosim_drone import Drone

drone = Drone()
drone.navigate_global(lat, lon, z, yaw, speed, frame_id, auto_arm)

๐Ÿ”น set_altitude(self, z: float, frame_id: str = 'map')

Change the desired flight altitude. The service is used to set the altitude and its coordinate system independently, after calling navigate or set_position.

:param z: Altitude
:param frame_id: Coordinate system for values x, y, z and yaw. Example: map, body, aruco_map. Default value: map.
:return: None

Parameters

Name Type Default
z float ``
frame_id str map

Example

from aerosim_drone import Drone

drone = Drone()
drone.set_altitude(z, frame_id)

๐Ÿ”น set_attitude(self, roll: float, pitch: float, yaw: float, thrust: float, frame_id: str = 'map', auto_arm: bool = False)

Set roll, pitch, yaw and throttle level (similar to the STABILIZED mode). This service may be used for lower level control of the drone behavior, or controlling the drone when no reliable data on its position is available.

:param roll: Requested roll (radians)
:param pitch: Requested pitch (radians)
:param yaw: Requested yaw (radians)
:param thrust: Throttle level, ranges from 0 (no throttle, propellers are stopped) to 1 (full throttle).
:param frame_id: Coordinate system for values x, y, z and yaw. Example: map, body, aruco_map. Default value: map.
:param auto_arm: switch the drone to OFFBOARD and arm automatically (the drone will take off)
:return: None

Parameters

Name Type Default
roll float ``
pitch float ``
yaw float ``
thrust float ``
frame_id str map
auto_arm bool False

Example

from aerosim_drone import Drone

drone = Drone()
drone.set_attitude(roll, pitch, yaw, thrust, frame_id, auto_arm)

๐Ÿ”น set_position(self, x: float, y: float, z: float, yaw: float, frame_id: str = 'map', auto_arm: bool = False)

Set the setpoint for position and yaw. This service may be used to specify the continuous flow of target points, for example, for flying along complex trajectories (circular, arcuate, etc.).

:param x: Point coordinate x
:param y: Point coordinate y
:param z: Point coordinate z
:param yaw: Yaw angle (radians)
:param frame_id: Coordinate system for values x, y, z and yaw. Example: map, body, aruco_map. Default value: map.
:param auto_arm: switch the drone to OFFBOARD and arm automatically (the drone will take off)
:return: None

Parameters

Name Type Default
x float ``
y float ``
z float ``
yaw float ``
frame_id str map
auto_arm bool False

Example

from aerosim_drone import Drone

drone = Drone()
drone.set_position(x, y, z, yaw, frame_id, auto_arm)

๐Ÿ”น set_rates(self, roll_rate: float, pitch_rate: float, yaw_rate: float, thrust: float, auto_arm: bool = False)

Set roll, pitch, yaw and throttle level (similar to the STABILIZED mode). This service may be used for lower level control of the drone behavior, or controlling the drone when no reliable data on its position is available.

:param roll_rate: Roll rate (rad/s)
:param pitch_rate: Pitch rate (rad/s)
:param yaw_rate: Yaw rate (rad/s)
:param thrust: Throttle level, ranges from 0 (no throttle, propellers are stopped) to 1 (full throttle).
:param auto_arm: Switch the drone to OFFBOARD and arm automatically (the drone will take off)
:return: None

Parameters

Name Type Default
roll_rate float ``
pitch_rate float ``
yaw_rate float ``
thrust float ``
auto_arm bool False

Example

from aerosim_drone import Drone

drone = Drone()
drone.set_rates(roll_rate, pitch_rate, yaw_rate, thrust, auto_arm)

๐Ÿ”น set_velocity(self, vx: float, vy: float, vz: float, yaw: float, frame_id: str = 'map', auto_arm: bool = False)

Set the setpoint for position and yaw. This service may be used to specify the continuous flow of target points, for example, for flying along complex trajectories (circular, arcuate, etc.).

:param vx: Flight speed (m/s) x
:param vy: Flight speed (m/s) y
:param vz: Flight speed (m/s) z
:param yaw: Yaw angle (radians)
:param frame_id: Coordinate system for values x, y, z and yaw. Example: map, body, aruco_map. Default value: map.
:param auto_arm: Switch the drone to OFFBOARD and arm automatically (the drone will take off)
:return: None

Parameters

Name Type Default
vx float ``
vy float ``
vz float ``
yaw float ``
frame_id str map
auto_arm bool False

Example

from aerosim_drone import Drone

drone = Drone()
drone.set_velocity(vx, vy, vz, yaw, frame_id, auto_arm)

๐Ÿ”น set_yaw(self, yaw: float, frame_id: str = 'map')

Change the desired yaw angle (and its coordinate system), keeping the previous command in effect.

:param yaw: Yaw angle (radians)
:param frame_id: Coordinate system for computing the yaw. Default value: map.
:return: None

Parameters

Name Type Default
yaw float ``
frame_id str map

Example

from aerosim_drone import Drone

drone = Drone()
drone.set_yaw(yaw, frame_id)

๐Ÿ”น set_yaw_rate(self, yaw_rate: float, frame_id: str = 'map')

The the desired angular yaw velocity, keeping the previous command in effect.

:param yaw_rate: Angular yaw velocity (rad/s);
:return: None

Parameters

Name Type Default
yaw_rate float ``
frame_id str map

Example

from aerosim_drone import Drone

drone = Drone()
drone.set_yaw_rate(yaw_rate, frame_id)

๐Ÿ”น take_off(self, y: float)

Take off drone
:param y: Coordinate y
:return: None

Parameters

Name Type Default
y float ``

Example

from aerosim_drone import Drone

drone = Drone()
drone.take_off(y)

Models


๐Ÿ”น Telemetry

Telemetry
โ”œโ”€โ”€ frame_id: str
โ”œโ”€โ”€ connected: bool
โ”œโ”€โ”€ armed: bool
โ”œโ”€โ”€ mode: FlightMode
โ”‚   โ”œโ”€โ”€ StabilizedManual (0)
โ”‚   โ”œโ”€โ”€ Acro (1)
โ”‚   โ”œโ”€โ”€ Rattitude (2)
โ”‚   โ”œโ”€โ”€ Altctl (3)
โ”‚   โ”œโ”€โ”€ Posctl (4)
โ”‚   โ”œโ”€โ”€ Offboard (5)
โ”‚   โ”œโ”€โ”€ AutoMission (6)
โ”‚   โ”œโ”€โ”€ AutoRtl (7)
โ”‚   โ””โ”€โ”€ AutoLand (8)
โ”œโ”€โ”€ x: float
โ”œโ”€โ”€ y: float
โ”œโ”€โ”€ z: float
โ”œโ”€โ”€ lat: float
โ”œโ”€โ”€ lon: float
โ”œโ”€โ”€ alt: float
โ”œโ”€โ”€ vx: float
โ”œโ”€โ”€ vy: float
โ”œโ”€โ”€ vz: float
โ”œโ”€โ”€ roll: float
โ”œโ”€โ”€ pitch: float
โ”œโ”€โ”€ yaw: float
โ”œโ”€โ”€ roll_rate: float
โ”œโ”€โ”€ pitch_rate: float
โ”œโ”€โ”€ yaw_rate: float
โ”œโ”€โ”€ voltage: float
โ””โ”€โ”€ cell_voltage: float

The Telemetry class is a data model designed to store and manage drone state information within the aerosim_drone library.

Data Attributes

System Info

  • frame_id (str): Coordinate frame reference identifier.
  • connected (bool): True if linked to the flight controller.
  • armed (bool): True if motors are active/armed.
  • mode (FlightMode): The current flight mode enum member.

Spatial Position & Velocity

  • x, y, z (float): Local coordinates (m).
  • lat, lon (float): Global WGS84 coordinates (deg).
  • alt (float): Altitude (m).
  • vx, vy, vz (float): Linear velocity (m/s).

Orientation & Dynamics

  • roll, pitch, yaw (float): Orientation in Radians.
  • roll_rate, pitch_rate, yaw_rate (float): Angular velocity in Rad/s.

Power Systems

  • voltage (float): Main battery voltage (V).
  • cell_voltage (float): Average per-cell voltage (V).

FlightMode (Enum)

Defines the operational modes of the flight controller:

Value Name Description
0 StabilizedManual Manual control with self-leveling.
1 Acro Rate control (no auto-level).
2 Rattitude Combined rate/attitude control.
3 Altctl Altitude hold mode.
4 Posctl Position hold mode (GPS dependent).
5 Offboard External API/Companion computer control.
6 AutoMission Automatic waypoint navigation.
7 AutoRtl Return to Launch.
8 AutoLand Automated landing.

๐Ÿ”น Detections

Detections
โ””โ”€โ”€ detections: List[GateDetection]
    โ”œโ”€โ”€ index: int
    โ”œโ”€โ”€ distance: float
    โ”œโ”€โ”€ gate: Gate
    โ”‚   โ”œโ”€โ”€ type: GateType
    โ”‚   โ”‚   โ”œโ”€โ”€ Square (0)
    โ”‚   โ”‚   โ”œโ”€โ”€ Cone (1)
    โ”‚   โ”‚   โ”œโ”€โ”€ EmptySquare (2)
    โ”‚   โ”‚   โ””โ”€โ”€ Arc (3)
    โ”‚   โ””โ”€โ”€ color: GateColor
    โ”‚       โ”œโ”€โ”€ Red (0)
    โ”‚       โ””โ”€โ”€ Green (1)
    โ””โ”€โ”€ position: Position
        โ”œโ”€โ”€ x: float
        โ”œโ”€โ”€ y: float
        โ””โ”€โ”€ z: float

This module defines the data structures for gate detection within the aerosim_drone simulation environment. It handles spatial data, gate classification, and collection of active detections.

Enumerations

GateType

Defines the physical shape of the detected gate.

  • Square (0): Standard square racing gate.
  • Cone (1): Obstacle or marker cone.
  • EmptySquare (2): Hollow square frame.
  • Arc (3): Curved/Arc-shaped gate.

GateColor

Defines the visual color of the gate.

  • Red (0): Red colored gate.
  • Green (1): Green colored gate.

Supporting Classes

Position

Represents a 3D coordinate in the world frame.

  • Attributes: x, y, z (float, meters).
  • Factory: from_dict(data: dict)

Gate

Describes the static physical properties of a gate.

  • Attributes: type (GateType), color (GateColor).
  • Factory: from_dict(data: dict)

GateDetection

Represents a specific detection instance in the current frame.

  • Attributes:
    • gate (Gate): The physical description.
    • distance (float): Distance from the drone to the gate (m).
    • position (Position): 3D center coordinates.
    • index (int): Gate index relative to the track order.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aerosim_drone-0.1.7.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aerosim_drone-0.1.7-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file aerosim_drone-0.1.7.tar.gz.

File metadata

  • Download URL: aerosim_drone-0.1.7.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for aerosim_drone-0.1.7.tar.gz
Algorithm Hash digest
SHA256 e41710016148d2946e9698ecc6665ac43937330eda881ade51e8f7beb6570820
MD5 d2b982b28cd553b0198feaee70efb6f6
BLAKE2b-256 2d1674ea6e3093b23f65a51b90fcbf05edc38f970d7361523fab99140da206b1

See more details on using hashes here.

File details

Details for the file aerosim_drone-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: aerosim_drone-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for aerosim_drone-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 20c0693e936b616fa81a0561d371c78a62ca90d3b153d6a15df541f28b522103
MD5 a8472fc4afb6483e0f4e9ab9d1464c95
BLAKE2b-256 1b2034eba49223419ce0d937ddb843f537d234cf3bf2af63a9fb056cbd3d1d9f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page