payloadcomputerdroneprojekt.mission_computer package#

Submodules#

payloadcomputerdroneprojekt.mission_computer.helper module#

class payloadcomputerdroneprojekt.mission_computer.helper.PIDController(Kp=1.0, Ki=0.0, Kd=0.0, output_limits=(None, None))[source]#

Bases: object

reset()[source]#
payloadcomputerdroneprojekt.mission_computer.helper.action_with_count(plan: dict, count: int)[source]#

Find the next action in the plan and return it with the updated count.

If the count is 0, returns the plan as is. If the count exceeds the number of actions, returns the remaining count.

Parameters:
  • plan (dict) – The action plan.

  • count (int) – Number of actions to skip.

Returns:

The next action or the remaining count.

Return type:

dict or int

payloadcomputerdroneprojekt.mission_computer.helper.count_actions(actions: dict) int[source]#

Recursively count the number of actions in a nested action plan.

Parameters:

actions (dict) – Action plan dictionary.

Returns:

Total number of actions.

Return type:

int

payloadcomputerdroneprojekt.mission_computer.helper.diag(x: float, y: float) float[source]#

Calculate the Euclidean distance from the origin to the point (x, y).

Parameters:
  • x (float) – X coordinate.

  • y (float) – Y coordinate.

Returns:

Euclidean distance.

Return type:

float

payloadcomputerdroneprojekt.mission_computer.helper.find_shortest_path(objs: list[dict], start: list[float]) list[list[float]][source]#

Find the shortest path to all objects from a starting point.

The function sorts the positions of the objects based on their Manhattan distance from the starting point and returns the sorted list of positions.

Parameters:
  • objs (list[dict]) – List of objects, each with a “pos” key containing coordinates.

  • start (list[float]) – Starting position as [x, y].

Returns:

Sorted list of positions based on distance from start.

Return type:

list[list[float]]

payloadcomputerdroneprojekt.mission_computer.helper.rec_serialize(obj)[source]#

Recursively serialize the object to load commands from a file if specified.

If the object is a dictionary and contains a “src” key, it loads the commands from the specified file and updates the object. If the object is a list, it recursively serializes each element.

Parameters:

obj (dict or list) – The object to serialize, which can be a dictionary or a list.

payloadcomputerdroneprojekt.mission_computer.mc_class module#

class payloadcomputerdroneprojekt.mission_computer.mc_class.MissionComputer(config: dict, port: str, camera: type[~payloadcomputerdroneprojekt.camera.abstract_class.AbstractCamera], communications: type[~payloadcomputerdroneprojekt.communications.comm_class.Communications] = <class 'payloadcomputerdroneprojekt.communications.comm_class.Communications'>, image_analysis: type[~payloadcomputerdroneprojekt.image_analysis.ia_class.ImageAnalysis] = <class 'payloadcomputerdroneprojekt.image_analysis.ia_class.ImageAnalysis'>)[source]#

Bases: object

MissionComputer class for managing drone missions, communication, and image analysis.

This class handles mission initialization, execution, progress tracking, and communication with the drone and its subsystems.

Parameters:
  • config (dict) – Configuration dictionary for the mission computer and subsystems.

  • port (str) – Communication port for the drone.

  • camera (type[AbstractCamera]) – Camera class to be used for image analysis.

  • communications (type[Communications], optional) – Communications class for drone communication.

  • image_analysis (type[ImageAnalysis], optional) – ImageAnalysis class for image processing.

async delay(options: dict) None[source]#

Delay execution for a specified amount of time.

Parameters:

options (dict) – Dictionary with the delay time in seconds.

async execute(action: dict) None[source]#

Execute a single mission action.

Parameters:

action (dict) – Action dictionary containing the action type and commands.

async execute_list(options: List[dict]) None[source]#

Execute a list of actions sequentially.

Parameters:

options (List[dict]) – List of action dictionaries.

async forever(options: dict) None[source]#

Run an infinite loop (used for testing or waiting).

Parameters:

options (dict) – Options dictionary (unused).

initiate(missionfile: str = '') None[source]#

Initialize or reset the mission plan from a file.

Parameters:

missionfile (str, optional) – Path to the mission file.

async land(objective: dict) None[source]#

Land the drone at a specified location, optionally using color/shape detection.

Parameters:

objective (dict) – Dictionary with landing coordinates and optional color/shape.

async mov(options: dict) None[source]#

Move the drone to a specified latitude, longitude, and height.

Parameters:

options (dict) – Dictionary with ‘lat’, ‘lon’, and optional ‘height’ and ‘yaw’.

async mov_local(options: dict) None[source]#

Move the drone to a specified local position (x, y, z) in meters.

Parameters:

options (dict) – Dictionary with ‘x’, ‘y’, and optional ‘z’ and ‘yaw’. x: forward (North), y: right (East), z: down (positive)

async mov_multiple(options: List[dict]) None[source]#

Move to multiple locations sequentially.

Parameters:

options (List[dict]) – List of movement command dictionaries.

async mov_to_objects_cap_pic(options: dict) None[source]#

Move to detected objects and capture images at each location.

Parameters:

options (dict) – Dictionary with movement and delay options.

async new_mission(plan: str) None[source]#

Callback for receiving a new mission plan.

Parameters:

plan (str) – Path to the new mission plan file.

async save_progress() None[source]#

Periodically save the current mission progress to a file.

async scan_area(options: dict) None[source]#

Scan a specified area using the drone’s camera.

Parameters:

options (dict) – Dictionary with ‘lat’, ‘lon’, ‘height’, and optional ‘yaw’.

set_work_dir(config: dict) None[source]#
async smart_land(objective: dict) None[source]#
start() None[source]#

Start the mission computer’s main event loop.

async start_camera(options: dict) None[source]#

Start the camera subsystem.

Parameters:

options (dict) – Options for starting the camera (e.g., images per second).

async status(msg: str) None[source]#

Send a status message to the communication subsystem.

Parameters:

msg (str) – Status message to send.

async stop_camera(options: dict) None[source]#

Stop the camera subsystem and process filtered objects.

Parameters:

options (dict) – Options for stopping the camera.

async takeoff(options: dict) None[source]#

Command the drone to take off to a specified height.

Parameters:

options (dict) – Options containing the target height.

payloadcomputerdroneprojekt.mission_computer.mc_class.test_rem(path: str) None[source]#

payloadcomputerdroneprojekt.mission_computer.scan_planer module#

payloadcomputerdroneprojekt.mission_computer.scan_planer.calculate_heading(lat1, lon1, lat2, lon2, transformer)[source]#
payloadcomputerdroneprojekt.mission_computer.scan_planer.export_geojson(scan_data, filename='scan_mission.geojson')[source]#
payloadcomputerdroneprojekt.mission_computer.scan_planer.fov_to_ground_footprint(altitude_m, fov_deg)[source]#
payloadcomputerdroneprojekt.mission_computer.scan_planer.generate_scan_lines(polygon, spacing, angle_deg=0)[source]#
payloadcomputerdroneprojekt.mission_computer.scan_planer.latlon_to_utm(polygon_latlon, epsg='32632')[source]#
payloadcomputerdroneprojekt.mission_computer.scan_planer.plan_scan(polygon_latlon, start_latlon, end_latlon, altitude, fov_deg, overlap_ratio, epsg='32632')[source]#
payloadcomputerdroneprojekt.mission_computer.scan_planer.utm_to_latlon(coords, transformer)[source]#

Module contents#