現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
Synchronizing the data of 2 subdevices within 1 device.
4 ビュー (過去 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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)
