Recording position to something other than a log
Posted: Sun May 13, 2018 8:47 pm
I am trying to have multiple drones fly in the loco positioning system and have one drone receive set positions and the other one set its position based on the actual position of the first drone, but I need to make the the position of each crazyflie accessible, meaning it cant go to a log. I was planning on having a list that would constantly be updated with the coordinates of the each drone, based on the radio address. However I am having trouble with finding a way to use the coordinates. autonomousSequence.py has a position callback function in the position logger, but I cannot understand where the coordinates are coming from.
def position_callback(timestamp, data, logconf):
x = data['kalman.stateX']
y = data['kalman.stateY']
z = data['kalman.stateZ']
print('pos: ({}, {}, {})'.format(x, y, z))
def start_position_printing(scf):
log_conf = LogConfig(name='Position', period_in_ms=500)
log_conf.add_variable('kalman.stateX', 'float')
log_conf.add_variable('kalman.stateY', 'float')
log_conf.add_variable('kalman.stateZ', 'float')
scf.cf.log.add_config(log_conf)
log_conf.data_received_cb.add_callback(position_callback)
log_conf.start()
kalman.stateX, kalman.stateY, and kalman.stateZ are exactly what I need, but I don't understand where they are coming from. Nowhere in any of the code can I find reference of them, but while they seem to be defined here, I cannot see what their values are actually based on. How can the numerical values that are being output here be referenced in other parts of the code? In other words, what is the path to the coordinates of the crazyflie calculated with the loco positioning system?
def position_callback(timestamp, data, logconf):
x = data['kalman.stateX']
y = data['kalman.stateY']
z = data['kalman.stateZ']
print('pos: ({}, {}, {})'.format(x, y, z))
def start_position_printing(scf):
log_conf = LogConfig(name='Position', period_in_ms=500)
log_conf.add_variable('kalman.stateX', 'float')
log_conf.add_variable('kalman.stateY', 'float')
log_conf.add_variable('kalman.stateZ', 'float')
scf.cf.log.add_config(log_conf)
log_conf.data_received_cb.add_callback(position_callback)
log_conf.start()
kalman.stateX, kalman.stateY, and kalman.stateZ are exactly what I need, but I don't understand where they are coming from. Nowhere in any of the code can I find reference of them, but while they seem to be defined here, I cannot see what their values are actually based on. How can the numerical values that are being output here be referenced in other parts of the code? In other words, what is the path to the coordinates of the crazyflie calculated with the loco positioning system?