Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
c-astral-wrapper
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
c-astral-wrapper
Commits
e78a3ad4
Commit
e78a3ad4
authored
Sep 25, 2023
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use cap_status_frequent to know utc time at boot
parent
1eb708b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
mavsdk_wrapper.cpp
mavsdk_wrapper.cpp
+14
-5
No files found.
mavsdk_wrapper.cpp
View file @
e78a3ad4
...
...
@@ -45,7 +45,7 @@ static const double SIN_ADDED_DISTANCE = sin(ADDED_DISTANCE);
static
int
mavsdk_started
=
0
;
static
Telemetry
::
Position
origin
;
static
int64_t
current_position
[
POSITION_ARRAY_SIZE
]
=
{
0
};
static
int64_t
timestamp_difference
=
0
;
static
int64_t
utc_time_at_boot
=
0
;
static
Coordinates
targeted_destination
;
static
float
targeted_radius
=
DEFAULT_RADIUS
;
...
...
@@ -283,18 +283,27 @@ int start(const char * ip, int port, const char * log_file, int timeout) {
action
=
new
Action
(
msystem
);
mavlink_passthrough
=
new
MavlinkPassthrough
(
msystem
);
mavlink_passthrough
->
subscribe_message_async
(
MAVLINK_MSG_ID_CAP_STATUS_FREQUENT
,
[](
const
mavlink_message_t
&
message
)
{
mavlink_cap_status_frequent_t
time
;
mavlink_msg_cap_status_frequent_decode
(
&
message
,
&
time
);
if
(
abs
((
long
long
int
)
time
.
utc_time
-
getTimestamp
())
<
1
)
{
utc_time_at_boot
=
time
.
utc_time
-
time
.
time_boot_ms
;
mavlink_passthrough
->
subscribe_message_async
(
MAVLINK_MSG_ID_CAP_STATUS_FREQUENT
,
nullptr
);
}
else
{
printf
(
"gps time %lu clock time %lld
\n
"
,
time
.
utc_time
,
getTimestamp
());
}
});
mavlink_passthrough
->
subscribe_message_async
(
MAVLINK_MSG_ID_GLOBAL_POSITION_INT
,
[](
const
mavlink_message_t
&
message
)
{
mavlink_global_position_int_t
position
;
mavlink_msg_global_position_int_decode
(
&
message
,
&
position
);
if
(
timestamp_difference
==
0
)
timestamp_difference
=
getTimestamp
()
-
position
.
time_boot_ms
;
current_position
[
0
]
=
position
.
lat
;
current_position
[
1
]
=
position
.
lon
;
current_position
[
2
]
=
position
.
alt
;
current_position
[
3
]
=
position
.
relative_alt
;
current_position
[
4
]
=
position
.
time_boot_ms
+
timestamp_difference
;
current_position
[
4
]
=
position
.
time_boot_ms
+
utc_time_at_boot
;
});
do
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment