blueye.sdk.mission
mission
Classes:
-
Mission–Class for handling mission planning with the drone
Functions:
-
create_waypoint_instruction–Helper function to create waypoint instructions.
-
export_to_json–Export the mission to a JSON file
-
import_from_json–Import a mission from a JSON file
-
prepare_new_mission–Creates a mission from a list of instructions
Mission
Mission(parent_drone: Drone)
Class for handling mission planning with the drone
Example usage
-
Create some instructions
import blueye.protocol as bp go_to_seabed = bp.Instruction(go_to_seabed_command={"desired_speed": 0.3}) take_picture = bp.Instruction(camera_command={ "camera_action": bp.CameraAction.CAMERA_ACTION_TAKE_PHOTO }) go_to_surface = bp.Instruction(go_to_surface_command={"desired_speed": 0.3}) -
Create a mission with the instructions
from blueye.sdk.mission import prepare_new_mission mission = prepare_new_mission( instruction_list = [go_to_seabed, take_picture, go_to_surface], mission_id = 0, mission_name = "Go to seabed and take a picture",) -
Load and run the new mission
drone.mission.load_and_run(mission)
Parameters:
-
parent_drone(Drone) –The parent drone instance.
Methods:
-
clear–Clear the currently loaded mission.
-
get_active–Get the current active mission.
-
get_status–Get the current mission status.
-
load_and_run–Clears any previous mission, loads the given mission, and runs it.
-
pause–Pause the currently running mission.
-
run–Run the currently loaded mission.
-
send_new–Send a new mission to the drone.
Source code in blueye/sdk/mission.py
194 195 196 197 198 199 200 | |
clear
clear()
Clear the currently loaded mission.
Raises:
-
RuntimeError–If the connected drone does not meet the required Blunux version.
Source code in blueye/sdk/mission.py
262 263 264 265 266 267 268 269 | |
get_active
get_active() -> Mission
Get the current active mission.
Returns:
-
Mission–The current active mission. The mission will be empty if no mission is running.
Raises:
-
RuntimeError–If the connected drone does not meet the required Blunux version.
Source code in blueye/sdk/mission.py
218 219 220 221 222 223 224 225 226 227 228 | |
get_status
get_status() -> Optional[MissionStatus]
Get the current mission status.
Returns:
-
Optional[MissionStatus]–The current mission status, or None if no telemetry data has been received.
Raises:
-
RuntimeError–If the connected drone does not meet the required Blunux version.
Source code in blueye/sdk/mission.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
load_and_run
load_and_run(mission: Mission, timeout: float = 2.0)
Clears any previous mission, loads the given mission, and runs it.
The method returns once the drone has been told to run the mission. Use
get_status to follow it from there.
For about a second after the drone boots there is no mission status to read. The method waits for it like for any other state, within the same timeout.
Parameters:
-
mission(Mission) –The mission to load and run.
-
timeout(float, default:2.0) –Seconds to wait for each step: for a mission status to arrive, for the drone to clear a previous mission, and for the new mission to become ready.
Raises:
-
RuntimeError–If the connected drone does not meet the required Blunux version, or the drone fails to load the mission.
-
TimeoutError–If no mission status arrives, or the mission does not become inactive or ready, within the timeout.
Source code in blueye/sdk/mission.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |
pause
pause()
Pause the currently running mission.
Raises:
-
RuntimeError–If the connected drone does not meet the required Blunux version.
Source code in blueye/sdk/mission.py
253 254 255 256 257 258 259 260 | |
run
run()
Run the currently loaded mission.
The mission state must be MISSION_STATE_READY before calling this method.
Raises:
-
RuntimeError–If the connected drone does not meet the required Blunux version.
Source code in blueye/sdk/mission.py
242 243 244 245 246 247 248 249 250 251 | |
send_new
send_new(mission: Mission)
Send a new mission to the drone.
Parameters:
-
mission(Mission) –The mission to send to the drone.
Raises:
-
RuntimeError–If the connected drone does not meet the required Blunux version.
Source code in blueye/sdk/mission.py
230 231 232 233 234 235 236 237 238 239 240 | |
create_waypoint_instruction
create_waypoint_instruction(
waypoint_name: str,
latitude: float,
longitude: float,
depth: float,
speed_to_target: float = 0.6,
speed_to_depth: float = 0.3,
circle_of_acceptance: float = 1,
waypoint_id: int = 0,
) -> Instruction
Helper function to create waypoint instructions.
Parameters:
-
waypoint_name(str) –The name of the waypoint.
-
latitude(float) –The latitude of the waypoint (WGS 84 decimal format). Needs to be in the range [-90, 90].
-
longitude(float) –The longitude of the waypoint (WGS 84 decimal format). Needs to be in the range [-180, 180].
-
depth(float) –The depth of the waypoint (meters below surface).
-
circle_of_acceptance(float, default:1) –The radius of the circle of acceptance (meters).
-
speed_to_target(float, default:0.6) –The speed to the waypoint (m/s).
-
waypoint_id(int, default:0) –The ID of the waypoint.
Raises:
-
ValueError–If latitude or longitude are out of bounds.
Returns:
-
Instruction(Instruction) –An Instruction object with the specified waypoint details.
Source code in blueye/sdk/mission.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
export_to_json
export_to_json(
mission: Mission,
output_path: Optional[Path | str] = None,
)
Export the mission to a JSON file
This allows you to save the mission to a file for later use or to share it with others.
Parameters:
-
mission(Mission) –The mission to export
-
output_path(Optional[Path | str], default:None) –The path to write the JSON file to. If
Nonethe mission will be written to the current directory with the nameBlueyeMission.json. If the path is a directory, the mission will be written to that directory with the nameBlueyeMission.json. Else the mission will be written to the specified file.
Source code in blueye/sdk/mission.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
import_from_json
import_from_json(input_path: Path | str) -> Mission
Import a mission from a JSON file
This allows you to load a mission from a file that was previously exported.
Parameters:
-
input_path(Path | str) –The path to the JSON file to import
Returns:
-
Mission–The imported mission
Source code in blueye/sdk/mission.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
prepare_new_mission
prepare_new_mission(
instruction_list: List[Instruction],
mission_id: int = 0,
mission_name: str = "",
) -> Mission
Creates a mission from a list of instructions
The instructions are copied and numbered 1 to n in list order, which is the numbering the
Blueye app uses. The drone executes the instructions in list order and reports progress by
these ids: MissionStatus.completed_instruction_ids and
ReferenceAutoPilot.active_instruction_id refer to them. The instructions passed in are left
unchanged, so the same instruction object can appear more than once in the list.
Parameters:
-
mission_id(int, default:0) –ID of the mission
-
mission_name(str, default:'') –Name of the mission
-
instruction_list(List[Instruction]) –List of instructions to create the mission from
Raises:
-
ValueError–If the number of instructions exceeds 50, which is the maximum allowed.
Returns:
-
Mission–A mission object with the instructions and their respective IDs
Source code in blueye/sdk/mission.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |