I have a class attribute called self.cf_pos.
I passed it into a function:
Code: Select all
def flight_logger(self, cf, uri,cf_pos)
Code: Select all
def sync_logger(scf, cf_pos,log_angle,log_position)
Thanks all.
code below:
Code: Select all
def sync_logger(self,cf,[b]cf_pos[/b],log_angle,log_position):
rawAngle0x = [0, 0]
rawAngle0y = [0, 0]
rawAngle1x = [0, 0]
rawAngle1y = [0, 0]
state_estimate = [0, 0, 0]
with SyncLogger(cf, [log_angle,log_position]) as log:
# TODO add roll and yaw.
for log_entry in log:
if 'lighthouse.rawAngle0x' in log_entry[1]:
data_1 = log_entry[1]
rawAngle0x.append(data_1['lighthouse.rawAngle0x'])
rawAngle0x.pop(0)
rawAngle1x.append(data_1['lighthouse.rawAngle1x'])
rawAngle1x.pop(0)
if rawAngle0x[0] == rawAngle0x[1] and rawAngle1x[0] == rawAngle1x[1]:
[b]cf_pos[/b] = Position(float('nan'), float('nan'), float('nan'))
# print(self.cf_pos.x, self.cf_pos.y, self.cf_pos.z)
if 'stateEstimate.x' in log_entry[1]:
if rawAngle0x[0] != rawAngle0x[1] or rawAngle1x[0] != rawAngle1x[1]:
data_2 = log_entry[1]
state_estimate[0] = data_2['stateEstimate.x']
state_estimate[1] = data_2['stateEstimate.y']
state_estimate[2] = data_2['stateEstimate.z']
[b]cf_pos[/b] = Position(state_estimate[0], state_estimate[1], state_estimate[2])
# print('updating state estimate to {}'.format(self.cf_pos))