You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to work with the data of the Crazyflie 2.0 IMU. Therefore i created a log with the microSD adapter. I converted the data to a csv and then to mat-file.
I also tried just changing foresign of y without swapping axes.
....loading data to script as row vectors (with size 3x13744) and convert to general ENU. Then transpose the vectors (required for Matlab Complementary filter)...
Fs = 250 %Hz
refFrame = 'ENU'
decim = 1;
cfToENU = [0 1 0;
-1 0 0;
0 0 1];
for i=1:length(acc)
acc(:,i) = cfToENU * acc(:,i);
gyro(:,i) = cfToENU * gyro(:,i);
end
acc = acc.' * 9.80665;
gyro = gyro.';
time = time.';
fuse = complementaryFilter('SampleRate',Fs, 'ReferenceFrame',refFrame, 'HasMagnetometer', false)
q = fuse(acc, gyro);
time = (0:decim:size(acc,1)-1)/Fs;
plot(time,eulerd(q,'ZYX','frame'))
title('Orientation Estimate')
legend('Z-axis', 'Y-axis', 'X-axis')
xlabel('Time (s)')
ylabel('Rotation (degrees)')
Output of plot is the following:
Estimation makes no sense 😢
Matlab Complementary works with data not from the crazyflie (direct in general ENU).
What is the correct way in Matlab to do the convert for crazyflie data created with microsd adapter?
I really need to reach general ENU notation.
Thank you very much in advance
Script i used for convert from crazyflie binary to csv is the following:
# -*- coding: utf-8 -*-
"""
Helper to decode binary logged sensor data from crazyflie2 with uSD-Card-Deck
and save the decoded data to CSV files.
Usage:
python3 usdlogToCSV.py log07 --output_folder out/
"""
import sys
import os
import argparse
import csv
sys.path.append('../../tools/usdlog/')
from cfusdlog import decode
def save_to_csv(decoded_data, input_filename, output_folder="output"):
"""
Save decoded log data to CSV files with the input filename as prefix.
Parameters:
- decoded_data: Dictionary containing decoded log data.
- input_filename: The original input filename (used for prefixing).
- output_folder: Directory where CSV files will be saved.
"""
# Ensure output directory exists
os.makedirs(output_folder, exist_ok=True)
# Extract the base filename (without extension) to use as a prefix
base_filename = os.path.splitext(os.path.basename(input_filename))[0]
for event_name, event_data in decoded_data.items():
# Set up the CSV file path with the prefix
output_file = os.path.join(output_folder, f"{base_filename}_{event_name}.csv")
try:
# Open and write data to the CSV file
with open(output_file, mode='w', newline='') as csvfile:
writer = csv.writer(csvfile)
# Write the header row
headers = ['timestamp'] + list(event_data.keys())
headers.remove('timestamp') # Avoid duplicate timestamp column
writer.writerow(headers)
# Write rows of data
rows = zip(event_data['timestamp'], *[event_data[k] for k in event_data if k != 'timestamp'])
writer.writerows(rows)
print(f"Saved {event_name} data to {output_file}")
except Exception as e:
print(f"Error saving {event_name} data to {output_file}: {e}")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("filename", help="Path to the binary log file")
parser.add_argument("--output_folder", default="output", help="Folder to save CSV files")
args = parser.parse_args()
try:
# Decode the log file
log_data = decode(args.filename)
if log_data:
# Save the decoded data to CSV files
save_to_csv(log_data, args.filename, args.output_folder)
else:
print("No data found in the log file to save.")
except FileNotFoundError:
print(f"File not found: {args.filename}")
except Exception as e:
print(f"An error occurred while processing the log file: {e}")
The correct plot done with crazyflie example.py looks exactly:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I need to work with the data of the Crazyflie 2.0 IMU. Therefore i created a log with the microSD adapter. I converted the data to a csv and then to mat-file.
When i now try to use Matlab Complementary Filter (https://de.mathworks.com/help/nav/ref/complementaryfilter-system-object.html) it always fails althrough I swapped x and y and changed the foresign of y also known as theta (to fit in general ENU instead of Crazyflie ENU).
I also tried just changing foresign of y without swapping axes.
Output of plot is the following:
Estimation makes no sense 😢
Matlab Complementary works with data not from the crazyflie (direct in general ENU).
What is the correct way in Matlab to do the convert for crazyflie data created with microsd adapter?
I really need to reach general ENU notation.
Thank you very much in advance
Script i used for convert from crazyflie binary to csv is the following:
The correct plot done with crazyflie example.py looks exactly:
Beta Was this translation helpful? Give feedback.
All reactions