MCPcopy Create free account
hub / github.com/bitcraze/crazyflie-lib-python / __init__

Method __init__

examples/cfbridge.py:34–58  ·  view source on GitHub ↗

Initialize and run the example with the specified link_uri

(self, link_uri)

Source from the content-addressed store, hash-verified

32
33class RadioBridge:
34 def __init__(self, link_uri):
35 """ Initialize and run the example with the specified link_uri """
36
37 # UDP socket for interfacing with GCS
38 self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
39 self._sock.bind(('127.0.0.1', 14551))
40
41 # Create a Crazyflie object without specifying any cache dirs
42 self._cf = Crazyflie()
43
44 # Connect some callbacks from the Crazyflie API
45 self._cf.link_established.add_callback(self._connected)
46 self._cf.disconnected.add_callback(self._disconnected)
47 self._cf.connection_failed.add_callback(self._connection_failed)
48 self._cf.connection_lost.add_callback(self._connection_lost)
49
50 print('Connecting to %s' % link_uri)
51
52 # Try to connect to the Crazyflie
53 self._cf.open_link(link_uri)
54
55 # Variable used to keep main loop occupied until disconnect
56 self.is_connected = True
57
58 threading.Thread(target=self._server).start()
59
60 def _connected(self, link_uri):
61 """ This callback is called form the Crazyflie API when a Crazyflie

Callers

nothing calls this directly

Calls 4

CrazyflieClass · 0.90
add_callbackMethod · 0.80
open_linkMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected