%% split betwen different sensors
% load('cycling_data')
% 
% % %trying to figure out the unit of measure of the time stamps
% % %total_time=time_stamps(length(time_stamps))-time_stamps(1) ;
% % %real_total_time=(6*60+15)*60;  %about 6 hours and 15 min expressed in seconds
% % %time_unit=real_total_time/total_time
% 
% time_stamps=(time_stamps-time_stamps(1))/1.0;
% 
% acc=[0,0,0,0];
% gyr=[0,0,0,0];
% gps=[0,0,0,0];
% 
% for k=1:length(time_stamps)
% 
%     if strcmp(sensor(k),'ACC')
%         acc=[acc;
%              time_stamps(k),a(k),b(k),c(k)];
%     end
%     
%     if strcmp(sensor(k),'GYR')
%         gyr=[gyr;
%              time_stamps(k),a(k),b(k),c(k)];
%     end
% 
%     if strcmp(sensor(k),'GPS')
%         gps=[gps;
%              time_stamps(k),a(k),b(k),c(k)];
%     end
%     
% end
% 
% acc=acc(2:length(acc),:);
% gyr=gyr(2:length(gyr),:);
% gps=gps(2:length(gps),:);

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% load('cycling_data_sensors')
% Input struct:
% in_data.GNSS.pos_ned      GNSS-receiver position estimates in NED
%                           coordinates [m]
% in_data.GNSS.t            Time of GNSS measurements [s]
% (in_data.GNSS.HDOP        GNSS Horizontal Dilution of Precision [-]) 
% (in_data.GNSS.VDOP        GNSS Vertical Dilution of Precision [-]) 
% in_data.IMU.acc           Accelerometer measurements [m/s^2]
% in_data.IMU.gyro          Gyroscope measurements [rad/s]
% in_data.IMU.t             Time of IMU measurements [s]

%from geodetic to cartesian GPS coordinates
% spheroid = referenceEllipsoid('GRS 80')
% [xNorth,yEast,zDown] = geodetic2ned(gps(5:length(gps),2),gps(5:length(gps),3),gps(5:length(gps),4),gps(4,2),gps(4,3),gps(4,4),spheroid)

% in_data.GNSS.pos_ned = [xNorth,yEast,zDown];
% in_data.GNSS.t=gps(5:length(gps),1)

%synchronize accelerometer and gyro data
% Gyr=gyr(1,2:4);
% Acc=acc(1,2:4);
% t=0;
% j=1; % to cycle over the gyro
% for i=1:length(acc) %cycle over the accelerometer
%     while gyr(j,1)<=acc(i,1)
%         %if the data are available and synchr then store them (with time)
%         if gyr(j,1)==acc(i,1)
%             Gyr=[Gyr;
%                  gyr(j,2:4)];
%             Acc=[Acc;
%                  acc(i,2:4)];
%             t=[t;gyr(j,1)];
%         end
%         j=j+1;
%     end
%     
%     %checkpoint for verifying progress
%     if ~mod(i,100000)
%         %display('sono arrivato al tempo:')
%         %t(j-1)
%         display('sono alla seguente riga delle accelerazioni(totale di 1901808):')
%         i
%     end
% end


% in_data.IMU.acc = Acc';
% in_data.IMU.gyro = Gyr';
% in_data.IMU.t = t;
% in_data.GNSS.pos_ned = Gps;
% in_data.GNSS.t = t_Gps;