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
190 191 192 193 194 195 196 |
|
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
258 259 260 261 262 263 264 265 |
|
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
214 215 216 217 218 219 220 221 222 223 224 |
|
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
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|
load_and_run
load_and_run(mission: Mission, timeout: float = 2.0)
Clears any previous mission, loads the given mission, and runs it.
Parameters:
-
mission
(Mission
) –The mission to load and run.
-
timeout
(float
, default:2.0
) –The maximum time to wait for the mission to be ready before raising an exception.
Raises:
-
RuntimeError
–If the connected drone does not meet the required Blunux version.
-
TimeoutError
–If the mission does not become ready within the specified timeout.
Source code in blueye/sdk/mission.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
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
249 250 251 252 253 254 255 256 |
|
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
238 239 240 241 242 243 244 245 246 247 |
|
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
226 227 228 229 230 231 232 233 234 235 236 |
|
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
None
the 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
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
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
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
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
Automatically assigns an ID to each instruction based on the order they are 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 |
|