Logging Sensor Data with Python IDLE
Posted: Fri Mar 30, 2018 4:57 am
Hello,
I am currently trying to create a simple Python code which will instruct the Crazyflie to perform some basic flight maneuvers and store some sensor data from the flight in a separate file. I have already been able to program the flight maneuvers and am now attempting to add the data storage capability to my code. To learn to do this, I have been looking at the basiclog.py and basiclogSync.py examples, but I have been unable to get them to work and I have a few questions about them.
First of all, why do both the basiclog.py and basiclogSync.py examples exist? They both seem to serve the exact same purpose. Obviously basiclogSync.py utilizes the SyncCrazyflie and SyncLogger classes while basiclog.py does not, which leads to drastic changes in the code, but the overall function of the code seems the same nonetheless. Is there a specific reason for the existence of both of these codes, rather than just one general purpose logging function?
Secondly, when connecting to the Crazyflie at the beginning of the code, why don't the logging examples use the URI? The flight examples I have been using (flowsequenceSync.py and the example given on the "Getting Started with STEM Bundle" tutorial) use the URI to connect, but the logging examples seem to scan any nearby Crazyflies, store them in a struct, and then access sensor data for the first one scanned. Is there a reason for this?
Finally, and most importantly, when I attempt to run either example (basiclog.py or basiclogSync.py), the process of attempting to connect to the Crazyflie outputs an error saying "Cannot find a Crazyradio Dongle." This confuses me because the Crazyradio works perfectly fine when executing the flight examples, but evidently not while executing the logging examples. This is why I asked about the difference between using the specific URI to connect to the Crazyflie in comparison to using "cflib.crtp.scan_interfaces()" to scan nearby drones. There must be some difference between the flight examples and logging examples which causes the radio to properly function on the former but not on the latter. Any idea what this could be?
Thanks so much for your time!
EDIT:
Managed to get the sensor data printed by replacing all instances of 'available[0][0]' with 'URI'. Am now working on writing it to a file.
If the data from the log_entry is output as a string, how do you write it to a spreadsheet?
I am currently trying to create a simple Python code which will instruct the Crazyflie to perform some basic flight maneuvers and store some sensor data from the flight in a separate file. I have already been able to program the flight maneuvers and am now attempting to add the data storage capability to my code. To learn to do this, I have been looking at the basiclog.py and basiclogSync.py examples, but I have been unable to get them to work and I have a few questions about them.
First of all, why do both the basiclog.py and basiclogSync.py examples exist? They both seem to serve the exact same purpose. Obviously basiclogSync.py utilizes the SyncCrazyflie and SyncLogger classes while basiclog.py does not, which leads to drastic changes in the code, but the overall function of the code seems the same nonetheless. Is there a specific reason for the existence of both of these codes, rather than just one general purpose logging function?
Secondly, when connecting to the Crazyflie at the beginning of the code, why don't the logging examples use the URI? The flight examples I have been using (flowsequenceSync.py and the example given on the "Getting Started with STEM Bundle" tutorial) use the URI to connect, but the logging examples seem to scan any nearby Crazyflies, store them in a struct, and then access sensor data for the first one scanned. Is there a reason for this?
Finally, and most importantly, when I attempt to run either example (basiclog.py or basiclogSync.py), the process of attempting to connect to the Crazyflie outputs an error saying "Cannot find a Crazyradio Dongle." This confuses me because the Crazyradio works perfectly fine when executing the flight examples, but evidently not while executing the logging examples. This is why I asked about the difference between using the specific URI to connect to the Crazyflie in comparison to using "cflib.crtp.scan_interfaces()" to scan nearby drones. There must be some difference between the flight examples and logging examples which causes the radio to properly function on the former but not on the latter. Any idea what this could be?
Thanks so much for your time!
EDIT:
Managed to get the sensor data printed by replacing all instances of 'available[0][0]' with 'URI'. Am now working on writing it to a file.
If the data from the log_entry is output as a string, how do you write it to a spreadsheet?