Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/automodule.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DroneKit-Python API Reference
.. automodule:: dronekit.lib
:members:
:inherited-members:
:exclude-members: Mission, get_mission, ConnectionInfo, web_connect, AuthInfo, delete
:exclude-members: Mission, get_mission, ConnectionInfo, web_connect, AuthInfo, delete, notify_observers, remove_all_observers, local_connect, APIConnection



Expand Down
2 changes: 1 addition & 1 deletion docs/examples/drone_delivery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ All attributes in DroneKit can have observers - this is the primary mechanism yo
...

def location_callback(self, location):
location = self.vehicle.location
location = self.vehicle.location.global_frame

if location.alt is not None:
self.altitude = location.alt
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/flight_replay.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ shown in :ref:`example_mission_basic`):
.. code:: python

print "Generating %s waypoints from replay..." % len(messages)
cmds = v.commands
cmds = vehicle.commands
cmds.clear()
v.flush()
vehicle.flush()
for i in xrange(0, len(messages)):
pt = messages[i]
lat = pt['lat']
Expand All @@ -127,7 +127,7 @@ shown in :ref:`example_mission_basic`):
0, 0, 0, 0, 0, 0,
lat, lon, altitude)
cmds.add(cmd)
v.flush()
vehicle.flush()


Known issues
Expand Down
3 changes: 1 addition & 2 deletions docs/examples/follow_me.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,11 @@ the mode is changed.
# Once we have a valid location (see gpsd documentation) we can start moving our vehicle around
if (gpsd.valid & gps.LATLON_SET) != 0:
altitude = 30 # in meters
dest = Location(gpsd.fix.latitude, gpsd.fix.longitude, altitude, is_relative=True)
dest = LocationGlobal(gpsd.fix.latitude, gpsd.fix.longitude, altitude, is_relative=True)
print "Going to: %s" % dest

# A better implementation would only send new waypoints if the position had changed significantly
vehicle.commands.goto(dest)
vehicle.flush()

