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

Method simple_goto

dronekit/__init__.py:1991–2041  ·  view source on GitHub ↗

Go to a specified global location (:py:class:`LocationGlobal` or :py:class:`LocationGlobalRelative`). There is no mechanism for notification when the target location is reached, and if another command arrives before that point that will be executed immediately. You

(self, location, airspeed=None, groundspeed=None)

Source from the content-addressed store, hash-verified

1989 0, 0, 0, 0, 0, 0, 0, altitude)
1990
1991 def simple_goto(self, location, airspeed=None, groundspeed=None):
1992 '''
1993 Go to a specified global location (:py:class:`LocationGlobal` or :py:class:`LocationGlobalRelative`).
1994
1995 There is no mechanism for notification when the target location is reached, and if another command arrives
1996 before that point that will be executed immediately.
1997
1998 You can optionally set the desired airspeed or groundspeed (this is identical to setting
1999 :py:attr:`airspeed` or :py:attr:`groundspeed`). The vehicle will determine what speed to
2000 use if the values are not set or if they are both set.
2001
2002 The method will change the :py:class:`VehicleMode` to ``GUIDED`` if necessary.
2003
2004 .. code:: python
2005
2006 # Set mode to guided - this is optional as the simple_goto method will change the mode if needed.
2007 vehicle.mode = VehicleMode("GUIDED")
2008
2009 # Set the LocationGlobal to head towards
2010 a_location = LocationGlobal(-34.364114, 149.166022, 30)
2011 vehicle.simple_goto(a_location)
2012
2013 :param location: The target location (:py:class:`LocationGlobal` or :py:class:`LocationGlobalRelative`).
2014 :param airspeed: Target airspeed in m/s (optional).
2015 :param groundspeed: Target groundspeed in m/s (optional).
2016 '''
2017 if isinstance(location, LocationGlobalRelative):
2018 frame = mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT
2019 alt = location.alt
2020 elif isinstance(location, LocationGlobal):
2021 # This should be the proper code:
2022 # frame = mavutil.mavlink.MAV_FRAME_GLOBAL
2023 # However, APM discards information about the relative frame
2024 # and treats any alt value as relative. So we compensate here.
2025 frame = mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT
2026 if not self.home_location:
2027 self.commands.download()
2028 self.commands.wait_ready()
2029 alt = location.alt - self.home_location.alt
2030 else:
2031 raise APIException('Expecting location to be LocationGlobal or LocationGlobalRelative.')
2032
2033 self._master.mav.mission_item_send(0, 0, 0, frame,
2034 mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 2, 0, 0,
2035 0, 0, 0, location.lat, location.lon,
2036 alt)
2037
2038 if airspeed != None:
2039 self.airspeed = airspeed
2040 if groundspeed != None:
2041 self.groundspeed = groundspeed
2042
2043 def send_mavlink(self, message):
2044 """

Callers 4

test_gotoFunction · 0.80
follow_me.pyFile · 0.80
simple_goto.pyFile · 0.80
gotoMethod · 0.80

Calls 3

APIExceptionClass · 0.85
downloadMethod · 0.80
wait_readyMethod · 0.45

Tested by 1

test_gotoFunction · 0.64