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
291edd3e
Commit
291edd3e
authored
Sep 05, 2023
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix loiter
Stop projecting destination
parent
6155425e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
26 deletions
+42
-26
mavsdk_wrapper.cpp
mavsdk_wrapper.cpp
+42
-26
No files found.
mavsdk_wrapper.cpp
View file @
291edd3e
...
...
@@ -48,12 +48,15 @@ static int64_t current_position[POSITION_ARRAY_SIZE] = {0};
static
int64_t
timestamp_difference
=
0
;
static
Coordinates
targeted_destination
;
static
float
targeted_radius
=
DEFAULT_RADIUS
;
static
Coordinates
projected_destination
;
static
const
float
DEFAULT_SPEED
=
16
;
static
float
last_override_altitude
;
static
float
last_override_speed
;
static
bool
do_projection
=
false
;
// Logs functions
static
void
log
(
std
::
string
message
)
{
...
...
@@ -181,6 +184,31 @@ static long long int getTimestamp() {
return
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
now
.
time_since_epoch
()).
count
();
}
static
int
doOverride
(
float
altitude
,
float
speed
,
const
char
*
failure_msg
)
{
if
(
!
mavsdk_started
)
return
-
1
;
MavlinkPassthrough
::
CommandLong
command
;
command
.
command
=
MAV_CMD_DO_OVERRIDE
;
command
.
param1
=
1
|
2
|
4
|
8
;
command
.
param2
=
1
|
2
|
4
|
8
;
command
.
param3
=
altitude
;
command
.
param4
=
speed
;
command
.
target_sysid
=
mavlink_passthrough
->
get_target_sysid
();
command
.
target_compid
=
mavlink_passthrough
->
get_target_compid
();
return
doMavlinkCommand
(
command
,
failure_msg
);
}
static
int
setAltitude
(
float
altitude
)
{
last_override_altitude
=
altitude
;
return
doOverride
(
altitude
,
last_override_speed
,
"Setting altitude failed"
);
}
static
void
setAltitude_async
(
float
altitude
)
{
std
::
thread
(
setAltitude
,
altitude
).
detach
();
}
void
updateLogAndProjection
(
void
)
{
std
::
ostringstream
oss
;
Telemetry
::
FixedwingMetrics
metrics
;
...
...
@@ -194,8 +222,15 @@ void updateLogAndProjection(void) {
<<
metrics
.
airspeed_m_s
<<
";"
<<
metrics
.
climb_rate_m_s
;
log
(
oss
.
str
());
if
(
projected_destination
.
latitude
!=
0
||
targeted_destination
.
latitude
!=
0
)
{
if
(
do_projection
)
{
updateProjection
(
current_position
[
0
],
current_position
[
1
]);
}
else
{
doReposition_async
(
(
float
)
targeted_destination
.
latitude
,
(
float
)
targeted_destination
.
longitude
,
targeted_radius
,
0
);
}
}
}
...
...
@@ -341,32 +376,12 @@ int triggerParachute(void) {
// Flight management functions
static
int
doOverride
(
float
altitude
,
float
speed
,
const
char
*
failure_msg
)
{
if
(
!
mavsdk_started
)
return
-
1
;
MavlinkPassthrough
::
CommandLong
command
;
command
.
command
=
MAV_CMD_DO_OVERRIDE
;
command
.
param1
=
1
|
2
|
4
|
8
;
command
.
param2
=
1
|
2
|
4
|
8
;
command
.
param3
=
altitude
;
command
.
param4
=
speed
;
command
.
target_sysid
=
mavlink_passthrough
->
get_target_sysid
();
command
.
target_compid
=
mavlink_passthrough
->
get_target_compid
();
return
doMavlinkCommand
(
command
,
failure_msg
);
}
static
int
setAltitude
(
float
altitude
)
{
last_override_altitude
=
altitude
;
return
doOverride
(
altitude
,
last_override_speed
,
"Setting altitude failed"
);
}
static
void
setAltitude_async
(
float
altitude
)
{
std
::
thread
(
setAltitude
,
altitude
).
detach
();
}
void
loiter
(
double
la
,
double
lo
,
float
a
,
float
radius
)
{
targeted_destination
.
latitude
=
la
;
targeted_destination
.
longitude
=
lo
;
targeted_radius
=
radius
;
do_projection
=
false
;
doReposition_async
((
float
)
la
,
(
float
)
lo
,
radius
,
0
);
setAltitude_async
(
a
);
}
...
...
@@ -389,6 +404,7 @@ void setTargetCoordinates(double la, double lo, float a) {
targeted_destination
.
latitude
=
la
;
targeted_destination
.
longitude
=
lo
;
do_projection
=
true
;
updateProjection
(
current_position
[
0
],
current_position
[
1
]);
setAltitude_async
(
a
);
...
...
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