# Send a new target every two seconds
# For a complete implementation of follow me you'd want adjust this delay
Expand Down
13 changes: 5 additions & 8 deletions docs/examples/guided-set-speed-yaw-demo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,13 @@ This takes a function argument of either :ref:`Vehicle.commands.goto() <guided_m
.. code-block:: python

def goto(dNorth, dEast, gotoFunction=vehicle.commands.goto):
currentLocation=vehicle.location
currentLocation=vehicle.location.global_frame
targetLocation=get_location_metres(currentLocation, dNorth, dEast)
targetDistance=get_distance_metres(currentLocation, targetLocation)
gotoFunction(targetLocation)
vehicle.flush()

while vehicle.mode.name=="GUIDED": #Stop action if we are no longer in guided mode.
remainingDistance=get_distance_metres(vehicle.location, targetLocation)
remainingDistance=get_distance_metres(vehicle.location.global_frame, targetLocation)
print "Distance to target: ", remainingDistance
if remainingDistance<=targetDistance*0.01: #Just below target, in case of undershoot.
print "Reached target"
Expand Down Expand Up @@ -246,7 +245,7 @@ which is used to directly specify the speed components of the vehicle. The funct
msg = vehicle.message_factory.set_position_target_global_int_encode(
0, # time_boot_ms (not used)
0, 0, # target system, target component
mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT_INT, # frame
mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT_INT, # frame
0b0000111111000111, # type_mask (only speeds enabled)
0, # lat_int - X Position in WGS84 frame in 1e7 * meters
0, # lon_int - Y Position in WGS84 frame in 1e7 * meters
Expand All @@ -259,7 +258,6 @@ which is used to directly specify the speed components of the vehicle. The funct
0, 0) # yaw, yaw_rate (not supported yet, ignored in GCS_Mavlink)
# send command to vehicle
vehicle.send_mavlink(msg)
vehicle.flush()



Expand All @@ -280,7 +278,7 @@ which is used to directly specify the target location of the vehicle. When used
msg = vehicle.message_factory.set_position_target_global_int_encode(
0, # time_boot_ms (not used)
0, 0, # target system, target component
mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT_INT, # frame
mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT_INT, # frame
0b0000111111111000, # type_mask (only speeds enabled)
aLocation.lat*1e7, # lat_int - X Position in WGS84 frame in 1e7 * meters
aLocation.lon*1e7, # lon_int - Y Position in WGS84 frame in 1e7 * meters
Expand All @@ -292,7 +290,6 @@ which is used to directly specify the target location of the vehicle. When used
0, 0) # yaw, yaw_rate (not supported yet, ignored in GCS_Mavlink)
# send command to vehicle
vehicle.send_mavlink(msg)
vehicle.flush()

In the example code this function is called from the :ref:`goto() <example_guided_mode_goto_convenience>` convenience function.

Expand Down Expand Up @@ -334,7 +331,7 @@ which is used to directly specify the target location in the North, East, Down f
0, 0) # yaw, yaw_rate (not supported yet, ignored in GCS_Mavlink)
# send command to vehicle
vehicle.send_mavlink(msg)
vehicle.flush()


At time of writing, acceleration and yaw bits are ignored.

Expand Down
11 changes: 6 additions & 5 deletions docs/examples/mission_basic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ The :ref:`source code <example_mission_basic_source_code>` is relatively self-do
operations are explained in the guide topic :ref:`auto_mode_vehicle_control` .

In overview, the example first calls ``clear_mission()`` to clear the current mission and then creates and
uploads a new mission using ``adds_square_mission(vehicle.location,50)``. This function defines a mission with a takeoff
uploads a new mission using ``adds_square_mission(vehicle.location.global_frame,50)``. This function defines a mission with a takeoff
command and four waypoints arranged in a square around the central position.

After taking off (in guided mode using the ``takeoff()`` function) the example starts the mission by setting the mode to AUTO:
Expand All @@ -147,7 +147,6 @@ After taking off (in guided mode using the ``takeoff()`` function) the example s
print "Starting mission"
# Set mode to AUTO to start mission
vehicle.mode = VehicleMode("AUTO")
vehicle.flush()

The progress of the mission is monitored in a loop. The convenience function
:ref:`distance_to_current_waypoint() <auto_mode_mission_distance_to_waypoint>`
Expand Down Expand Up @@ -187,9 +186,11 @@ This example fails in DroneKit 2.0.0b6 and earlier releases (see `#355 DKPY2 Can

This is blocked by https://github.com/dronekit/dronekit-python/issues/355 (vehicle.commands.clear not working).
The code output in "running the example needs to be updated once this runs cleanly.
The above text for the error needs to be replaced with original text
> "This example works around the :ref:`known issues in the API <auto_mode_mission_known_issues>`.
> Provided that the vehicle is connected and able to arm, it should run through to completion."
The above text for the error needs to be replaced with original text:

> "This example works around the :ref:`known issues in the API <auto_mode_mission_known_issues>`.
> Provided that the vehicle is connected and able to arm, it should run through to completion."

Need to check all that clearing is still strictly necessary in DKPY2 which handles race conditions more gracefully.
Add image of waypoints /flight for top of page.

Expand Down
4 changes: 3 additions & 1 deletion docs/examples/mission_import_export.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ Known issues
This is blocked by https://github.com/dronekit/dronekit-python/issues/355 (vehicle.commands.clear not working).
The code output in "running the example"" needs to be updated once this runs cleanly.
The above text for the error needs to be replaced with original text
> "This example works around known issues in the API:."

> "This example works around known issues in the API:."

Need to check all that clearing is still strictly necessary in DKPY2 which handles race conditions more gracefully.


Expand Down
7 changes: 2 additions & 5 deletions docs/examples/simple_goto.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,12 @@ Flying to a point - Goto
------------------------

The vehicle is already in ``GUIDED`` mode, so to send it to a certain point we just need to
call :py:func:`Vehicle.commands.goto() <dronekit.lib.CommandSequence.goto>` with the target location,
and then :py:func:`flush() <dronekit.lib.Vehicle.flush>` the command:
call :py:func:`Vehicle.commands.goto() <dronekit.lib.CommandSequence.goto>` with the target ``LocationGlobal``:

.. code-block:: python

point1 = Location(-35.361354, 149.165218, 20, is_relative=True)
point1 = LocationGlobal(-35.361354, 149.165218, 20, is_relative=True)
vehicle.commands.goto(point1)
vehicle.flush()

