Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MechaRaptor - Data Processing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Aerospace and Mechanical Engineering
tlambert
MechaRaptor - Data Processing
Commits
03f2d8cc
Unverified
Commit
03f2d8cc
authored
2 years ago
by
Thomas Lambert
Browse files
Options
Downloads
Patches
Plain Diff
feat(loadardu): base implementation of loadardu
parent
c785467d
No related branches found
No related tags found
No related merge requests found
Pipeline
#10583
failed
2 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
loadardu.m
+93
-0
93 additions, 0 deletions
loadardu.m
with
93 additions
and
0 deletions
loadardu.m
0 → 100644
+
93
−
0
View file @
03f2d8cc
function
arduData
=
loadardu
(
arduFile
)
% LOADARDU Load the Arduino data and clean it.
% This function loads the Arduino data. Then it:
% - removes the unneeded columns
% - convert time into milliseconds
% - converts the output into an array instead of a table
% - calculates the power
% - re-aligns the angles properly from the raw wing positions
% -----
% Output format:
% The output array has one row per timestep. The columns are ordered as follows:
% angleFrontLeft, angleFrontRight, angleAftLeft, angleAftRight, powerFront, powerAft
%
% Syntax:
% arduData = loadardu(arduFile) load the Arduino data file, then clean it and return a cleaned
% version with only the relevant fields in form of an array.
%
% Inputs:
% arduFile: Arduino file.
%
% Outputs:
% arduData: Array with the cleaned data.
%
% See also: readdata.
% ----------------------------------------------------------------------------------------------
% TODO: Check for inconsistencies in the table
% ----------------------------------------------------------------------------------------------
% (c) Copyright 2022 University of Liege
% Author: Thomas Lambert <t.lambert@uliege.be>
% ULiege - Aeroelasticity and Experimental Aerodynamics
% MIT License
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load data
arduTable
=
table
;
if
~
isempty
(
arduFile
)
arduTable
=
loadcsv
([
'arduinoFiles/'
,
arduFile
,
'.csv'
]);
end
% Time conversion
arduTable
.
time
=
timetomilli
(
arduTable
.
time
);
% Remove data with duplicate timecode
[
~
,
idx
]
=
unique
(
arduTable
.
time
);
% indexes of unique timecodes
arduTable
=
arduTable
(
idx
,
:);
% Convert into table
arduData
=
table2array
(
arduTable
);
% Calculate power, remove tension and current
power
=
arduData
(:,
[
5
,
7
])
.*
arduData
(:,
[
6
,
8
]);
arduData
(:,
5
:
end
)
=
[];
arduData
=
[
arduData
,
power
];
% Recalculate angles properly
end
function
rawTable
=
loadcsv
(
file
)
% LOADCSV Load the csv into a table
% Tweak options before import
opts
=
detectImportOptions
(
file
);
opts
.
VariableNamesLine
=
1
;
opts
.
SelectedVariableNames
=
{
'x_RXDate_Time'
,
'x1_Left_field6_'
,
'x1_Right_field7_'
,
...
'x2_Left_field8_'
,
'x2_Right_field9_'
,
'x1_Tension_field14_'
,
...
'x1_Current_field15_'
,
'x2_Tension_field16_'
,
...
'x2_Current_field17_'
};
opts
.
DataLines
=
[
2
Inf
];
% Import
rawTable
=
readtable
(
file
,
opts
);
% Rename columns
rawTable
.
Properties
.
VariableNames
=
{
'time'
,
'angleFrontLeft'
,
'angleFrontRight'
,
...
'angleAftLeft'
,
'angleAftRight'
,
...
'tensionF'
,
'currentF'
,
'tensionA'
,
'currentA'
};
end
function
timeMilli
=
timetomilli
(
time
)
% TIMETOMILLI Converts datetime data into milliseconds since start
% Parse time properly
time
=
datetime
(
time
,
'InputFormat'
,
'uuuu/MM/dd
''
/
''
HH:mm:ss::SSS'
,
'TimeZone'
,
'UTC'
);
% Converts into difference from the first time
timeMilli
=
milliseconds
(
time
-
time
(
1
))
+
1
;
% Shift of 1 so first time is 1 millisecond
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment