For logging I do the following:
Code: Select all
uris = [
'radio://0/80/2M/E7E7E7E7E0',
'radio://0/80/2M/E7E7E7E7E1',
'radio://0/80/2M/E7E7E7E7E2'
]
def log_stab_callback(uri, timestamp, data, log_conf):
global recording_pos_dict
global recording_pos_dict_est
x = float(data['drone.psX'])
y = float(data['drone.psY'])
z = float(data['drone.psZ'])
est_x = float(data['drone.esPsX'])
est_y = float(data['drone.esPsY'])
est_z = float(data['drone.esPsZ'])
pos_arr = [x, y, z]
est_pos_arr = [est_x, est_y, est_z]
recording_pos_dict[uri[-1]].append(pos_arr)
recording_pos_dict_est[uri[-1]].append(est_pos_arr)
def simple_log_async(scf):
lg_vars = {
'drone.id' : 'uint32_t',
'drone.psX' : 'float' ,
'drone.psY' : 'float',
'drone.psZ' : 'float',
'drone.esPsX' : 'float',
'drone.esPsY' : 'float',
'drone.esPsZ' : 'float'
}
lg_stab = LogConfig(name='Position', period_in_ms=100)
for key in lg_vars:
lg_stab.add_variable(key, lg_vars[key])
cf = scf.cf
cf.log.add_config(lg_stab)
lg_stab.data_received_cb.add_callback(lambda t, d, l: log_stab_callback(cf.link_uri, t, d, l))
lg_stab.start()
time.sleep(0.1)
if __name__ == '__main__':
cflib.crtp.init_drivers(enable_debug_driver=False) # initialize drivers
factory = CachedCfFactory(rw_cache='./cache')
with Swarm(uris, factory=factory) as swarm:
swarm.parallel(simple_log_async)
while True:
...
Can you please tell me what do you mean by "unconventional way"? To set up everything I have followed the instructions in this link
https://www.bitcraze.io/documentation/r ... log_param/ and got some help in the forum
I am using the cflib python library