Control API¶
control
¶
Nectar SDK - Control module.
MAVLINK_SITL_CONFIG
module-attribute
¶
MAVLINK_SITL_CONFIG = MavlinkConfig(name='sitl_drone', pose_source=PoseSource.GPS, connection_string='tcp:127.0.0.1:5760', expect_lidar=False)
MavlinkConfig preset for ArduPilot SITL over a direct pymavlink TCP link.
MAVLINK_SITL_GAZEBO_CONFIG
module-attribute
¶
MAVLINK_SITL_GAZEBO_CONFIG = MavlinkConfig(name='sitl_drone', pose_source=PoseSource.GPS, connection_string='tcp:127.0.0.1:5762', expect_lidar=False)
MavlinkConfig preset for SITL + Gazebo over the SITL secondary MAVLink port.
MAVLINK_SITL_VISION_CONFIG
module-attribute
¶
MAVLINK_SITL_VISION_CONFIG = MavlinkConfig(name='sitl_drone', pose_source=PoseSource.VISION, connection_string='tcp:127.0.0.1:5762', expect_lidar=False, vision_pose_topic='/visual_slam/tracking/vo_pose_covariance')
MavlinkConfig preset for SITL + Gazebo indoor (vision pose).
PX4_DDS_SITL_CONFIG
module-attribute
¶
PX4_DDS_SITL_CONFIG = Px4DdsConfig(name='px4_dds_sitl_drone', pose_source=PoseSource.GPS, pid_config_file=os.path.join(_PX4_CONFIG_DIR, 'position_sim_outdoor.yaml'))
Px4DdsConfig preset for PX4 SITL over native uXRCE-DDS (MicroXRCEAgent on 8888).
PX4_MAVLINK_SITL_CONFIG
module-attribute
¶
PX4_MAVLINK_SITL_CONFIG = Px4MavlinkConfig(name='px4_mavlink_sitl_drone', pose_source=PoseSource.GPS, expect_lidar=False)
Px4MavlinkConfig preset for PX4 SITL over direct pymavlink (headless, GPS, no lidar).
PX4_MAVLINK_SITL_GAZEBO_CONFIG
module-attribute
¶
PX4_MAVLINK_SITL_GAZEBO_CONFIG = Px4MavlinkConfig(name='px4_mavlink_sitl_drone', pose_source=PoseSource.GPS, expect_lidar=True, pid_config_file=os.path.join(_PX4_CONFIG_DIR, 'position_sim_outdoor.yaml'), setpoint_config_file=os.path.join(_PX4_CONFIG_DIR, 'setpoint_sim_outdoor.yaml'), apply_setpoint_params=True)
Px4MavlinkConfig preset for PX4 SITL + Gazebo over direct pymavlink (x500_nectar outdoor).
The downward rangefinder arrives as MAVLink DISTANCE_SENSOR on the offboard link (no MAVROS needed).
PX4_MAVLINK_SITL_VISION_CONFIG
module-attribute
¶
PX4_MAVLINK_SITL_VISION_CONFIG = Px4MavlinkConfig(name='px4_mavlink_sitl_drone', pose_source=PoseSource.VISION, expect_lidar=False, pid_config_file=os.path.join(_PX4_CONFIG_DIR, 'position_sim_indoor.yaml'), setpoint_config_file=os.path.join(_PX4_CONFIG_DIR, 'setpoint_sim_indoor.yaml'), apply_setpoint_params=True)
Px4MavlinkConfig preset for PX4 SITL indoor over direct pymavlink (VISION_POSITION_ESTIMATE).
PX4_SITL_CONFIG
module-attribute
¶
PX4_SITL_CONFIG = Px4MavrosConfig(name='px4_sitl_drone', pose_source=PoseSource.GPS, expect_lidar=False)
Px4MavrosConfig preset for PX4 SITL (headless, GPS, no lidar).
PX4_SITL_GAZEBO_CONFIG
module-attribute
¶
PX4_SITL_GAZEBO_CONFIG = Px4MavrosConfig(name='px4_sitl_drone', pose_source=PoseSource.GPS, expect_lidar=True, pid_config_file=os.path.join(_PX4_CONFIG_DIR, 'position_sim_outdoor.yaml'), setpoint_config_file=os.path.join(_PX4_CONFIG_DIR, 'setpoint_sim_outdoor.yaml'), apply_setpoint_params=True)
Px4MavrosConfig preset for PX4 SITL + Gazebo (x500_nectar outdoor, GPS + rangefinder).
The downward lidar reaches the SDK as /mavros/rangefinder/rangefinder: PX4 fuses the gz gpu_lidar into a distance_sensor and streams DISTANCE_SENSOR, which MAVROS republishes (see simulation/config/px4_config_sitl.yaml).
PX4_SITL_VISION_CONFIG
module-attribute
¶
PX4_SITL_VISION_CONFIG = Px4MavrosConfig(name='px4_sitl_drone', pose_source=PoseSource.VISION, expect_lidar=False, pid_config_file=os.path.join(_PX4_CONFIG_DIR, 'position_sim_indoor.yaml'), setpoint_config_file=os.path.join(_PX4_CONFIG_DIR, 'setpoint_sim_indoor.yaml'), apply_setpoint_params=True)
Px4MavrosConfig preset for PX4 SITL + Gazebo indoor (EKF2 external vision).
SITL_CONFIG
module-attribute
¶
SITL_CONFIG = MavrosConfig(name='sitl_drone', connection_string='tcp://127.0.0.1:5760', expect_lidar=False)
MavrosConfig preset for ArduPilot SITL (headless, no lidar).
SITL_GAZEBO_CONFIG
module-attribute
¶
SITL_GAZEBO_CONFIG = MavrosConfig(name='sitl_drone', pose_source=PoseSource.GPS, connection_string='tcp://127.0.0.1:5760', expect_lidar=True, pid_config_file=os.path.join(_ARDUPILOT_CONFIG_DIR, 'position_sim_outdoor.yaml'), setpoint_config_file=os.path.join(_ARDUPILOT_CONFIG_DIR, 'setpoint_sim_outdoor.yaml'), apply_setpoint_params=True)
MavrosConfig preset for SITL + Gazebo (ardupilot_gazebo iris model, rangefinder enabled).
SITL_GPS_CONFIG
module-attribute
¶
SITL_GPS_CONFIG = MavrosConfig(name='sitl_drone', pose_source=PoseSource.GPS, connection_string='tcp://127.0.0.1:5760', expect_lidar=False)
MavrosConfig preset for SITL with GPS pose source (outdoor simulation).
SITL_VISION_CONFIG
module-attribute
¶
SITL_VISION_CONFIG = MavrosConfig(name='sitl_drone', pose_source=PoseSource.VISION, connection_string='tcp://127.0.0.1:5760', expect_lidar=True, pid_config_file=os.path.join(_ARDUPILOT_CONFIG_DIR, 'position_sim_indoor.yaml'), setpoint_config_file=os.path.join(_ARDUPILOT_CONFIG_DIR, 'setpoint_sim_indoor.yaml'), apply_setpoint_params=True)
MavrosConfig preset for SITL indoor (no GPS, EKF3 ExternalNav, rangefinder enabled).
SetpointNavConfig
dataclass
¶
SetpointNavConfig(guid_options: int = 1, speed: float = 2.0, speed_up: float = 1.5, speed_down: float = 1.5, accel: float = 1.0, radius: float = 0.2, jerk: float = 1.0, psc_jerk: float = 5.0, rfnd_use: int = 1)
Bases: SetpointConfig
Configuration for ArduPilot setpoint navigation parameters.
All speed/distance values in SI units (m/s, m). Conversion to ArduPilot units (cm/s, cm) happens internally when setting FCU parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guid_options
|
int
|
Bitmask for GUID_OPTIONS parameter. Controls GUIDED mode behavior. Bit 0 (1): Allow arming from TX. Bit 6 (64): WPNav S-curve path planning for position targets. Bit 7 (128): Weathervaning. Default 1 = bit 0 (arm from TX, AC_PosControl). See https://ardupilot.org/copter/docs/ac2_guidedmode.html#guided-mode-options |
1
|
speed
|
float
|
Horizontal speed limit in m/s (maps to WPNAV_SPEED in cm/s). |
2.0
|
speed_up
|
float
|
Climb speed limit in m/s (maps to WPNAV_SPEED_UP in cm/s). |
1.5
|
speed_down
|
float
|
Descent speed limit in m/s (maps to WPNAV_SPEED_DN in cm/s). |
1.5
|
accel
|
float
|
Horizontal acceleration in m/s/s (maps to WPNAV_ACCEL in cm/s/s). |
1.0
|
radius
|
float
|
Arrival radius in m (maps to WPNAV_RADIUS in cm). Only used in WPNav mode for trajectory deceleration planning. |
0.2
|
jerk
|
float
|
WPNav horizontal jerk limit in m/s³ (maps to WPNAV_JERK). Controls S-curve trajectory smoothness in WPNav mode (bit 6). ArduPilot default 1.0, range 1–20. |
1.0
|
psc_jerk
|
float
|
Position controller horizontal jerk limit in m/s³ (PSC_JERK_XY in 4.6.3, PSC_JERK_NE in 4.8+). Affects AC_PosControl (SubMode::Pos) response speed. ArduPilot default 5.0, range 1–20. SITL typically needs higher values (e.g. 50) for usable response. |
5.0
|
rfnd_use
|
int
|
Rangefinder terrain following for WPNav (maps to WPNAV_RFND_USE). 0 = disabled, 1 = enabled. ArduPilot default 1. |
1
|
to_fcu_params
¶
Return ArduPilot parameter names and values in FCU units.
Speed/accel/radius are converted to cm/s and cm. Jerk values are
already in m/s³. Uses stable WPNAV_* names
as primary. Use PARAM_ALIASES to get fallback names for
ArduPilot v4.8+.
BaseDrone
¶
Bases: ABC
Abstract base class for drone implementations.
Each drone owns its own ROS 2 Node, which is registered with the
SDK-wide executor at construction time (see :mod:nectar.runtime).
Callers may pass an explicit executor to share an existing one
(e.g. the GUI's or Yasmin's). All blocking methods rely on that
executor to spin in the background.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
DroneConfig
|
Drone configuration dataclass. |
required |
executor
|
Executor
|
Executor to register this drone's node with. Defaults to the
shared SDK executor from :func: |
None
|
is_ready
property
¶
Check if drone is ready for operation (connected and driver running).
is_armed
property
¶
Check if motors are armed.
Returns:
| Type | Description |
|---|---|
Optional[bool]
|
True if armed, False if disarmed, None if not supported. |
flight_mode
property
¶
Current flight mode.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Flight mode name, or None if not available. |
is_fcu_connected
property
¶
Check if FCU/autopilot is connected.
Returns:
| Type | Description |
|---|---|
Optional[bool]
|
True if connected, False otherwise, None if not applicable. |
driver_session_name
property
¶
Tmux session name used for the driver process.
obstacle_manager
property
¶
obstacle_manager: ObstacleManager
Obstacle detection manager for this drone instance.
capabilities
property
¶
capabilities: frozenset[Capability]
Set of features this drone supports.
Override in subclasses to declare the supported :class:Capability
set. The base implementation declares none.
add_obstacle_detector
¶
add_obstacle_detector(name: str, detector: ObstacleDetector, strategy, config: Optional[ObstacleHandlerConfig] = None) -> None
Add obstacle detector with avoidance strategy.
Creates handler with independent timer for detection updates. Strategy determines how drone responds to detected obstacles during navigation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique identifier for this detector. |
required |
detector
|
ObstacleDetector
|
Detector implementation (e.g., DepthObstacleDetector). |
required |
strategy
|
AvoidanceStrategy
|
Strategy for obstacle response (e.g., PauseStrategy, SequenceStrategy). |
required |
config
|
ObstacleHandlerConfig
|
Handler configuration including update rate. If None, uses defaults. |
None
|
remove_obstacle_detector
¶
Remove obstacle detector and cleanup resources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Detector identifier. |
required |
enable_obstacle_detector
¶
Enable obstacle detector.
Starts timer-based updates and activates avoidance strategy during navigation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Detector identifier. |
required |
disable_obstacle_detector
¶
Disable obstacle detector.
Stops timer-based updates and deactivates avoidance strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Detector identifier. |
required |
enable_all_obstacle_detectors
¶
Enable all registered obstacle detectors.
disable_all_obstacle_detectors
¶
Disable all registered obstacle detectors.
connect
abstractmethod
¶
Establish connection to drone hardware or driver.
Returns:
| Type | Description |
|---|---|
bool
|
True if connection successful. |
arm
abstractmethod
¶
Arm motors for flight.
Returns:
| Type | Description |
|---|---|
bool
|
True if arming successful. |
disarm
abstractmethod
¶
Force disarm motors.
Always sends force disarm command to bypass safety checks.
Returns:
| Type | Description |
|---|---|
bool
|
True if disarming successful. |
takeoff
abstractmethod
¶
Execute takeoff to specified altitude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
altitude
|
float
|
Target altitude in meters. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if takeoff successful. |
land
abstractmethod
¶
Execute landing at current position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Maximum time for operation in seconds. |
30.0
|
Returns:
| Type | Description |
|---|---|
bool
|
True if landing successful (motors disarmed). |
move_velocity
abstractmethod
¶
move_velocity(vx: float = 0.0, vy: float = 0.0, vz: float = 0.0, vyaw: float = 0.0, duration: Optional[float] = None, reference: MoveReference = BODY) -> None
Command velocity-based movement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vx
|
float(m / s)
|
(+) Move forward (-) Move backward |
0.0
|
vy
|
float(m / s)
|
(+) Move left (-) Move right |
0.0
|
vz
|
float(m / s)
|
(+) Move up (-) Move down |
0.0
|
vyaw
|
float(rad / s)
|
(+) Rotate counter clockwise (-) Rotate clockwise |
0.0
|
duration
|
float(s)
|
Execution time. If None, command is continuous. |
None
|
reference
|
MoveReference(enum)
|
|
BODY
|
move_to
abstractmethod
¶
move_to(x: Optional[float] = None, y: Optional[float] = None, z: Optional[float] = None, yaw: Optional[float] = None, reference: MoveReference = BODY, timeout: Optional[float] = 60.0, precision: float = 0.2, method: NavigationMethod = POSITION, altitude_source: AltitudeSource = AUTO) -> bool
Navigate to target position.
The movement is relative to the drone's current orientation: - x-axis: forward/backward relative to drone's heading - y-axis: right/left relative to drone's heading - z-axis: up/down relative to current altitude
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Optional[float]
|
Distance to move forward (+) or backward (-) in meters. If None, disables movement in x direction. |
None
|
y
|
Optional[float]
|
Distance to move left (+) or right (-) in meters. If None, disables movement in y direction. |
None
|
z
|
Optional[float]
|
Distance to move up (+) or down (-) in meters. If None altitude control is disabled. |
None
|
yaw
|
Optional[float]
|
Target yaw in degrees. If None, disables yaw control. |
None
|
reference
|
MoveReference(enum)
|
Reference frame for movement: - BODY: relative to current orientation - WORLD: absolute world frame (ENU directions) - TAKEOFF: relative to takeoff position |
BODY
|
timeout
|
Optional[float]
|
Maximum navigation time in seconds. None for no timeout. |
60.0
|
precision
|
float
|
Arrival threshold in meters. |
0.2
|
method
|
NavigationMethod(enum)
|
Navigation algorithm: - POSITION: onboard position controller (FCU setpoint / goTo) - POSITION_GLOBAL: onboard GPS position controller (outdoor only) - PID: companion-side velocity PID with raw sensors - PID_EKF: companion-side velocity PID with EKF-fused position |
POSITION
|
altitude_source
|
AltitudeSource(enum)
|
Altitude sensor source for PID navigation:
|
AUTO
|
Returns:
| Type | Description |
|---|---|
bool
|
True if target reached within precision, False on timeout. |
Raises:
| Type | Description |
|---|---|
TakeoffPositionNotSetError
|
If reference=TAKEOFF but takeoff position not set. |
SensorNotAvailableError
|
If altitude_source=LIDAR but lidar is not available. |
CapabilityNotSupportedError
|
If the requested method is not supported by this drone. |
move_to_gps
¶
move_to_gps(latitude: float, longitude: float, altitude: Optional[float] = None, heading: Optional[float] = None, timeout: Optional[float] = 60.0, precision: float = 0.5, method: NavigationMethod = PID) -> bool
Navigate to GPS coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latitude
|
float
|
Target latitude in degrees (WGS84). |
required |
longitude
|
float
|
Target longitude in degrees (WGS84). |
required |
altitude
|
float
|
Target altitude above ground in meters. None uses current altitude. |
None
|
heading
|
float
|
Target heading in degrees (0 = North, clockwise). None uses current heading. |
None
|
timeout
|
float
|
Maximum navigation time in seconds. |
60.0
|
precision
|
float
|
Arrival threshold in meters. |
0.5
|
method
|
NavigationMethod
|
Navigation algorithm. |
PID
|
Returns:
| Type | Description |
|---|---|
bool
|
True if waypoint reached. |
Raises:
| Type | Description |
|---|---|
CapabilityNotSupportedError
|
If drone doesn't support GPS navigation. |
emergency_stop
abstractmethod
¶
Execute emergency stop (force motor shutdown).
set_home
¶
Set current position as home.
Returns:
| Type | Description |
|---|---|
bool
|
True if successful. |
rtl
¶
rtl(altitude: Optional[float] = None, precision: float = 0.2, method: RTLMethod = NAVIGATE, land: bool = True) -> bool
Return to launch position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
altitude
|
float
|
Transit altitude in meters. None uses current altitude. |
None
|
precision
|
float
|
Arrival threshold in meters (used by NAVIGATE method). |
0.2
|
method
|
RTLMethod
|
RTL algorithm: - NAVIGATE: SDK navigates to takeoff position using position control. - NATIVE: drone's built-in RTL mode (ArduPilot RTL, Bebop navigate_home). |
NAVIGATE
|
land
|
bool
|
Execute landing after reaching home. |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True if RTL successful. |
check_driver_status
¶
Check if driver node is running in ROS2 graph.
Uses ProcessUtils for efficient node checking without blocking.
Returns:
| Type | Description |
|---|---|
bool
|
True if driver node found in ROS2 graph. |
start_driver_process
¶
Start the driver process.
Convenience method that starts the driver and waits for it to be ready.
Returns:
| Type | Description |
|---|---|
bool
|
True if driver started successfully. |
stop_driver_process
¶
Stop the driver process.
Kills the tmux session running the driver.
Returns:
| Type | Description |
|---|---|
bool
|
True if driver stopped successfully. |
delay
¶
Sleep for seconds. SDK executor keeps spinning in the background.
Capability
¶
Bases: Enum
A discrete feature a drone may or may not support.
GPS_NAV
class-attribute
instance-attribute
¶
Navigate to global (lat/lon) waypoints.
LOCAL_SETPOINT
class-attribute
instance-attribute
¶
Onboard local position controller (FRAME_LOCAL_NED setpoints).
GLOBAL_SETPOINT
class-attribute
instance-attribute
¶
Onboard global position controller (GPS setpoints).
PID_NAV
class-attribute
instance-attribute
¶
Companion-side velocity PID navigation.
VELOCITY_BODY
class-attribute
instance-attribute
¶
Velocity commands in the body frame.
VELOCITY_WORLD
class-attribute
instance-attribute
¶
Velocity commands in the world/local frame.
VELOCITY_TAKEOFF
class-attribute
instance-attribute
¶
Velocity commands relative to the takeoff frame.
SERVO
class-attribute
instance-attribute
¶
Per-channel PWM servo control (ArduPilot DO_SET_SERVO).
ACTUATOR
class-attribute
instance-attribute
¶
Normalized payload actuator output (DO_SET_ACTUATOR).
RANGEFINDER
class-attribute
instance-attribute
¶
Downward rangefinder altitude source.
DISTANCE_SENSORS
class-attribute
instance-attribute
¶
All-orientation distance sensor telemetry.
VISION_POSE
class-attribute
instance-attribute
¶
External-vision pose estimate (indoor / non-GPS).
NATIVE_RTL
class-attribute
instance-attribute
¶
Autopilot-native return-to-launch.
OBSTACLE_AVOIDANCE
class-attribute
instance-attribute
¶
Companion-side obstacle detection / avoidance.
Px4MavlinkConfig
dataclass
¶
Px4MavlinkConfig(name: str = 'px4_mavlink_drone', start_driver: bool = False, pose_source: PoseSource = GPS, expect_lidar: bool = True, sensor_timeout: float = 10.0, baud: int = 921600, source_system: int = 1, source_component: int = 191, heartbeat_timeout: float = 30.0, rx_rate_hz: float = 100.0, heartbeat_hz: float = 1.0, stream_rates: Optional[Dict[str, float]] = None, vision_pose_topic: str = '/visual_slam/tracking/vo_pose_covariance', pid_config_file: Optional[str] = None, setpoint_config_file: Optional[str] = None, apply_setpoint_params: bool = False, connection_string: str = 'udp:0.0.0.0:14540', offboard_rate_hz: float = 20.0)
Bases: _MavlinkLinkConfig
PX4 over a direct pymavlink link (no MAVROS).
Mirrors :class:MavlinkConfig (pymavlink endpoint + stream settings) and
adds offboard_rate_hz for the PX4 offboard setpoint pump.
DriverInfo
dataclass
¶
DriverInfo(name: str, node_patterns: List[str], session_name: str, topic_patterns: List[str] = list(), driverless: bool = False, detect_via: str = 'node')
Information about a drone driver.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Human-readable driver name. |
node_patterns |
List[str]
|
ROS2 node name patterns to check for driver status. |
session_name |
str
|
Tmux session name for the driver process. |
topic_patterns |
List[str]
|
ROS2 topic name patterns that signal the driver is up, used when
|
driverless |
bool, default=False
|
True when the transport opens the FCU link inside the drone instance (no separate driver process), e.g. the direct pymavlink backends. |
detect_via |
str, default="node"
|
How to detect a running driver: |
DriverMonitor
¶
Monitor and manage drone driver processes.
Provides utilities for checking driver status using ROS2 node graph and managing driver lifecycle through ProcessUtils.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
driver_type
|
str
|
Type of driver to monitor ('mavros' or 'bebop'). |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
status |
DriverStatus
|
Current driver status. |
last_error |
Optional[str]
|
Last error message if status is ERROR. |
add_status_callback
¶
Register callback for status changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable[[DriverStatus], None]
|
Function called when driver status changes. |
required |
remove_status_callback
¶
Remove registered status callback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable[[DriverStatus], None]
|
Previously registered callback. |
required |
check_status
¶
Check current driver status by querying ROS2 node graph.
Returns:
| Type | Description |
|---|---|
DriverStatus
|
Current driver status. |
start_driver
¶
Start driver process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
Shell command to start the driver. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if driver started successfully. |
stop_driver
¶
Stop driver process.
Returns:
| Type | Description |
|---|---|
bool
|
True if driver stopped successfully. |
restart_driver
¶
Restart driver process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
Shell command to start the driver. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if driver restarted successfully. |
get_available_drivers
staticmethod
¶
Get list of supported driver types.
Returns:
| Type | Description |
|---|---|
List[str]
|
Available driver type identifiers. |
is_ros2_available
staticmethod
¶
Check if ROS2 environment is available.
Returns:
| Type | Description |
|---|---|
bool
|
True if ROS2 commands are accessible. |
CapabilityNotSupportedError
¶
DriverNotFoundError
¶
DroneError
¶
Bases: Exception
Base exception for all drone-related errors.
SensorNotAvailableError
¶
TakeoffPositionNotSetError
¶
DroneFactory
¶
Factory for creating drone instances using registry pattern.
register
classmethod
¶
Register drone type with factory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drone_type
|
str
|
Unique identifier for drone type (case-insensitive). |
required |
builder
|
BuilderFunc
|
Factory function with signature (DroneConfig, Node) -> Drone. |
required |
create
classmethod
¶
Create drone instance of specified type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drone_type
|
str
|
Drone type identifier (e.g., 'mavros', 'bebop'). |
required |
config
|
DroneConfig
|
Type-specific configuration dataclass. |
required |
executor
|
Executor
|
ROS 2 executor to register the drone's internal node with. Defaults
to the shared :mod: |
None
|
Returns:
| Type | Description |
|---|---|
Drone
|
Concrete drone implementation. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If drone_type not registered. |
available_types
classmethod
¶
Get list of registered drone types.
Returns:
| Type | Description |
|---|---|
list[str]
|
Available drone type identifiers, including built-ins that have not been imported yet. |
is_registered
classmethod
¶
Check if drone type is registered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drone_type
|
str
|
Drone type identifier. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if type is registered (explicitly or as a built-in). |
BaseObstacleDetector
¶
Bases: ABC
Thread-safe base class for obstacle detectors. Subclasses must implement _detect() for platform-specific detection logic.
is_enabled
property
¶
Get enabled state.
Returns:
| Type | Description |
|---|---|
bool
|
Enabled state. |
disable
¶
Disable detector and call lifecycle hook.
Calls _on_disable() for resource cleanup.
update
¶
Update detection state.
Thread-safe. Returns cached result if disabled.
Returns:
| Type | Description |
|---|---|
ObstacleInfo
|
Detection result. |
get_last_info
¶
Get last detection result.
Returns:
| Type | Description |
|---|---|
ObstacleInfo
|
Last detection result. |
ObstacleHandler
¶
ObstacleHandler(detector: ObstacleDetector, strategy: AvoidanceStrategy, node: Node, config: Optional[ObstacleHandlerConfig] = None)
Combines obstacle detector with avoidance strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detector
|
ObstacleDetector
|
Detector implementation. |
required |
strategy
|
AvoidanceStrategy
|
Avoidance strategy implementation. |
required |
node
|
Node
|
ROS2 node for timer creation. |
required |
config
|
ObstacleHandlerConfig
|
Handler configuration. If None, uses defaults. |
None
|
should_continue
¶
should_continue(drone: BaseDrone) -> bool
Query if navigation should continue based on obstacle state.
Executes strategy's decision logic. Thread-safe access to detection state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drone
|
BaseDrone
|
Drone instance for strategy execution. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if navigation should continue, False to pause. |
get_axis_modifiers
¶
Get axis disable flags from strategy.
Returns:
| Type | Description |
|---|---|
tuple of (bool, bool, bool)
|
(disable_x, disable_y, disable_z) flags. |
ObstacleManager
¶
Manages multiple obstacle handlers for a drone.
add
¶
add(name: str, handler: ObstacleHandler) -> None
Add obstacle handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique identifier. |
required |
handler
|
ObstacleHandler
|
Handler instance. |
required |
remove
¶
remove(name: str) -> Optional[ObstacleHandler]
Remove and cleanup obstacle handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Handler identifier. |
required |
Returns:
| Type | Description |
|---|---|
(ObstacleHandler, optional)
|
Removed handler, or None if not found. |
should_continue_navigation
¶
should_continue_navigation(drone: BaseDrone) -> bool
Check if navigation should continue.
Queries all enabled handlers. If any returns False, navigation pauses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drone
|
BaseDrone
|
Drone instance for strategy execution. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if all handlers allow navigation, False to pause. |
get_axis_control
¶
Get combined axis disable flags from all handlers.
Returns:
| Type | Description |
|---|---|
tuple of (bool, bool, bool)
|
(disable_x, disable_y, disable_z). True if any handler requests disable. |
PIDConfig
dataclass
¶
PIDConfig(kp: float = 0.0, ki: float = 0.0, kd: float = 0.0, setpoint: float = 0.0, output_min: float = -1.0, output_max: float = 1.0, integral_min: float = -1.0, integral_max: float = 1.0)
PID controller configuration.
from_yaml
classmethod
¶
from_yaml(file_path: str | Path) -> PIDConfig
Load PID configuration from YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str or Path
|
Path to YAML configuration file. |
required |
Returns:
| Type | Description |
|---|---|
PIDConfig
|
PID configuration object. |
from_dict
classmethod
¶
from_dict(config_dict: dict) -> PIDConfig
Create PIDConfig from dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_dict
|
dict
|
Dictionary with PID parameters. |
required |
Returns:
| Type | Description |
|---|---|
PIDConfig
|
PID configuration object. |
to_dict
¶
Convert configuration to dictionary.
Returns:
| Type | Description |
|---|---|
dict
|
Configuration as dictionary. |
PIDController
¶
PIDController(kp: float = 0.0, ki: float = 0.0, kd: float = 0.0, setpoint: float = 0.0, output_limits: tuple[float, float] = (-1.0, 1.0), integral_limits: tuple[float, float] = (-1.0, 1.0), output_deadband: float = 0.0)
PID Controller with anti-windup and output limits.
Initialize PID controller.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kp
|
float
|
Proportional gain. |
0.0
|
ki
|
float
|
Integral gain. |
0.0
|
kd
|
float
|
Derivative gain. |
0.0
|
setpoint
|
float
|
Desired target value. |
0.0
|
output_limits
|
tuple[float, float]
|
Min and max output values (min, max). |
(-1.0, 1.0)
|
integral_limits
|
tuple[float, float]
|
Min and max integral term values for anti-windup (min, max). |
(-1.0, 1.0)
|
output_deadband
|
float
|
Symmetric deadband applied to the final output. Suppresses sub-noise commands that would otherwise be sent to the actuator and cause hover micro-jitter. Set to 0 to disable. |
0.0
|
update
¶
Update PID controller with current value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_value
|
float
|
Current measured value. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Control effort output. |
set_setpoint
¶
Set new setpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
setpoint
|
float
|
New target value. |
required |
tune
¶
Update PID gains.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kp
|
float
|
Proportional gain. |
required |
ki
|
float
|
Integral gain. |
required |
kd
|
float
|
Derivative gain. |
required |
get_components
¶
Get individual PID components for debugging.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with P, I, D components and output. |
PositionPIDConfig
dataclass
¶
PositionPIDConfig(x: PIDConfig = PIDConfig(), y: PIDConfig = PIDConfig(), z: PIDConfig = PIDConfig(), yaw: PIDConfig = PIDConfig())
Configuration for position controller PIDs (X, Y, Z, Yaw axes).
from_yaml
classmethod
¶
from_yaml(file_path: str | Path) -> PositionPIDConfig
Load position PID configuration from YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str or Path
|
Path to YAML configuration file. |
required |
Returns:
| Type | Description |
|---|---|
PositionPIDConfig
|
Position PID configuration object. |
Px4SetpointConfig
dataclass
¶
Px4SetpointConfig(speed: float = 5.0, vel_max: float = 12.0, speed_up: float = 3.0, speed_down: float = 1.5, accel: float = 3.0, accel_up: float = 4.0, accel_down: float = 3.0, jerk: float = 4.0, yaw_rate: float = 45.0, takeoff_speed: float = 1.5)
Bases: SetpointConfig
Configuration for PX4 setpoint navigation (MPC_* parameters).
All values in SI units (m/s, m/s/s, m/s³) except yaw_rate (deg/s, to
match PX4's MPC_YAWRAUTO_MAX). Unlike ArduPilot there is no
GUID_OPTIONS/arrival-radius equivalent — PX4 offboard arrival is judged
by the SDK navigator, so only kinematic limits are configured here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
speed
|
float
|
Desired horizontal cruise speed in m/s (maps to |
5.0
|
vel_max
|
float
|
Maximum horizontal speed in m/s (maps to |
12.0
|
speed_up
|
float
|
Maximum climb speed in m/s (maps to |
3.0
|
speed_down
|
float
|
Maximum descent speed in m/s (maps to |
1.5
|
accel
|
float
|
Horizontal acceleration in m/s/s (maps to |
3.0
|
accel_up
|
float
|
Maximum upward acceleration in m/s/s (maps to |
4.0
|
accel_down
|
float
|
Maximum downward acceleration in m/s/s (maps to |
3.0
|
jerk
|
float
|
Auto-mode jerk limit in m/s³ (maps to |
4.0
|
yaw_rate
|
float
|
Maximum auto yaw rate in deg/s (maps to |
45.0
|
takeoff_speed
|
float
|
Takeoff climb speed in m/s (maps to |
1.5
|
to_fcu_params
¶
Return PX4 parameter names and values in FCU units.
PX4 parameters are already in SI units, so values pass through directly
(yaw_rate stays in deg/s). MPC_XY_VEL_MAX is raised to at least
the cruise speed so the cruise is never clamped by the cap.
SetpointConfig
dataclass
¶
Bases: ABC
Firmware-agnostic setpoint-navigation configuration base.
Subclasses declare SI-unit fields (m/s, m/s/s, m/s³), a _RANGES map of
field -> (min, max) used to clamp values in :meth:__post_init__, an
optional PARAM_ALIASES map (primary FCU name -> firmware alias), and
implement :meth:to_fcu_params.
to_fcu_params
abstractmethod
¶
Return autopilot parameter name -> value in FCU units.
from_yaml
classmethod
¶
from_yaml(file_path: Union[str, Path]) -> SetpointConfig
Load configuration from a YAML mapping file.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the YAML content is not a mapping. |
from_dict
classmethod
¶
from_dict(config_dict: dict) -> SetpointConfig
Create from a dict, ignoring keys that are not declared fields.
DistanceReading
dataclass
¶
DistanceReading(distance: float = 0.0, orientation: SensorOrientation = OTHER, min_distance: float = 0.0, max_distance: float = 0.0, sensor_id: int = 0, sensor_type: int = 0, signal_quality: Optional[int] = None, raw_orientation: int = 0, timestamp: float = 0.0)
A single distance-sensor measurement reported by the FCU.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
distance
|
float
|
Measured distance in meters. |
0.0
|
orientation
|
SensorOrientation
|
Direction the sensor faces in the body frame. |
OTHER
|
min_distance
|
float
|
Sensor range limits in meters. |
0.0
|
max_distance
|
float
|
Sensor range limits in meters. |
0.0
|
sensor_id
|
int
|
MAVLink sensor id; the key under which the reading is stored. |
0
|
sensor_type
|
int
|
|
0
|
signal_quality
|
int
|
Quality 0-100, or |
None
|
raw_orientation
|
int
|
Original MAV_SENSOR_ORIENTATION value (useful when |
0
|
timestamp
|
float
|
Monotonic seconds when the reading was received. |
0.0
|
SensorOrientation
¶
Bases: Enum
Mounting direction of a distance sensor in the body frame.
Mirrors the subset of MAV_SENSOR_ORIENTATION
<https://mavlink.io/en/messages/common.html#MAV_SENSOR_ORIENTATION>_ that
ArduPilot reports for rangefinders and proximity sectors. Yaw values are
measured clockwise from forward (0 = forward, 90 = right). OTHER covers
any value outside this set.
from_mavlink
classmethod
¶
from_mavlink(value: int) -> SensorOrientation
Map a raw MAV_SENSOR_ORIENTATION value, falling back to OTHER.
BebopDrone
¶
Bases: BaseDrone
Parrot Bebop 2 drone implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BebopConfig
|
Bebop-specific configuration. |
required |
executor
|
Executor
|
ROS 2 executor to register this drone's node with. Defaults to
the shared :mod: |
None
|
capabilities
property
¶
capabilities: frozenset[Capability]
Movement and control features supported by the Bebop.
Body-frame velocity (cmd_vel) and autopilot-native return-to-home.
No position control, parameters, GPS, or companion navigation.
from_config
classmethod
¶
from_config(config: DroneConfig, executor: Optional[Executor] = None) -> BebopDrone
Factory entry point for :class:DroneFactory.
connect
¶
Check Bebop driver connection status.
Returns:
| Type | Description |
|---|---|
bool
|
True if the bebop_driver node is running. |
arm
¶
Arm motors (no-op for Bebop).
Bebop arms automatically on takeoff.
Returns:
| Type | Description |
|---|---|
bool
|
Always True. |
disarm
¶
Force disarm motors via emergency stop.
Returns:
| Type | Description |
|---|---|
bool
|
True if command sent. |
takeoff
¶
Execute takeoff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
altitude
|
float
|
Target altitude in meters (ignored by Bebop, uses default hover altitude). |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if takeoff command sent. |
land
¶
Execute landing at current position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Maximum time for operation (unused, Bebop lands asynchronously). |
30.0
|
Returns:
| Type | Description |
|---|---|
bool
|
True if land command sent. |
move_velocity
¶
move_velocity(vx: float = 0.0, vy: float = 0.0, vz: float = 0.0, vyaw: float = 0.0, duration: Optional[float] = None, reference: MoveReference = BODY) -> None
Command velocity-based movement.
Bebop uses normalized velocities (-1.0 to 1.0). Values are clamped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vx
|
float
|
Forward/backward velocity (-1.0 to 1.0). |
0.0
|
vy
|
float
|
Left/right velocity (-1.0 to 1.0). |
0.0
|
vz
|
float
|
Up/down velocity (-1.0 to 1.0). |
0.0
|
vyaw
|
float
|
Yaw rotation velocity (-1.0 to 1.0). |
0.0
|
duration
|
float
|
If specified, sends command for this duration. |
None
|
reference
|
MoveReference
|
Reference frame (only BODY supported, others ignored). |
BODY
|
Notes
Bebop only supports BODY frame. WORLD and TAKEOFF references are ignored.
flip
¶
Execute acrobatic flip maneuver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
direction
|
int
|
Flip direction: 0=Front, 1=Back, 2=Right, 3=Left. |
required |
camera_control
¶
Control camera gimbal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tilt
|
float
|
Tilt angle in degrees (positive=down, negative=up). |
required |
pan
|
float
|
Pan angle in degrees (positive=left, negative=right). |
required |
CrazyflieDrone
¶
Bases: BaseDrone
Crazyflie 2.x drone implementation via Crazyswarm2.
Communicates with the Crazyflie through the crazyflie_server ROS 2 node, which handles radio communication, parameter syncing, and logging. Supports the high-level commander (takeoff, land, goTo) and streaming setpoints (cmdFullState, cmdPosition).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
CrazyflieConfig
|
Crazyflie-specific configuration. |
required |
executor
|
Executor
|
ROS 2 executor to register this drone's node with. Defaults to
the shared :mod: |
None
|
capabilities
property
¶
capabilities: frozenset[Capability]
Movement and control features supported by the Crazyflie.
Onboard local position control (move_to POSITION via goTo),
body/world/takeoff velocity streaming, and firmware parameter access.
No GPS, companion PID, vision pose, rangefinder, servo, or native RTL.
pose
property
¶
Current estimated pose from the Crazyflie's state estimator.
from_config
classmethod
¶
from_config(config: DroneConfig, executor: Optional[Executor] = None) -> CrazyflieDrone
Factory entry point for :class:DroneFactory.
connect
¶
Verify connection to the Crazyflie via the server.
Waits for status messages to confirm the server is communicating with the Crazyflie hardware.
Returns:
| Type | Description |
|---|---|
bool
|
True if status messages are being received. |
arm
¶
Arm the Crazyflie.
For CF 2.1 (brushed), arming happens automatically on takeoff. For Bolt-based (brushless), this starts the motors.
Returns:
| Type | Description |
|---|---|
bool
|
True if arm command sent. |
disarm
¶
Disarm the Crazyflie.
Returns:
| Type | Description |
|---|---|
bool
|
True if disarm command sent. |
takeoff
¶
takeoff(altitude: float, duration: Optional[float] = None, timeout: float = 30.0, precision: float = 0.12) -> bool
Execute takeoff to specified altitude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
altitude
|
float
|
Target height in meters (must be > 0). |
required |
duration
|
float
|
Time to reach target height in seconds. If None, estimated from altitude and default_velocity. |
None
|
timeout
|
float
|
Maximum time to wait for altitude convergence. |
30.0
|
precision
|
float
|
Altitude precision in meters. Takeoff succeeds when height >= altitude - precision. |
0.12
|
Returns:
| Type | Description |
|---|---|
bool
|
True if takeoff command sent and altitude reached. |
land
¶
Execute landing at current position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Maximum time for operation in seconds. |
30.0
|
duration
|
float
|
Time for descent in seconds. If None, estimated from current height and default_velocity. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if landing completed (height near ground). |
move_velocity
¶
move_velocity(vx: float = 0.0, vy: float = 0.0, vz: float = 0.0, vyaw: float = 0.0, duration: Optional[float] = None, reference: MoveReference = BODY) -> None
Command velocity-based movement via full-state streaming setpoints.
Publishes to cmd_full_state with the desired velocity. Switches the Crazyflie to low-level streaming mode. Call notify_setpoints_stop() before using high-level commands (takeoff, land, goTo) again.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vx
|
float(m / s)
|
Forward (+) / backward (-) velocity. |
0.0
|
vy
|
float(m / s)
|
Left (+) / right (-) velocity. |
0.0
|
vz
|
float(m / s)
|
Up (+) / down (-) velocity. |
0.0
|
vyaw
|
float(rad / s)
|
Yaw rate. Counter-clockwise positive. |
0.0
|
duration
|
float(s)
|
If specified, sends commands for this duration at ~50Hz. If None, publishes a single command. |
None
|
reference
|
MoveReference
|
BODY: velocities relative to current heading. TAKEOFF: velocities in takeoff heading frame. WORLD: velocities in world frame. |
BODY
|
move_to
¶
move_to(x: Optional[float] = None, y: Optional[float] = None, z: Optional[float] = None, yaw: Optional[float] = None, reference: MoveReference = BODY, timeout: Optional[float] = 60.0, precision: float = 0.1, method: NavigationMethod = POSITION, altitude_source: AltitudeSource = AUTO) -> bool
Navigate to target position using the onboard high-level commander.
Uses the Crazyflie's goTo service which plans a smooth degree-7 polynomial trajectory from current state to target.
Coordinate semantics:
- BODY: offsets relative to current position and heading. x/y=None disables that axis (no offset). z=None maintains current height. yaw is degrees relative to current heading.
- TAKEOFF: offsets relative to takeoff position and heading. x/y=None preserves current position on that axis (does NOT go to takeoff position). z is absolute height above ground (z=None maintains current height, z <= 0 is rejected for safety). yaw is degrees relative to takeoff heading.
- WORLD: absolute world-frame coordinates. None values preserve current position/yaw on that axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Forward (+) / backward (-) offset in meters. |
None
|
y
|
float
|
Left (+) / right (-) offset in meters. |
None
|
z
|
float
|
Up (+) / down (-) offset in meters (BODY) or absolute height (TAKEOFF). |
None
|
yaw
|
float
|
Target yaw in degrees relative to reference heading. None maintains current yaw. |
None
|
reference
|
MoveReference
|
Reference frame for movement. |
BODY
|
timeout
|
float
|
Maximum time for navigation. |
60.0
|
precision
|
float
|
Arrival threshold in meters. |
0.1
|
method
|
NavigationMethod
|
Only POSITION is supported (onboard polynomial planner). PID, PID_EKF, POSITION_GLOBAL raise CapabilityNotSupportedError. |
POSITION
|
altitude_source
|
AltitudeSource
|
Ignored -- Crazyflie uses fused ToF/flow altitude. |
AUTO
|
Returns:
| Type | Description |
|---|---|
bool
|
True if target reached within precision. |
Raises:
| Type | Description |
|---|---|
TakeoffPositionNotSetError
|
If reference=TAKEOFF but takeoff position not set. |
CapabilityNotSupportedError
|
If method is not POSITION. |
emergency_stop
¶
Emergency stop. Cuts power and locks the Crazyflie.
After emergency stop, the Crazyflie must be physically rebooted. All future commands are ignored until reboot.
rtl
¶
rtl(altitude: Optional[float] = None, precision: float = 0.2, method: RTLMethod = NAVIGATE, land: bool = True) -> bool
Return to takeoff position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
altitude
|
float
|
Transit height in meters. If specified, adjusts height first. |
None
|
precision
|
float
|
Arrival threshold in meters. |
0.2
|
method
|
RTLMethod
|
Only NAVIGATE supported. NATIVE raises CapabilityNotSupportedError. |
NAVIGATE
|
land
|
bool
|
Execute landing after reaching takeoff position. |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True if RTL successful. |
go_to
¶
Direct access to the Crazyflie goTo high-level command.
Plans a smooth polynomial trajectory to the goal position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
goal
|
list of 3 floats
|
Target position [x, y, z] in meters. |
required |
yaw
|
float
|
Target yaw angle in radians. |
required |
duration
|
float
|
Time to reach the goal in seconds. |
required |
relative
|
bool
|
If True, goal is relative to current position. |
False
|
cmd_full_state
¶
cmd_full_state(pos: List[float], vel: List[float], acc: List[float], yaw: float, omega: List[float]) -> None
Send a streaming full-state setpoint.
Switches to low-level mode. Call notify_setpoints_stop() before using high-level commands again.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos
|
list of 3 floats
|
Position [x, y, z] in meters. |
required |
vel
|
list of 3 floats
|
Velocity [vx, vy, vz] in m/s. |
required |
acc
|
list of 3 floats
|
Acceleration [ax, ay, az] in m/s^2. |
required |
yaw
|
float
|
Yaw angle in radians. |
required |
omega
|
list of 3 floats
|
Angular velocity [wx, wy, wz] in rad/s. |
required |
cmd_position
¶
Send a streaming position setpoint.
Switches to low-level mode. Call notify_setpoints_stop() before using high-level commands again.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos
|
list of 3 floats
|
Position [x, y, z] in meters. |
required |
yaw
|
float
|
Yaw angle in radians. |
0.0
|
notify_setpoints_stop
¶
Signal end of streaming setpoints.
Must be called after streaming commands (cmd_full_state, cmd_position, move_velocity) and before using high-level commands (takeoff, land, move_to, go_to).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
remain_valid_ms
|
int
|
Milliseconds the last setpoint remains valid. |
100
|
upload_trajectory
¶
Upload a piecewise polynomial trajectory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trajectory_id
|
int
|
ID number for this trajectory. |
required |
pieces
|
list
|
List of TrajectoryPolynomialPiece messages. |
required |
start_trajectory
¶
start_trajectory(trajectory_id: int, timescale: float = 1.0, reverse: bool = False, relative: bool = True) -> None
Begin executing a previously uploaded trajectory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trajectory_id
|
int
|
ID number from upload_trajectory(). |
required |
timescale
|
float
|
Duration scale factor (2.0 = twice as slow). |
1.0
|
reverse
|
bool
|
Execute trajectory backwards in time. |
False
|
relative
|
bool
|
Shift trajectory to begin at current position. |
True
|
set_firmware_param
¶
Set a Crazyflie firmware parameter via the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Parameter name (e.g., "stabilizer.controller", "ring.effect"). |
required |
value
|
int or float
|
Parameter value. |
required |
get_firmware_param
¶
Get a Crazyflie firmware parameter value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Parameter name (e.g., "stabilizer.controller"). |
required |
Returns:
| Type | Description |
|---|---|
int or float or None
|
Parameter value, or None on failure. |
set_group_mask
¶
Set group mask for broadcast commands (swarm coordination).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_mask
|
int
|
8-bit bitmask for group membership (0 = respond to all broadcasts). |
required |
MavlinkConnection
¶
MavlinkConnection(*, source_system: int = 1, source_component: int = MAV_COMP_ID_ONBOARD_COMPUTER, heartbeat_timeout: float = 30.0)
Thin wrapper around pymavlink.mavutil.mavlink_connection.
The connection string and baud rate are passed to :meth:connect, not the
constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_system
|
int
|
MAVLink system ID this connection presents itself as. Default 1 (same system as the FCU; ArduPilot accepts companion-computer messages from the same system ID). |
1
|
source_component
|
int
|
MAVLink component ID. Default |
MAV_COMP_ID_ONBOARD_COMPUTER
|
heartbeat_timeout
|
float
|
Maximum seconds to wait for the first FCU heartbeat during
:meth: |
30.0
|
Attributes:
| Name | Type | Description |
|---|---|---|
master |
mavfile
|
Underlying pymavlink connection. Use |
Notes
A single endpoint must have one RX reader (only the owning transport
calls recv_match) but may have many senders (setpoints, heartbeat,
rangefinder, vision bridge). pymavlink's mav.*_send is not thread-safe,
so every sender must serialize through :attr:send_lock.
connect
¶
Open the MAVLink endpoint and complete the heartbeat handshake.
Blocks until the first non-GCS heartbeat arrives or until
heartbeat_timeout
elapses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
str
|
Connection string. Both |
required |
baud
|
int
|
Serial baud rate. Ignored for non-serial connections. |
921600
|
Raises:
| Type | Description |
|---|---|
TimeoutError
|
If no FCU heartbeat is received within |
MavlinkDrone
¶
MavlinkDrone(config: MavlinkConfig, executor: Optional[Executor] = None, connection: Optional[MavlinkConnection] = None)
Bases: ArduPilotDrone
Direct-pymavlink ArduPilot drone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MavlinkConfig
|
MAVLink-specific configuration (pymavlink connection string, baud, ...). |
required |
executor
|
Executor
|
ROS 2 executor to register this drone's node with. Defaults to the
shared :mod: |
None
|
connection
|
MavlinkConnection
|
Pre-built endpoint to share (e.g. when a rangefinder publisher already
owns the link). When |
None
|
connection
property
¶
connection: MavlinkConnection
The underlying MAVLink endpoint (shareable with sensor publishers).
from_config
classmethod
¶
from_config(config: DroneConfig, executor: Optional[Executor] = None) -> MavlinkDrone
Factory entry point for :class:DroneFactory.
MavrosDrone
¶
Bases: ArduPilotDrone
MAVROS drone implementation for ArduPilot/PX4 flight controllers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MavrosConfig
|
MAVROS-specific configuration. |
required |
executor
|
Executor
|
ROS 2 executor to register this drone's node with. Defaults to the
shared :mod: |
None
|
from_config
classmethod
¶
from_config(config: DroneConfig, executor: Optional[Executor] = None) -> MavrosDrone
Factory entry point for :class:DroneFactory.
DepthObstacleDetector
¶
DepthObstacleDetector(min_distance_mm: float = 100, max_distance_mm: float = 1500, cluster_eps: float = 20, cluster_min_samples: int = 20, min_cluster_pixels: int = 50, depth_threshold_mm: float = 1300, color_topic: str = '/camera/color/image_raw', depth_topic: str = '/camera/depth/image_rect_raw')
Bases: BaseObstacleDetector
RealSense D435i depth camera obstacle detector using DBSCAN clustering.
Processes depth frames to identify obstacle clusters, determines direction (LEFT, RIGHT, FRONT) from cluster position relative to image center, and returns the closest obstacle distance.
The internal :class:ImageHandler owns its own ROS 2 node, registered
with :mod:nectar.runtime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_distance_mm
|
float
|
Valid depth range. Pixels outside are ignored. |
100
|
max_distance_mm
|
float
|
Valid depth range. Pixels outside are ignored. |
100
|
cluster_eps
|
float
|
DBSCAN clustering parameters. |
20
|
cluster_min_samples
|
float
|
DBSCAN clustering parameters. |
20
|
min_cluster_pixels
|
int
|
Minimum total valid pixels to attempt clustering. |
50
|
depth_threshold_mm
|
float
|
Maximum cluster mean depth to consider as obstacle. |
1300
|
color_topic
|
str
|
RealSense color and aligned-depth topics. |
'/camera/color/image_raw'
|
depth_topic
|
str
|
RealSense color and aligned-depth topics. |
'/camera/color/image_raw'
|
detection_event
property
¶
Threading event set when obstacle detected, cleared when path clear.
Px4DdsDrone
¶
Bases: Px4Drone
PX4 drone over the native uXRCE-DDS bridge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Px4DdsConfig
|
PX4/uXRCE-DDS-specific configuration. |
required |
executor
|
Executor
|
ROS 2 executor to register this drone's node with. Defaults to the
shared :mod: |
None
|
from_config
classmethod
¶
from_config(config: DroneConfig, executor: Optional[Executor] = None) -> Px4DdsDrone
Factory entry point for :class:DroneFactory.
Px4MavlinkDrone
¶
Px4MavlinkDrone(config: Px4MavlinkConfig, executor: Optional[Executor] = None, connection: Optional[MavlinkConnection] = None)
Bases: Px4Drone
PX4 drone over a direct pymavlink.
connection
property
¶
connection: MavlinkConnection
The underlying MAVLink endpoint (shareable with sensor publishers).
from_config
classmethod
¶
from_config(config: DroneConfig, executor: Optional[Executor] = None) -> Px4MavlinkDrone
Factory entry point for :class:DroneFactory.
Px4MavrosDrone
¶
Bases: Px4Drone
PX4 drone implementation over MAVROS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Px4MavrosConfig
|
PX4/MAVROS-specific configuration. |
required |
executor
|
Executor
|
ROS 2 executor to register this drone's node with. Defaults to the
shared :mod: |
None
|
from_config
classmethod
¶
from_config(config: DroneConfig, executor: Optional[Executor] = None) -> Px4MavrosDrone
Factory entry point for :class:DroneFactory.
VehicleDrone
¶
Bases: BaseDrone
Firmware-agnostic multicopter drone implementing shared flight behavior.
Holds navigation, takeoff/land sequencing, PID/setpoint movement, GPS
handling, and telemetry access common to every FCU. Firmware-specific
behavior (arm sequence, flight-mode names, native RTL, setpoint
parameters) is delegated to overridable hooks implemented by
:class:~nectar.control.ardupilot.drone.ArduPilotDrone and
:class:~nectar.control.px4.drone.Px4Drone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
DroneConfig
|
Configuration; subclasses pass the firmware/transport-specific config. |
required |
transport
|
VehicleTransport
|
Concrete transport (constructed by the subclass). |
required |
executor
|
Executor
|
ROS 2 executor to register this drone's node with. |
None
|
capabilities
abstractmethod
property
¶
capabilities: frozenset[Capability]
Set of features this drone supports (declared per firmware).
gps
property
¶
GPS fix as a plain :class:GeoPoint.
Raises:
| Type | Description |
|---|---|
SensorNotAvailableError
|
If pose_source is VISION (indoor mode). |
heading
property
¶
Compass heading in degrees.
Raises:
| Type | Description |
|---|---|
SensorNotAvailableError
|
If pose_source is VISION (indoor mode). |
rel_alt
property
¶
Relative altitude above home position.
Raises:
| Type | Description |
|---|---|
SensorNotAvailableError
|
If pose_source is VISION (indoor mode). |
vision_pose
property
¶
Vision-based pose estimate (ENU) as a plain :class:LocalPose.
local_pose
property
¶
EKF-fused local position (ENU) as a plain :class:LocalPose.
pid_config
property
¶
pid_config: Optional[PositionPIDConfig]
Current PID configuration for position control.
setpoint_config
property
¶
setpoint_config: Optional[SetpointConfig]
Current setpoint navigation configuration, or None if unsupported.
distance_sensors
property
¶
distance_sensors: Dict[int, DistanceReading]
All distance-sensor readings the FCU reports, keyed by sensor id.
Covers every orientation (forward, the yaw sectors, up, down) and id, for
obstacle detection, redundancy, or verification. The downward sensor used
for altitude is also available through :meth:get_altitude with
AltitudeSource.LIDAR.
position
property
¶
Current position: vision pose (indoor) or GPS (outdoor).
position_as_target
property
¶
Current position converted to a plain setpoint target.
get_altitude
¶
Get altitude from a specific sensor source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
AltitudeSource
|
Sensor source to read altitude from:
|
AUTO
|
Returns:
| Type | Description |
|---|---|
float or None
|
Altitude in meters, or None if the requested source is unavailable. |
get_distance
¶
get_distance(orientation: SensorOrientation) -> Optional[DistanceReading]
Most recent reading facing orientation, or None if none.
When several sensors share an orientation, the latest one is returned.
disarm
¶
Force disarm motors.
Sends MAV_CMD_COMPONENT_ARM_DISARM (400) with the force flag (param2=21196) to bypass safety checks.
Returns:
| Type | Description |
|---|---|
bool
|
True if disarming successful, False on failure or timeout. |
takeoff
¶
takeoff(altitude: float, max_retries: int = 2, adjust_altitude: bool = True, precision: float = 0.12, timeout: float = 25.0) -> bool
Execute takeoff with event-driven completion detection.
Per attempt: arm (state-polled) -> spin-up delay -> set takeoff position (first attempt) -> takeoff command -> wait for liftoff and altitude settling -> optional altitude adjustment. Skips entirely if already airborne. Retries only on failed liftoff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
altitude
|
float
|
Target altitude in meters. |
required |
max_retries
|
int
|
Maximum number of takeoff attempts. |
2
|
adjust_altitude
|
bool
|
If True, fine-tune altitude using move_to after settling. |
True
|
precision
|
float
|
Altitude precision in meters for adjustment. |
0.12
|
timeout
|
float
|
Maximum seconds to wait for altitude settling and for adjustment. |
25.0
|
Returns:
| Type | Description |
|---|---|
bool
|
True if takeoff successful, False if all retries exhausted. |
land
¶
Execute landing at current position.
Sends the land command and waits for touchdown (descent velocity has
settled) or full disarm, whichever happens first. Returning on
touchdown avoids blocking for ArduPilot's DISARM_DELAY.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Maximum time to wait for landing completion. Defaults are generous for slow SITL descents; real drones return early. |
60.0
|
Returns:
| Type | Description |
|---|---|
bool
|
True on touchdown or disarm, False on command failure or timeout. |
publish_setpoint
¶
Send a navigation target to the transport's setpoint egress.
move_velocity
¶
move_velocity(vx: float = 0.0, vy: float = 0.0, vz: float = 0.0, vyaw: float = 0.0, duration: Optional[float] = None, reference: MoveReference = BODY) -> None
Move the drone by sending velocity commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vx
|
float(m / s)
|
BODY/TAKEOFF: forward (+) / backward (-). WORLD: east (+) / west (-). |
0.0
|
vy
|
float(m / s)
|
BODY/TAKEOFF: left (+) / right (-). WORLD: north (+) / south (-). |
0.0
|
vz
|
float(m / s)
|
Up (+) / down (-). |
0.0
|
vyaw
|
float(rad / s)
|
Counter-clockwise (+) / clockwise (-). |
0.0
|
duration
|
float(s)
|
Movement time. If None, publishes a single command (continuous mode, caller must re-publish). |
None
|
reference
|
MoveReference
|
Velocity reference frame:
|
BODY
|
Raises:
| Type | Description |
|---|---|
TakeoffPositionNotSetError
|
If reference=TAKEOFF but the takeoff position is not set. |
SensorNotAvailableError
|
If required position sensors are not available. |
move_to
¶
move_to(x: Optional[float] = None, y: Optional[float] = None, z: Optional[float] = None, yaw: Optional[float] = None, reference: MoveReference = BODY, timeout: Optional[float] = 60.0, precision: float = 0.2, method: NavigationMethod = PID_EKF, altitude_source: AltitudeSource = AUTO) -> bool
Move the drone to a position relative to its current location and heading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Forward (+) / backward (-) in meters. For PID methods, None disables X-axis control; for POSITION methods, None means zero offset. |
None
|
y
|
float
|
Left (+) / right (-) in meters. For PID methods, None disables Y-axis control; for POSITION methods, None means zero offset. |
None
|
z
|
float
|
Up (+) / down (-) in meters. For PID methods, None disables altitude control; for POSITION methods, None means zero offset. |
None
|
yaw
|
float
|
Yaw angle in degrees. None maintains the current yaw. |
None
|
reference
|
MoveReference
|
BODY: relative to current position/heading. TAKEOFF: absolute from the takeoff position/heading. |
BODY
|
timeout
|
float
|
Maximum navigation time in seconds. |
60.0
|
precision
|
float
|
Arrival threshold in meters. |
0.2
|
method
|
NavigationMethod
|
PID_EKF: companion-side velocity PID with EKF-fused position. PID: companion-side velocity PID with raw sensors (vision/GPS). POSITION: onboard position controller (local setpoint). POSITION_GLOBAL: onboard GPS position controller (outdoor only). |
PID_EKF
|
altitude_source
|
AltitudeSource
|
Altitude source for PID navigation:
|
AUTO
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the target is reached within precision. |
Raises:
| Type | Description |
|---|---|
TakeoffPositionNotSetError
|
If reference=TAKEOFF but the takeoff position is not set. |
CapabilityNotSupportedError
|
If reference=WORLD, or POSITION_GLOBAL indoors. |
SensorNotAvailableError
|
If required position or altitude sensors are not available. |
See Also
https://ardupilot.org/dev/docs/copter-commands-in-guided-mode.html
move_to_gps
¶
move_to_gps(latitude: float, longitude: float, altitude: Optional[float] = None, heading: Optional[float] = None, timeout: Optional[float] = 60.0, precision: float = 0.5, method: NavigationMethod = PID) -> bool
Move the drone to a GPS coordinate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latitude
|
float
|
Target latitude in degrees (WGS84). |
required |
longitude
|
float
|
Target longitude in degrees (WGS84). |
required |
altitude
|
float
|
Target altitude above ground in meters (relative). None keeps current. |
None
|
heading
|
float
|
Heading in degrees (0=North). None keeps current. |
None
|
timeout
|
float
|
Maximum navigation time in seconds. |
60.0
|
precision
|
float
|
Arrival threshold in meters. |
0.5
|
method
|
NavigationMethod
|
PID: companion-side velocity PID with raw GPS. PID_EKF: companion-side velocity PID with EKF local position. POSITION_GLOBAL: onboard GPS position controller. |
PID
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the target is reached within precision. |
Raises:
| Type | Description |
|---|---|
CapabilityNotSupportedError
|
If indoor mode, or POSITION (local) is used with GPS coordinates. |
set_takeoff_position
¶
set_takeoff_position(pose: Optional[Union[LocalPose, GeoPoint, LocalTarget, GlobalTarget]] = None, heading: Optional[float] = None) -> None
Manually set the takeoff position for TAKEOFF reference frame and RTL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pose
|
LocalPose | GeoPoint | LocalTarget | GlobalTarget
|
Position to use. If None, uses the current position. |
None
|
heading
|
float
|
Heading in degrees. Required if |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the pose type is not supported. |
set_pid_config
¶
Update PID configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
str | dict | PositionPIDConfig
|
YAML file path, configuration dictionary, or PositionPIDConfig. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the config type is not supported. |
set_setpoint_config
¶
Update setpoint navigation configuration.
When apply=True (default) the parameters are pushed to the FCU via
set_param (persisted to the autopilot's storage). Use apply=False
to update the SDK-side config only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
str | Path | dict | SetpointConfig
|
YAML file path, configuration dictionary, or a setpoint config of this firmware's type. |
required |
apply
|
bool
|
If True, push the parameters to the FCU. |
True
|
Raises:
| Type | Description |
|---|---|
CapabilityNotSupportedError
|
If this firmware exposes no setpoint configuration. |
TypeError
|
If the config type is not supported. |
set_home
¶
Set the current GPS position as home.
Returns:
| Type | Description |
|---|---|
bool
|
True if the home position was set, False on failure or timeout. |
See Also
https://ardupilot.org/copter/docs/common-mavlink-mission-command-messages-mav_cmd.html#mav-cmd-do-set-home
set_mode
¶
Set the FCU flight mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
Flight mode name (e.g. 'GUIDED', 'STABILIZE', 'LOITER', 'RTL', 'LAND'). |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True only once the FCU reports the requested mode. False if the transport rejects the request or the mode is not confirmed within the timeout. |
See Also
https://ardupilot.org/copter/docs/flight-modes.html
set_param
¶
Set an autopilot parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param_id
|
str
|
Parameter name (e.g. 'RTL_ALT', 'WPNAV_SPEED', 'RTL_RETURN_ALT'). |
required |
param_value
|
int or float
|
Parameter value. Integers are sent as int, floats as double. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the parameter was set, False on failure or timeout. |
set_speed
¶
Change the speed limit at runtime.
Updates the firmware's position-controller speed limit on the given
axis. ArduPilot issues MAV_CMD_DO_CHANGE_SPEED (active immediately);
PX4 updates the matching MPC_* parameter. See the firmware
specializations for the exact semantics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
speed
|
float
|
Speed in m/s. |
required |
speed_type
|
str
|
Speed axis: "horizontal", "climb", or "descent". |
"horizontal"
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the change was accepted, False on failure or timeout. |
set_actuator
¶
Drive a payload actuator output via MAV_CMD_DO_SET_ACTUATOR.
Firmware-neutral normalized actuator control: ArduPilot routes it to the
servo output assigned the matching actuator function, PX4 to the
Peripheral Actuator Set outputs (see the PX4 generic actuator
control docs). Untargeted actuators are left unchanged (NaN).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Actuator number within the group, 1-6. |
required |
value
|
float
|
Normalized output in [-1, 1]. |
required |
group
|
int
|
Actuator set/group index (param7); 0 = first set of 6 outputs. |
0
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the command was accepted, False on failure or timeout. |
Raises:
| Type | Description |
|---|---|
CapabilityNotSupportedError
|
If the drone does not declare |
ValueError
|
If |
set_gripper
¶
Open or close a gripper via MAV_CMD_DO_GRIPPER.
Firmware-neutral gripper control supported by both ArduPilot (Gripper
library) and PX4 (Gripper output function). Ideal for payload release
(e.g. a hook): grab=False releases, grab=True grabs/holds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grab
|
bool
|
True to grab/close, False to release/open. |
required |
instance
|
int
|
Gripper instance id. |
1
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the command was accepted, False on failure or timeout. |
Raises:
| Type | Description |
|---|---|
CapabilityNotSupportedError
|
If the drone does not declare |
rtl
¶
rtl(altitude: Optional[float] = None, precision: float = 0.2, method: RTLMethod = NAVIGATE, land: bool = True) -> bool
Return to launch position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
altitude
|
float
|
Transit altitude in meters. If set, climbs/descends before navigating. |
None
|
precision
|
float
|
Arrival threshold in meters (used by the NAVIGATE method). |
0.2
|
method
|
RTLMethod
|
NAVIGATE: SDK navigates to the takeoff position using position control. NATIVE: trigger the autopilot's native RTL mode. |
NAVIGATE
|
land
|
bool
|
Execute landing after reaching home. |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True if RTL was successful. |
Raises:
| Type | Description |
|---|---|
TakeoffPositionNotSetError
|
If method=NAVIGATE but the takeoff position is not set. |
GPSUtils
¶
GPS utilities for vehicle navigation.
geoid_height
classmethod
¶
Calculate geoid height for AMSL-to-ellipsoid conversion.
Uses EGM96 geoid model with 5' grid and cubic interpolation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latitude
|
float
|
Latitude in degrees. |
required |
longitude
|
float
|
Longitude in degrees. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Geoid height in meters. Subtract from ellipsoid height to get AMSL. |
create_global_target
classmethod
¶
create_global_target(latitude: float, longitude: float, altitude_rel: float, heading: float, initial_altitude: float) -> GlobalTarget
Create a global setpoint with EGM96 altitude correction.
Converts relative altitude to AMSL using the initial GPS altitude and
geoid height. Yaw is stored in ENU radians (matching the local-frame
convention), converted from the NED heading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latitude
|
float
|
Target coordinates in degrees. |
required |
longitude
|
float
|
Target coordinates in degrees. |
required |
altitude_rel
|
float
|
Target altitude above ground in meters. |
required |
heading
|
float
|
Target heading in degrees (0 = North, clockwise). |
required |
initial_altitude
|
float
|
Initial GPS altitude for the AMSL offset. |
required |
Returns:
| Type | Description |
|---|---|
GlobalTarget
|
With AMSL |
check_reached
classmethod
¶
check_reached(current_lat: float, current_lon: float, current_alt: float, target_lat: float, target_lon: float, target_alt: float, precision_radius: float = 0.5, alt_threshold: float = 0.5) -> Tuple[bool, float, float]
Check if a GPS waypoint has been reached (geodesic horizontal distance).
Returns:
| Type | Description |
|---|---|
tuple of (bool, float, float)
|
(reached, horizontal_distance, altitude_difference) |
local_offset
staticmethod
¶
local_offset(current_lat: float, current_lon: float, target_lat: float, target_lon: float) -> Tuple[float, float]
East/north offset in meters from current to target position.
Equirectangular approximation for display and per-axis error reporting;
arrival checks use the geodesic distance from :meth:check_reached.
Returns:
| Type | Description |
|---|---|
tuple of (float, float)
|
(east, north) offset in meters. |
VehicleNavigator
¶
Navigation controller for :class:VehicleDrone.
Handles PID velocity-based and FCU setpoint navigation for both local
(:class:LocalTarget) and global (:class:GlobalTarget) targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drone
|
VehicleDrone
|
Drone instance providing telemetry, setpoint egress, and configuration. |
required |
navigate_pid
¶
navigate_pid(target: Union[LocalTarget, GlobalTarget], active_axes: tuple[bool, bool, bool], yaw: Optional[float], timeout: Optional[float], precision: float, altitude_source: AltitudeSource = AUTO, altitude_target: Optional[float] = None, use_local: bool = False) -> bool
PID velocity-based navigation loop.
Computes body-frame errors, feeds them into per-axis PID controllers, and publishes velocity commands until the target is reached or timeout.
Returns:
| Type | Description |
|---|---|
bool
|
True if target reached within precision, False on timeout. |
navigate_setpoint
¶
navigate_setpoint(target: Union[LocalTarget, GlobalTarget], timeout: Optional[float], precision: float, check_alt: Optional[float] = None) -> bool
Direct setpoint navigation loop.
Sends the target to the transport and monitors distance until reached.
For :class:LocalTarget: checks Euclidean distance using EKF local
position. For :class:GlobalTarget: checks geodesic distance using GPS
and relative altitude.
Returns:
| Type | Description |
|---|---|
bool
|
True if target reached within precision, False on timeout. |
resolve_altitude_target
¶
resolve_altitude_target(z: Optional[float], reference: MoveReference, altitude_source: AltitudeSource) -> Optional[float]
Compute the absolute altitude target for the given source and reference.
Returns:
| Type | Description |
|---|---|
float or None
|
Absolute target value, or None for default position-based altitude. |
Raises:
| Type | Description |
|---|---|
SensorNotAvailableError
|
If LIDAR source requested but lidar data is not available. |
build_driver_command
¶
build_driver_command(drone_type: str, *, connection_string: str = '', ip: str = '', backend: str = '', mocap: bool = False, agent_port: int = 8888) -> str
Build the shell command that launches a drone's driver process.
Single source of truth for the driver launch commands shared by the SDK and the GUI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drone_type
|
str
|
Drone type identifier (e.g. |
required |
connection_string
|
str
|
FCU connection string / |
''
|
ip
|
str
|
Drone IP address (Bebop). |
''
|
backend
|
str
|
Crazyswarm2 backend (Crazyflie). |
''
|
mocap
|
bool
|
Whether to enable motion capture (Crazyflie). |
False
|
agent_port
|
int
|
UDP port for the Micro XRCE-DDS Agent ( |
8888
|
Returns:
| Type | Description |
|---|---|
str
|
Command to run in a tmux session. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the drone type has no driver process (driverless or unknown). |
is_driver_running
¶
Check whether a drone's driver is currently up.
Dispatches on the driver's detect_via strategy: a ROS 2 node-graph
lookup for node-based drivers, or a topic-graph lookup for transports that
surface only through their data topics (e.g. the Micro XRCE-DDS Agent,
detected by PX4's /fmu/* topics). Topic detection is independent of how
the agent was launched (GUI, make sim-bridge PROTOCOL=dds, or manually),
so an externally started agent is recognized too.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drone_type
|
str
|
Drone type identifier. |
required |
timeout
|
float
|
Maximum time for the ROS 2 graph query. |
2.0
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the driver is running. Always False for driverless or unknown types. |