@@ -192,9 +192,24 @@ def __str__(self):
192
192
return "Battery:voltage={},current={},level={}" .format (self .voltage , self .current , self .level )
193
193
194
194
195
+ class Rangefinder (object ):
196
+ """
197
+ Rangefinder readings.
198
+
199
+ :param distance: Distance.
200
+ :param voltage: Voltage.
201
+ """
202
+ def __init__ (self , distance , voltage ):
203
+ self .distance = distance
204
+ self .voltage = voltage
205
+
206
+ def __str__ (self ):
207
+ return "Rangefinder: distance={}, voltage={}" .format (self .distance , self .voltage )
208
+
209
+
195
210
class VehicleMode (object ):
196
211
"""
197
- This object is used to get and set the current "flight mode".
212
+ This object is used to get and set the current "flight mode".
198
213
199
214
The flight mode determines the behaviour of the vehicle and what commands it can obey.
200
215
The recommended flight modes for *DroneKit-Python* apps depend on the vehicle type:
@@ -330,7 +345,7 @@ def location_callback(location):
330
345
:param attr_name: The attribute to watch.
331
346
:param observer: The callback to invoke when a change in the attribute is detected.
332
347
333
- .. todo:: Check that the defect for endless repetition after thread closes is fixed: https://github.com/diydrones/dronekit-python/issues/74
348
+ .. todo:: Check that the defect for endless repetition after thread closes is fixed: https://github.com/diydrones/dronekit-python/issues/74
334
349
"""
335
350
l = self .__observers .get (attr_name )
336
351
if l is None :
@@ -456,7 +471,7 @@ class Vehicle(HasObservers):
456
471
457
472
.. py:attribute:: mount_status
458
473
459
- Current status of the camera mount (gimbal) as a three element list: ``[ pitch, yaw, roll ]``.
474
+ Current status of the camera mount (gimbal) as a three element list: ``[ pitch, yaw, roll ]``.
460
475
461
476
The values in the list are set to ``None`` if no mount is configured.
462
477
@@ -465,13 +480,13 @@ class Vehicle(HasObservers):
465
480
466
481
Current system :py:class:`Battery` status.
467
482
468
-
483
+
469
484
.. py:attribute:: channel_override
470
485
471
486
.. warning::
472
487
473
- RC override may be useful for simulating user input and when implementing certain types of joystick control.
474
- It should not be used for direct control of vehicle channels unless there is no other choice!
488
+ RC override may be useful for simulating user input and when implementing certain types of joystick control.
489
+ It should not be used for direct control of vehicle channels unless there is no other choice!
475
490
476
491
Instead use the appropriate MAVLink commands like DO_SET_SERVO/DO_SET_RELAY, or more generally
477
492
set the desired position or direction/speed.
@@ -481,15 +496,15 @@ class Vehicle(HasObservers):
481
496
482
497
To cancel an override call ``channel_override`` again, setting zero for the overridden channels.
483
498
484
- The values of the first four channels map to the main flight controls: 1=Roll, 2=Pitch, 3=Throttle, 4=Yaw (the mapping is defined in ``RCMAP_`` parameters:
485
- `Plane <http://plane.ardupilot.com/wiki/arduplane-parameters/#rcmap__parameters>`_,
486
- `Copter <http://copter.ardupilot.com/wiki/configuration/arducopter-parameters/#rcmap__parameters>`_ ,
499
+ The values of the first four channels map to the main flight controls: 1=Roll, 2=Pitch, 3=Throttle, 4=Yaw (the mapping is defined in ``RCMAP_`` parameters:
500
+ `Plane <http://plane.ardupilot.com/wiki/arduplane-parameters/#rcmap__parameters>`_,
501
+ `Copter <http://copter.ardupilot.com/wiki/configuration/arducopter-parameters/#rcmap__parameters>`_ ,
487
502
`Rover <http://rover.ardupilot.com/wiki/apmrover2-parameters/#rcmap__parameters>`_).
488
503
489
- The remaining channel values are configurable, and their purpose can be determined using the
490
- `RCn_FUNCTION parameters <http://plane.ardupilot.com/wiki/flight-features/channel-output-functions/>`_.
491
- In general a value of 0 set for a specific ``RCn_FUNCTION`` indicates that the channel can be
492
- `mission controlled <http://plane.ardupilot.com/wiki/flight-features/channel-output-functions/#disabled>`_ (i.e. it will not directly be
504
+ The remaining channel values are configurable, and their purpose can be determined using the
505
+ `RCn_FUNCTION parameters <http://plane.ardupilot.com/wiki/flight-features/channel-output-functions/>`_.
506
+ In general a value of 0 set for a specific ``RCn_FUNCTION`` indicates that the channel can be
507
+ `mission controlled <http://plane.ardupilot.com/wiki/flight-features/channel-output-functions/#disabled>`_ (i.e. it will not directly be
493
508
controlled by normal autopilot code).
494
509
495
510
An example of setting and clearing the override is given below:
@@ -514,8 +529,8 @@ class Vehicle(HasObservers):
514
529
515
530
https://github.com/diydrones/dronekit-python/issues/72
516
531
517
- .. todo::
518
-
532
+ .. todo::
533
+
519
534
channel_override/channel_readback documentation
520
535
521
536
In a future update strings will be defined per vehicle type ('pitch', 'yaw', 'roll' etc...)
@@ -572,9 +587,9 @@ def commands(self):
572
587
"""
573
588
Gets the editable waypoints for this vehicle (the current "mission").
574
589
575
- This can be used to get, create, and modify a mission. It can also be used for direct control of vehicle position
576
- (outside missions) using the :py:func:`goto <droneapi.lib.CommandSequence.goto>` method.
577
-
590
+ This can be used to get, create, and modify a mission. It can also be used for direct control of vehicle position
591
+ (outside missions) using the :py:func:`goto <droneapi.lib.CommandSequence.goto>` method.
592
+
578
593
:returns: A :py:class:`CommandSequence` containing the waypoints for this vehicle.
579
594
"""
580
595
None
@@ -603,9 +618,9 @@ def get_mission(self, query_params):
603
618
604
619
Returns an object providing access to historical missions.
605
620
606
- .. warning::
621
+ .. warning::
607
622
608
- Mission objects are only accessible from the REST API in release 1 (most use-cases requiring missions prefer a
623
+ Mission objects are only accessible from the REST API in release 1 (most use-cases requiring missions prefer a
609
624
610
625
:param query_params: Some set of arguments that can be used to find a past mission
611
626
:return: Mission - the mission object.
@@ -639,7 +654,7 @@ def message_factory(self):
639
654
msg = vehicle.message_factory.image_trigger_control_encode(True)
640
655
vehicle.send_mavlink(msg)
641
656
642
- There is no need to specify the system id, component id or sequence number of messages (if defined in the message type) as the
657
+ There is no need to specify the system id, component id or sequence number of messages (if defined in the message type) as the
643
658
API will set these appropriately when the message is sent.
644
659
645
660
.. todo:: When I have a custom message guide topic. Link from here to it.
@@ -655,7 +670,7 @@ def send_mavlink(self, message):
655
670
The function can send arbitrary messages/commands to a vehicle at any time and in any vehicle mode. It is particularly useful for
656
671
controlling vehicles outside of missions (for example, in GUIDED mode).
657
672
658
- The :py:func:`message_factory <droneapi.lib.Vehicle.message_factory>` is used to create messages in the appropriate format.
673
+ The :py:func:`message_factory <droneapi.lib.Vehicle.message_factory>` is used to create messages in the appropriate format.
659
674
Callers do not need to populate sysId/componentId/crc in the packet as the method will take care of that before sending.
660
675
661
676
:param: message: A ``MAVLink_message`` instance, created using :py:func:`message_factory <droneapi.lib.Vehicle.message_factory>`.
@@ -677,7 +692,7 @@ def set_mavlink_callback(self, callback):
677
692
678
693
The code snippet below shows how to set a "demo" callback function as the callback handler:
679
694
680
- .. code:: python
695
+ .. code:: python
681
696
682
697
# Demo callback handler for raw MAVLink messages
683
698
def mavrx_debug_handler(message):
@@ -754,12 +769,12 @@ class Parameters(HasObservers):
754
769
vehicle.parameters['THR_MIN']=100
755
770
vehicle.flush()
756
771
757
- .. note::
772
+ .. note::
758
773
759
774
At time of writing ``Parameters`` does not implement the observer methods, and change notification for parameters
760
775
is not supported.
761
776
762
- .. todo::
777
+ .. todo::
763
778
764
779
Check to see if observers have been implemented and if so, update the information here, in about, and in Vehicle class:
765
780
https://github.com/diydrones/dronekit-python/issues/107
@@ -780,9 +795,9 @@ class Command(mavutil.mavlink.MAVLink_mission_item_message):
780
795
mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 0, 0, 0, 0, 0, 0,-34.364114, 149.166022, 30)
781
796
782
797
783
- :param target_system: The id number of the message's target system (drone, GSC) within the MAVLink network.
784
- Set this to zero (broadcast) when communicating with a companion computer.
785
- :param target_component: The id of a component the message should be routed to within the target system
798
+ :param target_system: The id number of the message's target system (drone, GSC) within the MAVLink network.
799
+ Set this to zero (broadcast) when communicating with a companion computer.
800
+ :param target_component: The id of a component the message should be routed to within the target system
786
801
(for example, the camera). Set to zero (broadcast) in most cases.
787
802
:param seq: The sequence number within the mission (the autopilot will reject messages sent out of sequence).
788
803
This should be set to zero as the API will automatically set the correct value when uploading a mission.
@@ -845,7 +860,7 @@ class CommandSequence(object):
845
860
0, 0, 0, 0, 0, 0,
846
861
lat, lon, altitude)
847
862
cmds.add(cmd)
848
- vehicle.flush()
863
+ vehicle.flush()
849
864
850
865
.. py:function:: takeoff(altitude)
851
866
@@ -943,5 +958,3 @@ def next(self, value):
943
958
.. INTERNAL NOTE: (implementation provided by subclass)
944
959
"""
945
960
pass
946
-
947
-
0 commit comments