altHold log problem
Posted: Sat Jun 06, 2015 7:52 pm
Below there is a snippet of a python program. the aim is to get some log TOC data.
########################################################################
# Set up Holder Logger
########################################################################
self._lg_altH = LogConfig(name="altHold", period_in_ms=50)
#self._lg_altH.addVariable("altHold.zSpeed", "float") #L1
#self._lg_altH.addVariable("altHold.vSpeed", "float") #L2
#self._lg_altH.addVariable("altHold.target", "float") #L3
self._cf.log.add_config(self._lg_altH)
if self._lg_altH.valid:
# This callback will receive the data
self._lg_altH.data_received_cb.add_callback(self._log_altH_data)
# This callback will be called on errors
self._lg_altH.error_cb.add_callback(self._log_error)
# Start the logging
self._lg_altH.start()
else:
print("Could not add logconfig since some variables are not in TOC")
########################################################################
# Set up Acc Logger
########################################################################
self._lg_acc = LogConfig(name="Acc", period_in_ms=50)
self._lg_acc.add_variable("acc.x", "float")
self._lg_acc.add_variable("acc.y", "float")
self._lg_acc.add_variable("acc.z", "float")
self._cf.log.add_config(self._lg_acc)
if self._lg_acc.valid:
# This callback will receive the data
self._lg_acc.data_received_cb.add_callback(self._log_acc_data)
# This callback will be called on errors
self._lg_acc.error_cb.add_callback(self._log_error)
# Start the logging
self._lg_acc.start()
else:
print("Could not add logconfig since some variables are not in TOC")
def _log_altH_data(self, timestamp, data, logconf):
"""Callback froma the log API when data arrives"""
global a_hold_z, a_hold_v, a_hold_t
(a_hold_z, a_hold_v, a_hold_t) = (data["altHold.zSpeed"], data["altHold.vSpeed"], data["altHold.target"])
def _log_acc_data(self, timestamp, data, logconf):
"""Callback froma the log API when data arrives"""
global g_acc_x, g_acc_y, g_acc_z;
(g_acc_x, g_acc_y, g_acc_z) = (data["acc.x"], data["acc.y"], data["acc.z"])
etc
etc
print "acc.x,y,z=%.3f,%.3f,%.3f" % (g_acc_x, g_acc_y, g_acc_z)
etc
When executing the program, the output is
acc.x,y,z=-0.035,-0.010,1.085
(i.e the acc data are obtained)
with uncommented lines #L1 #L2 #L3 in setup Holder Logger (under the exact same conditions) the output is:
acc.x,y,z=0.000,0.000,0.000
(i.e. no altHold data but also no more acc data)
Why altHold (and motor) Log TOC do not behave like acc,baro,gyro, etc?
How/Why attempting to get the altHold(and motor) data affects the acc (and gyro,etc) data?
I am using CF2
Firmware: 1ab92e55c44b (CLEAN)
Sensors found
HMC5883L: 1
MS5611: 1
Sensors tests
HMC5883L: 1
MPU6500: 1
MS5611: 1
########################################################################
# Set up Holder Logger
########################################################################
self._lg_altH = LogConfig(name="altHold", period_in_ms=50)
#self._lg_altH.addVariable("altHold.zSpeed", "float") #L1
#self._lg_altH.addVariable("altHold.vSpeed", "float") #L2
#self._lg_altH.addVariable("altHold.target", "float") #L3
self._cf.log.add_config(self._lg_altH)
if self._lg_altH.valid:
# This callback will receive the data
self._lg_altH.data_received_cb.add_callback(self._log_altH_data)
# This callback will be called on errors
self._lg_altH.error_cb.add_callback(self._log_error)
# Start the logging
self._lg_altH.start()
else:
print("Could not add logconfig since some variables are not in TOC")
########################################################################
# Set up Acc Logger
########################################################################
self._lg_acc = LogConfig(name="Acc", period_in_ms=50)
self._lg_acc.add_variable("acc.x", "float")
self._lg_acc.add_variable("acc.y", "float")
self._lg_acc.add_variable("acc.z", "float")
self._cf.log.add_config(self._lg_acc)
if self._lg_acc.valid:
# This callback will receive the data
self._lg_acc.data_received_cb.add_callback(self._log_acc_data)
# This callback will be called on errors
self._lg_acc.error_cb.add_callback(self._log_error)
# Start the logging
self._lg_acc.start()
else:
print("Could not add logconfig since some variables are not in TOC")
def _log_altH_data(self, timestamp, data, logconf):
"""Callback froma the log API when data arrives"""
global a_hold_z, a_hold_v, a_hold_t
(a_hold_z, a_hold_v, a_hold_t) = (data["altHold.zSpeed"], data["altHold.vSpeed"], data["altHold.target"])
def _log_acc_data(self, timestamp, data, logconf):
"""Callback froma the log API when data arrives"""
global g_acc_x, g_acc_y, g_acc_z;
(g_acc_x, g_acc_y, g_acc_z) = (data["acc.x"], data["acc.y"], data["acc.z"])
etc
etc
print "acc.x,y,z=%.3f,%.3f,%.3f" % (g_acc_x, g_acc_y, g_acc_z)
etc
When executing the program, the output is
acc.x,y,z=-0.035,-0.010,1.085
(i.e the acc data are obtained)
with uncommented lines #L1 #L2 #L3 in setup Holder Logger (under the exact same conditions) the output is:
acc.x,y,z=0.000,0.000,0.000
(i.e. no altHold data but also no more acc data)
Why altHold (and motor) Log TOC do not behave like acc,baro,gyro, etc?
How/Why attempting to get the altHold(and motor) data affects the acc (and gyro,etc) data?
I am using CF2
Firmware: 1ab92e55c44b (CLEAN)
Sensors found
HMC5883L: 1
MS5611: 1
Sensors tests
HMC5883L: 1
MPU6500: 1
MS5611: 1