altHold log problem

Firmware/software/electronics
Post Reply
ellesse
Beginner
Posts: 11
Joined: Thu Mar 26, 2015 10:35 am

altHold log problem

Post by ellesse »

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
marcus
Bitcraze
Posts: 659
Joined: Mon Jan 28, 2013 7:02 pm
Location: Sweden
Contact:

Re: altHold log problem

Post by marcus »

Hi,

From looking at the code everything seems ok. The important thing is that you cannot set up the logging before you have connected to the Crazyflie. But since it's working in the first case I assume you don't do this. Adding another log-block shouldn't effect other that are already added.

Could you switch on the DEBUG level for logging and paste the output from you application so we can get some more info?
ellesse
Beginner
Posts: 11
Joined: Thu Mar 26, 2015 10:35 am

Re: altHold log problem

Post by ellesse »

Thanks for the quick reply.
How do I switch to DEBUG. Do I need one of these:
http://www.seeedstudio.com/depot/Crazyf ... -2114.html

Is there another way to DEBUG?

Please note, I have tried the code on ifferent CF2s and I have the same results.
ellesse
Beginner
Posts: 11
Joined: Thu Mar 26, 2015 10:35 am

Re: altHold log problem

Post by ellesse »

I will try using
logging.basicConfig(level=logging.DEBUG)
instead of
logging.basicConfig(level=logging.ERROR)

and report back to you.
ellesse
Beginner
Posts: 11
Joined: Thu Mar 26, 2015 10:35 am

Re: altHold log problem

Post by ellesse »

Thanks for your help. Your DEBUG suggestion was very helpful.

I should have used:
self._lg_altH.add_variable(......

insead of (maybe taken from older version in the forum discussions??)
self._lg_altH.addVariable(....

Are there any more options other than ERROR and DEBUG for:
logging.basicConfig(level=logging.DEBUG)?
marcus
Bitcraze
Posts: 659
Joined: Mon Jan 28, 2013 7:02 pm
Location: Sweden
Contact:

Re: altHold log problem

Post by marcus »

Yes, add_variable is the new name (this was changed a while back from addVariable) so this could be the cause of your problems. Did you try changing it? Did it help?

As for ERROR/DEBUG there are more levels in between (like WARNING and INFO). For more information on the Python logging framework have a look at this link. There's also the option of adding more/less information to the printouts and also saving them to a file.
ellesse
Beginner
Posts: 11
Joined: Thu Mar 26, 2015 10:35 am

Re: altHold log problem

Post by ellesse »

Thanks for your prompt reply. Yes it works now (even if both altHold.err and altHold.target values are always zero...)
Post Reply