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

Method connected

examples/multiranger_pointcloud.py:136–174  ·  view source on GitHub ↗
(self, URI)

Source from the content-addressed store, hash-verified

134 print('Disconnected')
135
136 def connected(self, URI):
137 print('We are now connected to {}'.format(URI))
138
139 # The definition of the logconfig can be made before connecting
140 lpos = LogConfig(name='Position', period_in_ms=100)
141 lpos.add_variable('stateEstimate.x')
142 lpos.add_variable('stateEstimate.y')
143 lpos.add_variable('stateEstimate.z')
144
145 try:
146 self.cf.log.add_config(lpos)
147 lpos.data_received_cb.add_callback(self.pos_data)
148 lpos.start()
149 except KeyError as e:
150 print('Could not start log configuration,'
151 '{} not found in TOC'.format(str(e)))
152 except AttributeError:
153 print('Could not add Position log config, bad configuration.')
154
155 lmeas = LogConfig(name='Meas', period_in_ms=100)
156 lmeas.add_variable('range.front')
157 lmeas.add_variable('range.back')
158 lmeas.add_variable('range.up')
159 lmeas.add_variable('range.left')
160 lmeas.add_variable('range.right')
161 lmeas.add_variable('range.zrange')
162 lmeas.add_variable('stabilizer.roll')
163 lmeas.add_variable('stabilizer.pitch')
164 lmeas.add_variable('stabilizer.yaw')
165
166 try:
167 self.cf.log.add_config(lmeas)
168 lmeas.data_received_cb.add_callback(self.meas_data)
169 lmeas.start()
170 except KeyError as e:
171 print('Could not start log configuration,'
172 '{} not found in TOC'.format(str(e)))
173 except AttributeError:
174 print('Could not add Measurement log config, bad configuration.')
175
176 def pos_data(self, timestamp, data, logconf):
177 position = [

Callers

nothing calls this directly

Calls 5

add_variableMethod · 0.95
startMethod · 0.95
LogConfigClass · 0.90
add_configMethod · 0.80
add_callbackMethod · 0.80

Tested by

no test coverage detected