Starling Package documentation

circle_flight.py: ROS node to perform flight based on scan parameters. UDRI DTC AEROPRINT

class starling.circle_flight.OffboardStarlingNode(*args: Any, **kwargs: Any)

Bases: Node

Node for controlling a vehicle in offboard mode.

arm()

Send an arm command to the vehicle.

clear_trajectory()

Clear the trajectory.

create_path()

Creates a flight path consisting of multiple circular levels at different altitudes. This method calculates a series of altitudes for circular flight paths, starting from a maximum height and descending to a minimum height. The number of circular levels is determined by num_circles. The altitudes are stored in the circle_altitudes list and are used to initialize circular flight paths.

circle_altitudes

A list to store the altitudes for each circular level.

Type:

list

num_circles

The number of circular levels to create.

Type:

int

min_height

The minimum altitude for the flight path.

Type:

float

max_height

The maximum altitude for the flight path.

Type:

float

start_altitude

The starting altitude for the flight path.

Type:

float

end_altitude

The ending altitude for the flight path.

Type:

float

Logs:

Logs the starting altitude and the list of calculated circle altitudes.

Calls:

self.init_circle(altitude): Initializes a circular flight path at the given altitude.

disarm()

Send a disarm command to the vehicle.

engage_offboard_mode()

Switch to offboard mode.

init_circle(altitude)

Initializes a circular flight path at a given altitude.

Parameters:

altitude (float) – The altitude at which the circular flight path should be initialized.

This method calculates the trajectory setpoints for a circular flight path based on the specified altitude, radius, rate, and cycle duration. It computes the position, velocity, acceleration, and yaw for each step in the circular path and appends the resulting TrajectorySetpoint messages to the path list. Additionally, it calculates the yawspeed for smooth transitions between yaw angles.

self.path

A list of TrajectorySetpoint messages representing the circular flight path.

Type:

list

land()

Switch to land mode.

object_height_callback(msg)

Callback function to update the object’s height.

This function is triggered when a new message is received. It updates the object’s height attribute with the data from the message and logs the update.

Parameters:

msg – The message containing the new height data. It is expected to have a ‘data’ attribute that holds the height value.

offboard_move_callback()

Callback function to handle offboard movement. This function is called periodically to publish the next setpoint in the offboard path. It also handles the end of the scan by publishing a scan end message and initiating a landing sequence after a certain number of iterations.

Behavior:

  • Publishes the next trajectory setpoint if the counter is within the path length.

  • If the counter exceeds the path length and the scan has not ended, it logs the end of the scan, publishes a scan end message, and sets the scan ended flag.

  • Publishes a takeoff setpoint with the end altitude.

  • Initiates landing if the counter exceeds the path length by 100.

Attributes:

  • self.offboard_arr_counter (int): Counter to track the current position in the path.

  • self.path (list): List of trajectory setpoints.

  • self.scan_ended (bool): Flag to indicate if the scan has ended.

  • self.end_altitude (float): Altitude to use for the takeoff setpoint at the end of the scan.

  • self.trajectory_setpoint_publisher (Publisher): Publisher for trajectory setpoints.

  • self.scan_end_pub (Publisher): Publisher for scan end messages.

  • self.get_logger (function): Function to get the logger instance.

  • self.publish_takeoff_setpoint (function): Function to publish the takeoff setpoint.

  • self.land (function): Function to initiate landing.

publish_offboard_control_heartbeat_signal()

Publish the offboard control mode.

publish_takeoff_setpoint(x: float, y: float, z: float)

Publish the trajectory setpoint.

publish_vehicle_command(command, **params) None

Publish a vehicle command.

radius_callback(msg)

Callback function to update the radius based on the received message.

Parameters:

msg (Message) – The message containing the new radius value.

Returns:

None

ready_callback(msg)

Callback function that is triggered when a ready message is received. This function handles the initialization and reset of various components based on the received message. If the message indicates readiness, it resets the system, logs the event, creates a flight path, and starts a timer for periodic callbacks. If the message does not indicate readiness, it resets the system and initiates landing.

Parameters:

msg (std_msgs.msg.Bool) – A message indicating whether the system is ready.

reset()

Resets the flight control node to its initial state.

