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

Method initialize

dronekit/__init__.py:2101–2142  ·  view source on GitHub ↗
(self, rate=4, heartbeat_timeout=30)

Source from the content-addressed store, hash-verified

2099 return self._master.mav
2100
2101 def initialize(self, rate=4, heartbeat_timeout=30):
2102 self._handler.start()
2103
2104 # Start heartbeat polling.
2105 start = monotonic.monotonic()
2106 self._heartbeat_error = heartbeat_timeout or 0
2107 self._heartbeat_started = True
2108 self._heartbeat_lastreceived = start
2109
2110 # Poll for first heartbeat.
2111 # If heartbeat times out, this will interrupt.
2112 while self._handler._alive:
2113 time.sleep(.1)
2114 if self._heartbeat_lastreceived != start:
2115 break
2116 if not self._handler._alive:
2117 raise APIException('Timeout in initializing connection.')
2118
2119 # Register target_system now.
2120 self._handler.target_system = self._heartbeat_system
2121
2122 # Wait until board has booted.
2123 while True:
2124 if self._flightmode not in [None, 'INITIALISING', 'MAV']:
2125 break
2126 time.sleep(0.1)
2127
2128 # Initialize data stream.
2129 if rate != None:
2130 self._master.mav.request_data_stream_send(0, 0, mavutil.mavlink.MAV_DATA_STREAM_ALL,
2131 rate, 1)
2132
2133 self.add_message_listener('HEARTBEAT', self.send_capabilties_request)
2134
2135 # Ensure initial parameter download has started.
2136 while True:
2137 # This fn actually rate limits itself to every 2s.
2138 # Just retry with persistence to get our first param stream.
2139 self._master.param_fetch_all()
2140 time.sleep(0.1)
2141 if self._params_count > -1:
2142 break
2143
2144 def send_capabilties_request(self, vehicle, name, m):
2145 '''Request an AUTOPILOT_VERSION packet'''

Callers 2

connectFunction · 0.80
test_battery_noneFunction · 0.80

Calls 3

add_message_listenerMethod · 0.95
APIExceptionClass · 0.85
startMethod · 0.80

Tested by 1

test_battery_noneFunction · 0.64