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

Method wait_ready

dronekit/__init__.py:2149–2203  ·  view source on GitHub ↗

Waits for specified attributes to be populated from the vehicle (values are initially ``None``). This is typically called "behind the scenes" to ensure that :py:func:`connect` does not return until attributes have populated (via the ``wait_ready`` parameter). You can also u

(self, *types, **kwargs)

Source from the content-addressed store, hash-verified

2147 vehicle.send_mavlink(capability_msg)
2148
2149 def wait_ready(self, *types, **kwargs):
2150 """
2151 Waits for specified attributes to be populated from the vehicle (values are initially ``None``).
2152
2153 This is typically called "behind the scenes" to ensure that :py:func:`connect` does not return until
2154 attributes have populated (via the ``wait_ready`` parameter). You can also use it after connecting to
2155 wait on a specific value(s).
2156
2157 There are two ways to call the method:
2158
2159 .. code-block:: python
2160
2161 #Wait on default attributes to populate
2162 vehicle.wait_ready(True)
2163
2164 #Wait on specified attributes (or array of attributes) to populate
2165 vehicle.wait_ready('mode','airspeed')
2166
2167 Using the ``wait_ready(True)`` waits on :py:attr:`parameters`, :py:attr:`gps_0`,
2168 :py:attr:`armed`, :py:attr:`mode`, and :py:attr:`attitude`. In practice this usually
2169 means that all supported attributes will be populated.
2170
2171 By default, the method will timeout after 30 seconds and raise an exception if the
2172 attributes were not populated.
2173
2174 :param types: ``True`` to wait on the default set of attributes, or a
2175 comma-separated list of the specific attributes to wait on.
2176 :param int timeout: Timeout in seconds after which the method will raise an exception
2177 (the default) or return ``False``. The default timeout is 30 seconds.
2178 :param Boolean raise_exception: If ``True`` the method will raise an exception on timeout,
2179 otherwise the method will return ``False``. The default is ``True`` (raise exception).
2180 """
2181 timeout = kwargs.get('timeout', 30)
2182 raise_exception = kwargs.get('raise_exception', True)
2183
2184 # Vehicle defaults for wait_ready(True) or wait_ready()
2185 if list(types) == [True] or list(types) == []:
2186 types = self._default_ready_attrs
2187
2188 if not all(isinstance(item, basestring) for item in types):
2189 raise APIException('wait_ready expects one or more string arguments.')
2190
2191 # Wait for these attributes to have been set.
2192 await = set(types)
2193 start = monotonic.monotonic()
2194 while not await.issubset(self._ready_attrs):
2195 time.sleep(0.1)
2196 if monotonic.monotonic() - start > timeout:
2197 if raise_exception:
2198 raise APIException('wait_ready experienced a timeout after %s seconds.' %
2199 timeout)
2200 else:
2201 return False
2202
2203 return True
2204
2205
2206class Gimbal(object):

Callers 15

simple_gotoMethod · 0.45
target_locationMethod · 0.45
wait_readyMethod · 0.45
wait_readyMethod · 0.45
connectFunction · 0.45
test_battery_noneFunction · 0.45
test_timeoutFunction · 0.45
test_set_homeFunction · 0.45
test_parameterFunction · 0.45
assert_commandsFunction · 0.45
vehicle_state.pyFile · 0.45
flight_replay.pyFile · 0.45

Calls 2

APIExceptionClass · 0.85
getMethod · 0.80

Tested by 5

test_battery_noneFunction · 0.36
test_timeoutFunction · 0.36
test_set_homeFunction · 0.36
test_parameterFunction · 0.36
assert_commandsFunction · 0.36