Returns a :py:class:`Vehicle` object connected to the address specified by string parameter ``ip``. Connection string parameters (``ip``) for different targets are listed in the :ref:`getting started guide `. The method is usually called with ``wait_ready=True``
(ip,
_initialize=True,
wait_ready=None,
status_printer=errprinter,
vehicle_class=None,
rate=4,
baud=115200,
heartbeat_timeout=30,
source_system=255,
use_native=False)
| 2769 | |
| 2770 | |
| 2771 | def connect(ip, |
| 2772 | _initialize=True, |
| 2773 | wait_ready=None, |
| 2774 | status_printer=errprinter, |
| 2775 | vehicle_class=None, |
| 2776 | rate=4, |
| 2777 | baud=115200, |
| 2778 | heartbeat_timeout=30, |
| 2779 | source_system=255, |
| 2780 | use_native=False): |
| 2781 | """ |
| 2782 | Returns a :py:class:`Vehicle` object connected to the address specified by string parameter ``ip``. |
| 2783 | Connection string parameters (``ip``) for different targets are listed in the :ref:`getting started guide <get_started_connecting>`. |
| 2784 | |
| 2785 | The method is usually called with ``wait_ready=True`` to ensure that vehicle parameters and (most) attributes are |
| 2786 | available when ``connect()`` returns. |
| 2787 | |
| 2788 | .. code:: python |
| 2789 | |
| 2790 | from dronekit import connect |
| 2791 | |
| 2792 | # Connect to the Vehicle using "connection string" (in this case an address on network) |
| 2793 | vehicle = connect('127.0.0.1:14550', wait_ready=True) |
| 2794 | |
| 2795 | :param String ip: :ref:`Connection string <get_started_connecting>` for target address - e.g. 127.0.0.1:14550. |
| 2796 | |
| 2797 | :param Bool/Array wait_ready: If ``True`` wait until all default attributes have downloaded before |
| 2798 | the method returns (default is ``None``). |
| 2799 | The default attributes to wait on are: :py:attr:`parameters`, :py:attr:`gps_0`, |
| 2800 | :py:attr:`armed`, :py:attr:`mode`, and :py:attr:`attitude`. |
| 2801 | |
| 2802 | You can also specify a named set of parameters to wait on (e.g. ``wait_ready=['system_status','mode']``). |
| 2803 | |
| 2804 | For more information see :py:func:`Vehicle.wait_ready <Vehicle.wait_ready>`. |
| 2805 | |
| 2806 | :param status_printer: Method of signature ``def status_printer(txt)`` that prints |
| 2807 | STATUS_TEXT messages from the Vehicle and other diagnostic information. |
| 2808 | By default the status information is printed to the command prompt in which the script is running. |
| 2809 | :param Vehicle vehicle_class: The class that will be instantiated by the ``connect()`` method. |
| 2810 | This can be any sub-class of ``Vehicle`` (and defaults to ``Vehicle``). |
| 2811 | :param int rate: Data stream refresh rate. The default is 4Hz (4 updates per second). |
| 2812 | :param int baud: The baud rate for the connection. The default is 115200. |
| 2813 | :param int heartbeat_timeout: Connection timeout value in seconds (default is 30s). |
| 2814 | If a heartbeat is not detected within this time an exception will be raised. |
| 2815 | :param int source_system: The MAVLink ID of the :py:class:`Vehicle` object returned by this method (by default 255). |
| 2816 | :param bool use_native: Use precompiled MAVLink parser. |
| 2817 | |
| 2818 | .. note:: |
| 2819 | |
| 2820 | The returned :py:class:`Vehicle` object acts as a ground control station from the |
| 2821 | perspective of the connected "real" vehicle. It will process/receive messages from the real vehicle |
| 2822 | if they are addressed to this ``source_system`` id. Messages sent to the real vehicle are |
| 2823 | automatically updated to use the vehicle's ``target_system`` id. |
| 2824 | |
| 2825 | It is *good practice* to assign a unique id for every system on the MAVLink network. |
| 2826 | It is possible to configure the autopilot to only respond to guided-mode commands from a specified GCS ID. |
| 2827 | |
| 2828 |