Johnnie
(Johnnie)
February 27, 2019, 2:01pm
1
Hey,
I am trying to get the GPS time to sync my MCU on the fly.
In all GPS messages i receiving the time since the boot (instead of UNIX Epoch time)
I have GPS signal (i see 10 satellites)
how can i get the GPS time (us) via Mavlink
moobsen
(Moobsen)
February 27, 2019, 8:28pm
2
While I have never used it, according to the mavlink specification message #232 might contain what you are looking for.
https://mavlink.io/en/messages/common.html#GPS_INPUT
time_week_ms -> GPS time (from start of GPS week) [ms]
time_week -> GPS week number
The GPS time is contained in the GPS_RAW_INT message.
NOT on the GPS_INPUT message, that one is meant as time/pos input, not as time/position output.
moobsen
(Moobsen)
February 28, 2019, 11:28am
4
Hm OK.
Yet I don’t see he time_week and time_week_ms fields in GPS_RAW_INT
https://mavlink.io/en/messages/common.html#GPS_RAW_INT
<field type="uint16_t" name="param_index">Index of this onboard parameter</field>
</message>
<message id="23" name="PARAM_SET">
<description>Set a parameter value (write new value to permanent storage). IMPORTANT: The receiving component should acknowledge the new parameter value by sending a PARAM_VALUE message to all communication partners. This will also ensure that multiple GCS all have an up-to-date list of all parameters. If the sending GCS did not receive a PARAM_VALUE message within its timeout time, it should re-send the PARAM_SET message.</description>
<field type="uint8_t" name="target_system">System ID</field>
<field type="uint8_t" name="target_component">Component ID</field>
<field type="char[16]" name="param_id">Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string</field>
<field type="float" name="param_value">Onboard parameter value</field>
<field type="uint8_t" name="param_type" enum="MAV_PARAM_TYPE">Onboard parameter type.</field>
</message>
<message id="24" name="GPS_RAW_INT">
<description>The global position, as returned by the Global Positioning System (GPS). This is
NOT the global position estimate of the system, but rather a RAW sensor value. See message GLOBAL_POSITION for the global position estimate.</description>
<field type="uint64_t" name="time_usec" units="us">Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.</field>
<field type="uint8_t" name="fix_type" enum="GPS_FIX_TYPE">GPS fix type.</field>
<field type="int32_t" name="lat" units="degE7">Latitude (WGS84, EGM96 ellipsoid)</field>
<field type="int32_t" name="lon" units="degE7">Longitude (WGS84, EGM96 ellipsoid)</field>
<field type="int32_t" name="alt" units="mm">Altitude (MSL). Positive for up. Note that virtually all GPS modules provide the MSL altitude in addition to the WGS84 altitude.</field>
<field type="uint16_t" name="eph">GPS HDOP horizontal dilution of position (unitless). If unknown, set to: UINT16_MAX</field>
<field type="uint16_t" name="epv">GPS VDOP vertical dilution of position (unitless). If unknown, set to: UINT16_MAX</field>
<field type="uint16_t" name="vel" units="cm/s">GPS ground speed. If unknown, set to: UINT16_MAX</field>
I guess this not part of the MAVLINK Common Message Set.
Have you looked at SYSTEM_TIME?