# sleep so we can see the change in map
time.sleep(30)
Expand All @@ -148,7 +146,6 @@ To return to the home position and land, we set the mode to ``RTL``:
.. code-block:: python

vehicle.mode = VehicleMode("RTL")
vehicle.flush()


Source code
Expand Down
15 changes: 7 additions & 8 deletions docs/examples/vehicle_state.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ Example: Vehicle State
This example shows how to get/set vehicle attribute and parameter information,
how to observe vehicle attribute changes, and how to get the home position.

The guide topic :ref:`vehicle-information` provides a more detailed explanation of how the API
should be used.
The guide topic :ref:`vehicle-information` provides a more detailed explanation
of how the API should be used.


Running the example
===================

The example can be run as described in :doc:`running_examples` (which in turn assumes that the vehicle
and DroneKit have been set up as described in :ref:`get-started`).
The example can be run as described in :doc:`running_examples` (which in turn assumes that
the vehicle and DroneKit have been set up as described in :ref:`get-started`).

If you're using a simulated vehicle remember to :ref:`disable arming checks <disable-arming-checks>` so
that the example can run. You can also
Expand Down Expand Up @@ -56,7 +56,8 @@ On the command prompt you should see (something like):
Accumulating vehicle attribute messages (2s)

Get all vehicle attribute values:
Location: Location:lat=-35.3632601,lon=149.1652279,alt=-0.00999999977648,is_relative=False
Global Location: LocationGlobal:lat=-35.363261,lon=149.1652299,alt=0.0,is_relative=False
Local Location: LocationLocal:north=None,east=None,down=None
Attitude: Attitude:pitch=0.00486609805375,yaw=0.489637970924,roll=0.00645932834595
Velocity: [-0.12, 0.06, 0.0]
GPS: GPSInfo:fix=3,num_sat=10
Expand Down Expand Up @@ -117,10 +118,8 @@ Known issues
This example works around the :ref:`known issues in the API <api-information-known-issues>`.
Provided that the vehicle is connected and able to arm, it should run through to completion.

Two cases where you may observe issues are:
You may observe these issues:

* You will see an error ``Timeout setting THR_MIN to 10.000000``. This can be ignored because the value is actually set.
See `#12 Timeout error when setting a parameter <https://github.com/dronekit/dronekit-python/issues/12>`_ for information.
* When the observer sets the mode callback, it waits two seconds after changing the mode before removing the observer
(to ensure that the callback function is run before the observer is removed). In this time you may see the callback being
called twice even though the mode is only changed once.
Expand Down
9 changes: 4 additions & 5 deletions docs/guide/auto_mode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ To start a mission change the mode to AUTO:

# Set the vehicle into auto mode
vehicle.mode = VehicleMode("AUTO")
vehicle.flush()

.. note::

Expand Down Expand Up @@ -344,8 +343,8 @@ The commands are added to a list which is returned by the function.
ln_param4=float(linearray[7])
ln_param5=float(linearray[8])
ln_param6=float(linearray[9])
ln_param7=float(linearray[10])
ln_autocontinue=int(linearray[11].strip())
ln_param7=float(linearray[10])
ln_autocontinue=int(linearray[11].strip())
cmd = Command( 0, 0, 0, ln_frame, ln_command, ln_currentwp, ln_autocontinue, ln_param1, ln_param2, ln_param3, ln_param4, ln_param5, ln_param6, ln_param7)
missionlist.append(cmd)
return missionlist
Expand Down Expand Up @@ -417,8 +416,8 @@ Get distance to waypoint
lat=missionitem.x
lon=missionitem.y
alt=missionitem.z
targetWaypointLocation=Location(lat,lon,alt,is_relative=True)
distancetopoint = get_distance_metres(vehicle.location, targetWaypointLocation)
targetWaypointLocation=LocationGlobal(lat,lon,alt,is_relative=True)
distancetopoint = get_distance_metres(vehicle.location.global_frame, targetWaypointLocation)
return distancetopoint

The function determines the current target waypoint number with :py:func:`Vehicle.commands.next <dronekit.lib.CommandSequence.next>`
Expand Down
Loading