이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Synchronizing the data of 2 subdevices within 1 device.
조회 수: 5 (최근 30일)
이전 댓글 표시
Niels
2025년 6월 16일
I am currently trying to figure out how to Sync up my IMU data. Within this IMU there is an Accelerometer and Gyroscope that get data with 200Hz and an GNSS that gets data with 10Hz. The ultimate goal is using the script(when its done) for event detection. Within the GNSS data I get is a POSIX time and a 'timestamp[us]' in the IMU data is only the 'timestamp[us]. Does anyone have an idea on how I could manage to sync these two time variables so I can view real time events within matlab eventhough they have different frequencies.
답변 (1개)
Star Strider
2025년 6월 16일
I would copy both original data records to appropriate timetable arrays, and then use the synchronize function. It might be necessary to create POSIX time vlaues for the one that has only microseconds (IMU), so create the complete timestamp, or use only the 'seconds' data from the data (GNSS) with POSIX times.
댓글 수: 10
Niels
2025년 6월 18일
But since the to devices have different frequencies, i have way more datapoints from one of the 2. Wouldn't that create issues?
Star Strider
2025년 6월 18일
The synchronize function has ways to deal with those issues. You have to decide what to tell it to create the result you want.
I still suggest adding the date to the POSIX timestamps for the IMU data. That will make everything easier, and doing it is probably straightforward with the MATLAB datetime function.
Star Strider
2025년 6월 20일
If you posted examples of your files, I might be able to post an example of how to do all of this.
Adding the date information to the IMU data should be relatively straightforward.
With respect to interpolating the GNSS data, there are several options, however the two I sould recommend would be 'previous' (all 'missing' data subsequent to the first data instance repeat until the next data), or perhaps linear' to linearly interpolate between the data. It depends on how you want those data to be interpolated to fill the 'gaps'.
Niels
2025년 6월 20일
Hi, i created an example file. Line 1 through 500 is from the GNSS and line 501 till 1000 is from the IMU.
If you got the time and are still willing to try and help out i'd greatly appreciate that. If not, no worries.
If a differrent formate is preferred or needed, i could provide that(probably).
Star Strider
2025년 6월 20일
I need some clarification with respect to what you want to do with these data. Breaking the original file into two files, it appears that 'GNSS' has data that 'IMU' does not, although they both have the same variable names. That raises a different question, since 'time [POSIXms]' is different for IMU and GNSS. (They seem to simply be millisecond values, not actually POSIX formatted dates and times.) Converting them using seconds does not add much information.
How do you want to deal with these?
AllData = readtable('MatlabForum.xlsx', VariableNamingRule='preserve');
IMU = AllData(1:500,:)
IMU = 500×8 table
time [POSIXms] timestamp [us] latitude [deg] longitude [deg] speedN [m/s] speedE [m/s] speedD [m/s] altitude [m]
______________ ______________ ______________ _______________ ____________ ____________ ____________ ____________
1.7468e+12 1.403e+06 1 1 0 0 0 91317
1.7468e+12 1.5392e+06 1 1 0 0 0 91317
1.7468e+12 1.6392e+06 1 1 0 0 0 91317
1.7468e+12 1.7392e+06 1 1 0 0 0 91317
1.7468e+12 1.8382e+06 1 1 0 0 0 91317
1.7468e+12 1.9388e+06 1 1 0 0 0 91317
1.7468e+12 2.039e+06 1 1 0 0 0 91317
1.7468e+12 2.1388e+06 1 1 0 0 0 91317
1.7468e+12 2.2392e+06 1 1 0 0 0 91317
1.7468e+12 2.3382e+06 1 1 0 0 0 91317
1.7468e+12 2.4395e+06 1 1 0 0 0 91317
1.7468e+12 2.5392e+06 1 1 0 0 0 91317
1.7468e+12 2.638e+06 1 1 0 0 0 91317
1.7468e+12 2.7392e+06 1 1 0 0 0 91317
1.7468e+12 2.8402e+06 1 1 0 0 0 91317
1.7468e+12 2.9392e+06 1 1 0 0 0 91317
GNSS = AllData(501:end,:)
GNSS = 499×8 table
time [POSIXms] timestamp [us] latitude [deg] longitude [deg] speedN [m/s] speedE [m/s] speedD [m/s] altitude [m]
______________ ______________ ______________ _______________ ____________ ____________ ____________ ____________
8.455e+05 -0.41187 -0.11078 -0.23766 -35.7 77.28 159.32 NaN
8.505e+05 -0.97893 -0.24986 -0.55388 26.04 0.56 11.48 NaN
8.555e+05 -0.93159 -0.19959 -0.48995 17.64 -4.06 8.82 NaN
8.605e+05 -0.91012 -0.1747 -0.46604 60.48 -28.56 67.34 NaN
8.655e+05 -0.9067 -0.17129 -0.48214 -7 16.24 -19.32 NaN
8.705e+05 -0.90329 -0.1952 -0.49386 -3.64 16.1 -18.76 NaN
8.755e+05 -0.85937 -0.18739 -0.4675 -2.8 14.56 -20.3 NaN
8.805e+05 -0.8257 -0.19959 -0.42114 -4.2 16.52 -21.98 NaN
8.855e+05 -0.77494 -0.1747 -0.3577 7.42 18.2 -10.22 NaN
8.905e+05 -0.78861 -0.21228 -0.37625 5.88 20.44 -7.14 NaN
8.955e+05 -0.80032 -0.2196 -0.38454 4.2 23.1 -4.06 NaN
9.005e+05 -0.81301 -0.2113 -0.40797 2.52 24.5 -6.58 NaN
9.055e+05 -0.79788 -0.19666 -0.42846 2.1 26.6 -13.58 NaN
9.105e+05 -0.79202 -0.26303 -0.47238 0 30.38 -16.1 NaN
9.155e+05 -0.79007 -0.31964 -0.54363 -4.48 34.02 -12.74 NaN
9.205e+05 -0.78763 -0.35819 -0.54266 -0.98 40.74 -8.54 NaN
GNSS_POSIX = seconds(GNSS{:,1});
[GNSS_start,GNSS_end] = bounds(GNSS_POSIX)
GNSS_start = duration
8.455e+05 sec
GNSS_end = duration
3.336e+06 sec
IMU_POSIX = seconds(IMU{:,1});
[IMU_start,IMU_end] = bounds(IMU_POSIX)
IMU_start = duration
1.7468e+12 sec
IMU_end = duration
1.7468e+12 sec
VNIMU = IMU.Properties.VariableNames
VNIMU = 1×8 cell array
{'time [POSIXms]'} {'timestamp [us]'} {'latitude [deg]'} {'longitude [deg]'} {'speedN [m/s]'} {'speedE [m/s]'} {'speedD [m/s]'} {'altitude [m]'}
VNGNSS = GNSS.Properties.VariableNames
VNGNSS = 1×8 cell array
{'time [POSIXms]'} {'timestamp [us]'} {'latitude [deg]'} {'longitude [deg]'} {'speedN [m/s]'} {'speedE [m/s]'} {'speedD [m/s]'} {'altitude [m]'}
VNCommon = intersect(VNIMU, VNGNSS, 'stable')
VNCommon = 1×8 cell array
{'time [POSIXms]'} {'timestamp [us]'} {'latitude [deg]'} {'longitude [deg]'} {'speedN [m/s]'} {'speedE [m/s]'} {'speedD [m/s]'} {'altitude [m]'}
.
Niels
2025년 6월 20일
I'd assume that both the GNSS and the IMU start collecting data at the same time since they are both within the same device. So maybe you could assume that the first data point of the IMU has the same POSIX value..
Star Strider
2025년 6월 20일
I am also a bit confused with the timestamps. If they are in the same device (and I assume using the same clock), the times should be similar. The GNSS data has negative microsecond timestamps. I am not sure how to combine the times (millisecond and microsecond) and have them resemble each other. They do not seem to overlap.
We need to resolve the inconsistencies in the time values (ms and us) in the two records in order to proceed with this, since synchronzing them is the primary issue. We can then resolve ow to combine or interpolate the longitude, latitude, altitude, velocity and any others.
I do not have access to your instrumentation or how it reports the time values. I may be able help resolve this, however I need to understand how your instrumentation reports the relevant time values for the two records.
I also assume that the latitude, longitude, velocities, altitude, and such should be the same for equivalent times for both records.
AllData = readtable('MatlabForum.xlsx', VariableNamingRule='preserve');
IMU = AllData(1:500,:)
IMU = 500×8 table
time [POSIXms] timestamp [us] latitude [deg] longitude [deg] speedN [m/s] speedE [m/s] speedD [m/s] altitude [m]
______________ ______________ ______________ _______________ ____________ ____________ ____________ ____________
1.7468e+12 1.403e+06 1 1 0 0 0 91317
1.7468e+12 1.5392e+06 1 1 0 0 0 91317
1.7468e+12 1.6392e+06 1 1 0 0 0 91317
1.7468e+12 1.7392e+06 1 1 0 0 0 91317
1.7468e+12 1.8382e+06 1 1 0 0 0 91317
1.7468e+12 1.9388e+06 1 1 0 0 0 91317
1.7468e+12 2.039e+06 1 1 0 0 0 91317
1.7468e+12 2.1388e+06 1 1 0 0 0 91317
1.7468e+12 2.2392e+06 1 1 0 0 0 91317
1.7468e+12 2.3382e+06 1 1 0 0 0 91317
1.7468e+12 2.4395e+06 1 1 0 0 0 91317
1.7468e+12 2.5392e+06 1 1 0 0 0 91317
1.7468e+12 2.638e+06 1 1 0 0 0 91317
1.7468e+12 2.7392e+06 1 1 0 0 0 91317
1.7468e+12 2.8402e+06 1 1 0 0 0 91317
1.7468e+12 2.9392e+06 1 1 0 0 0 91317
GNSS = AllData(501:end,:)
GNSS = 499×8 table
time [POSIXms] timestamp [us] latitude [deg] longitude [deg] speedN [m/s] speedE [m/s] speedD [m/s] altitude [m]
______________ ______________ ______________ _______________ ____________ ____________ ____________ ____________
8.455e+05 -0.41187 -0.11078 -0.23766 -35.7 77.28 159.32 NaN
8.505e+05 -0.97893 -0.24986 -0.55388 26.04 0.56 11.48 NaN
8.555e+05 -0.93159 -0.19959 -0.48995 17.64 -4.06 8.82 NaN
8.605e+05 -0.91012 -0.1747 -0.46604 60.48 -28.56 67.34 NaN
8.655e+05 -0.9067 -0.17129 -0.48214 -7 16.24 -19.32 NaN
8.705e+05 -0.90329 -0.1952 -0.49386 -3.64 16.1 -18.76 NaN
8.755e+05 -0.85937 -0.18739 -0.4675 -2.8 14.56 -20.3 NaN
8.805e+05 -0.8257 -0.19959 -0.42114 -4.2 16.52 -21.98 NaN
8.855e+05 -0.77494 -0.1747 -0.3577 7.42 18.2 -10.22 NaN
8.905e+05 -0.78861 -0.21228 -0.37625 5.88 20.44 -7.14 NaN
8.955e+05 -0.80032 -0.2196 -0.38454 4.2 23.1 -4.06 NaN
9.005e+05 -0.81301 -0.2113 -0.40797 2.52 24.5 -6.58 NaN
9.055e+05 -0.79788 -0.19666 -0.42846 2.1 26.6 -13.58 NaN
9.105e+05 -0.79202 -0.26303 -0.47238 0 30.38 -16.1 NaN
9.155e+05 -0.79007 -0.31964 -0.54363 -4.48 34.02 -12.74 NaN
9.205e+05 -0.78763 -0.35819 -0.54266 -0.98 40.74 -8.54 NaN
GNSS_Time = GNSS{:,1}*1E-3+GNSS{:,2}*1E-6; % Convert To 'seconds'
[GNSS_start,GNSS_end] = bounds(GNSS_Time)
GNSS_start = 845.5000
GNSS_end = 3.3360e+03
GNSS_Timespan = GNSS_end - GNSS_start
GNSS_Timespan = 2.4905e+03
IMU_Time = IMU{:,1}*1E-3+IMU{:,2}*1E-6; % Convert To 'seconds'
[IMU_start,IMU_end] = bounds(IMU_Time)
IMU_start = 1.7468e+09
IMU_end = 1.7468e+09
IMU_Timespan = IMU_end - IMU_start
IMU_Timespan = 97.5680
.
Star Strider
2025년 6월 21일
@Niels -- Having the documentation for your instrumentation with respect to how it calculates and assigns the time data for both the IMU and GNSS records would help solve this.
Please post the relevant sections of the .pdf documentation, or the entire .pdf documentation if it is not voluminous (that is, fits the Answers file size limits).
Niels
2025년 6월 23일
Yeah that is where my issue started, the documentation that I have says nothing about the calculation or the gathering of the data from the device itself.. I've mailed the company trying to get anything like that tho.
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
