Had some very enlightening evenings - just me, TortoiseHG and the firmware/client code...
Nevertheless, can't get this to work:
main.py
Code: Select all
def connectionDone(self, linkURI):
self.setUIState(UIState.CONNECTED, linkURI)
Config().set("link_uri", linkURI)
lg = LogConfig("Battery", 1000)
lg.addVariable(LogVariable("pm.vbat", "float"))
self.log = self.cf.log.create_log_packet(lg)
if (self.log != None):
self.log.dataReceived.add_callback(self.batteryUpdatedSignal.emit)
self.log.error.add_callback(self.loggingError)
self.log.start()
else:
logger.warning("Could not setup loggingblock!")
gyroconf = LogConfig("Gyro", 10)
gyroconf.addVariable(LogVariable("gyro.x", "float"))
gyroconf.addVariable(LogVariable("gyro.y", "float"))
gyroconf.addVariable(LogVariable("gyro.z", "float"))
self.log = self.cf.log.create_log_packet(gyroconf)
if (self.log != None):
self.log.dataReceived.add_callback(gyroData)
self.log.start()
else:
print "gyro.x/y/z not found in log TOC"
def gyroData(data):
print "Gyrodata: x=%.2f, y=%.2f, z=%.2f" % (data["gyro.x"], data["gyro.y"], data["gyro.z"])
and
stabilizer.c
Code: Select all
LOG_GROUP_START(gyro)
LOG_ADD(LOG_FLOAT, x, &gyro.x)
LOG_ADD(LOG_FLOAT, y, &gyro.y)
LOG_ADD(LOG_FLOAT, z, &gyro.z)
LOG_GROUP_STOP(gyro)
static bool isInit;
static void distributePower(const uint16_t thrust, const int16_t roll,
const int16_t pitch, const int16_t yaw);
So far I'm getting some nice graphs choosing the gyro for plotting.
But what about the console output of the raw gyro data using the code line above:
Code: Select all
print "Gyrodata: x=%.2f, y=%.2f, z=%.2f" % (data["gyro.x"], data["gyro.y"], data["gyro.z"])
1. There's no console output except the default one from the copter's selt test - is anything wrong with my code?
2. Second question: is creating a log group in stabilizer.c also necessary for getting console output of specific sensor data or is it used solely for telling the client what structures can be used for plotting (log TOC)?