This method performs the following actions:

  • Attempts to cancel the current timer. Logs a message if it fails.

  • Attempts to cancel the figure-8 timer. Logs a message if it fails.

  • Sets the scan_ended flag to False.

  • Clears the flight path.

  • Resets the offboard setpoint counter.

  • Sets the hit_figure_8 flag to False.

  • Sets the taken_off flag to False.

  • Sets the armed flag to False.

  • Resets the offboard arrival counter.

  • Logs a message indicating that the flight control node has been reset.

start_height_callback(msg)

Callback function to update the start height.

This function is triggered when a new message is received. It updates the start height with the data from the message and logs the updated height.

Parameters:

msg – The message containing the new start height data. It is expected to have a ‘data’ attribute that holds the height value.

timer_callback() None

Timer callback function that handles offboard control and flight operations. This function is periodically called to:

  • Publish offboard control heartbeat signals.

  • Engage offboard mode and arm the vehicle after a certain number of setpoints.

  • Increment the offboard setpoint counter.

  • Publish takeoff setpoints for the vehicle to reach the start altitude.

  • Initiate a scan operation and start a figure-8 flight pattern if conditions are met.

The function performs the following steps:

  1. Publishes offboard control heartbeat signals.

  2. Engages offboard mode and arms the vehicle when the offboard setpoint counter reaches 10.

  3. Increments the offboard setpoint counter if it is less than 11.

  4. Publishes takeoff setpoints until 10 seconds have passed since the start time.

  5. Initiates a scan operation and starts a figure-8 flight pattern if the vehicle is ready and the figure-8 pattern has not been started.

Returns:

None

vehicle_local_position_callback(vehicle_local_position)
vehicle_status_callback(vehicle_status)

Callback function for vehicle_status topic subscriber.

class starling.circle_flight.VOXLQVIOController

Bases: object

Controller class for handling VOXL QVIO (Visual-Inertial Odometry) operations.

reset()

Sends a reset command to the VOXL QVIO system.

starling.circle_flight.main(args=None) None

Main function to initialize the ROS node and start the flight control node.

custom_pc_publisher.py: ROS node for publishing PointCloud2, transformed for drone pose. UDRI DTC AEROPRINT

class starling.custom_pc_publisher.PCNode(*args: Any, **kwargs: Any)

Bases: Node

Node for publishing transformed point cloud data.

callback(data)

Callback function to process incoming point cloud data and publish transformed data.

Parameters:

data (sensor_msgs.msg.PointCloud2) – The incoming point cloud data.

Raises:

Exception – If any error occurs during processing, it logs the exception message.

The function performs the following steps:

  1. Extracts the timestamp from the incoming data and finds the corresponding pose.

  2. Calculates the time difference between the pose and point cloud data.

  3. Checks if the current time minus the last published time is greater than the publishing rate and if the time difference is within the allowed maximum.

  4. If conditions are met, it processes the point cloud data:

  • Converts the PointCloud2 data to a numpy array and then to an Open3D point cloud.

  • Rotates and translates the point cloud based on the pose’s position and orientation.

  • Converts the transformed point cloud back to PointCloud2 format.

  • Publishes the transformed point cloud data.

  • Updates the last published time.

  1. If conditions are not met, it logs a message indicating a bad scan.

class starling.custom_pc_publisher.PoseNode(*args: Any, **kwargs: Any)

Bases: Node

Node for acquiring and managing pose data from VOXL MPA.

This class subscribes to a specific topic to receive pose data in the form of PoseStamped messages. It maintains a dictionary of received poses keyed by their timestamp for quick lookup and retrieval.

As Starling pose data and ToF data are recieved by ROS, we need to ensure the pose is as close to the pose in the particular ToF frame. So we keep a dictionary of recent ToF frames and use the one that most closely matches the pose timestamp.

sub

The subscription to the pose topic.

Type:

Subscription

lookup

A dictionary to store pose messages keyed by their timestamp.

Type:

dict

pose

The most recently received pose message.

Type:

PoseStamped

callback(msg)

Add pose to dictionary.

find(target)

Find a pose with a key closest to a target

get_pose()

Get a pose

starling.custom_pc_publisher.main(args=None) None

Start both nodes in separate threads