Recording position to something other than a log

Discussions about autonomous flight in general, regardless of positioning method
Post Reply
Posts: 3
Joined: Tue Nov 14, 2017 3:16 am

Recording position to something other than a log

Post by jfenton888 » 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. 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')

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?

Posts: 79
Joined: Tue Jun 30, 2015 7:47 am

Re: Recording position to something other than a log

Post by kristoffer » Tue May 15, 2018 6:43 am


The kalman.stateX, kalman.stateY and kalman.stateZ are log variables that are exposed in the Crazyflie and they contain the current estimated position of the Crazyflie.

You will find the source of the log variable in the crazyflie firmware, ... r_kalman.c at the very end. The values are picked from the state vector of the kalman filter.

Log variables (and their names) are defined in the firmware and transmitted to the python lib in the TOC during the connection handshake, that is why they can not be found in the lib.

- Kristoffer

Post Reply