I've been trying to understand the new changes to the logging API so I've been going through the API documentation code and changing it over line by line where needed. I've got this piece of code that seems to compile okay but when the execution reaches the logging section it craps out with this.
Code: Select all
File "/home/bitcraze/projects/crazyflie-pc-client/lib/cfaltlogger.py", line 46, in connectSetupFinished
self.accel_log = self.crazyflie.log.add_config(accel_log_conf)
File "/home/bitcraze/projects/crazyflie-pc-client/lib/cflib/crazyflie/log.py", line 413, in add_config
var.name) is None):
File "/home/bitcraze/projects/crazyflie-pc-client/lib/cflib/crazyflie/toc.py", line 90, in get_element_by_complete_name
return self.get_element_by_id(self.get_element_id(complete_name))
File "/home/bitcraze/projects/crazyflie-pc-client/lib/cflib/crazyflie/toc.py", line 98, in get_element_id
[group, name] = complete_name.split(".")
Cheers,
doddz
Does anyone know if the crazyflie.log.add_config(accel_log_conf) was the right method to call? Has anyone had this error too and figured out what it was?
The code in question...
Code: Select all
# Set accelerometer logging config
accel_log_conf = LogConfig("Accel", 10)
accel_log_conf.add_variable(LogVariable("acc.x", "float"))
accel_log_conf.add_variable(LogVariable("acc.y", "float"))
accel_log_conf.add_variable(LogVariable("acc.z", "float"))
# Now that the connection is established, start logging
self.accel_log = self.crazyflie.log.add_config(accel_log_conf)
if self.accel_log is not None:
self.accel_log.data_received_cb.add_callback(self.log_accel_data)
self.accel_log.start()
else:
print("acc.x/y/z not found in log TOC")
def log_accel_data(self, data):
logging.info("Accelerometer: x=%.2f, y=%.2f, z=%.2f" %
(data["acc.x"], data["acc.y"], data["acc.z"]))