MCPcopy
hub / github.com/dronekit/dronekit-python / target_location

Method target_location

dronekit/__init__.py:2311–2359  ·  view source on GitHub ↗

Point the gimbal at a specific region of interest (ROI). .. code-block:: python #Set the camera to track the current home location. vehicle.gimbal.target_location(vehicle.home_location) The target position must be defined in a :py:class:`LocationGl

(self,roi)

Source from the content-addressed store, hash-verified

2309 self._vehicle.send_mavlink(msg)
2310
2311 def target_location(self,roi):
2312 """
2313 Point the gimbal at a specific region of interest (ROI).
2314
2315 .. code-block:: python
2316
2317 #Set the camera to track the current home location.
2318 vehicle.gimbal.target_location(vehicle.home_location)
2319
2320 The target position must be defined in a :py:class:`LocationGlobalRelative` or :py:class:`LocationGlobal`.
2321
2322 This function can be called in AUTO or GUIDED mode.
2323
2324 In order to clear an ROI you can send a location with all zeros (e.g. ``LocationGlobalRelative(0,0,0)``).
2325
2326 :param roi: Target location in global relative frame.
2327 """
2328 #set gimbal to targeting mode
2329 msg = self._vehicle.message_factory.mount_configure_encode(
2330 0, 1, # target system, target component
2331 mavutil.mavlink.MAV_MOUNT_MODE_GPS_POINT, #mount_mode
2332 1, # stabilize roll
2333 1, # stabilize pitch
2334 1, # stabilize yaw
2335 )
2336 self._vehicle.send_mavlink(msg)
2337
2338 #Get altitude relative to home irrespective of Location object passed in.
2339 if isinstance(roi, LocationGlobalRelative):
2340 alt = roi.alt
2341 elif isinstance(roi, LocationGlobal):
2342 if not self.home_location:
2343 self.commands.download()
2344 self.commands.wait_ready()
2345 alt = roi.alt - self.home_location.alt
2346 else:
2347 raise APIException('Expecting location to be LocationGlobal or LocationGlobalRelative.')
2348
2349 #set the ROI
2350 msg = self._vehicle.message_factory.command_long_encode(
2351 0, 1, # target system, target component
2352 mavutil.mavlink.MAV_CMD_DO_SET_ROI, #command
2353 0, #confirmation
2354 0, 0, 0, 0, #params 1-4
2355 roi.lat,
2356 roi.lon,
2357 alt
2358 )
2359 self._vehicle.send_mavlink(msg)
2360
2361 def release(self):
2362 """

Callers

nothing calls this directly

Calls 4

APIExceptionClass · 0.85
send_mavlinkMethod · 0.80
downloadMethod · 0.80
wait_readyMethod · 0.45

Tested by

no test coverage detected