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
e93d3a18
Commit
e93d3a18
authored
Aug 29, 2023
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop using blocking overrides
parent
96b86d57
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
18 deletions
+24
-18
mavsdk_wrapper.cpp
mavsdk_wrapper.cpp
+24
-18
No files found.
mavsdk_wrapper.cpp
View file @
e93d3a18
...
@@ -45,6 +45,10 @@ static Telemetry::Position origin;
...
@@ -45,6 +45,10 @@ static Telemetry::Position origin;
static
Coordinates
targeted_destination
;
static
Coordinates
targeted_destination
;
static
Coordinates
projected_destination
;
static
Coordinates
projected_destination
;
static
const
float
DEFAULT_SPEED
=
16
;
static
float
last_override_altitude
;
static
float
last_override_speed
;
// Logs functions
// Logs functions
static
void
log
(
std
::
string
message
)
{
static
void
log
(
std
::
string
message
)
{
...
@@ -230,6 +234,8 @@ int start(const char * ip, int port, const char * log_file, int timeout) {
...
@@ -230,6 +234,8 @@ int start(const char * ip, int port, const char * log_file, int timeout) {
}
while
(
isnan
(
abs_altitude
)
||
abs_altitude
==
0
);
}
while
(
isnan
(
abs_altitude
)
||
abs_altitude
==
0
);
origin
=
telemetry
->
position
();
origin
=
telemetry
->
position
();
last_override_altitude
=
origin
.
absolute_altitude_m
;
last_override_speed
=
DEFAULT_SPEED
;
log
(
"MAVSDK started..."
);
log
(
"MAVSDK started..."
);
mavsdk_started
=
1
;
mavsdk_started
=
1
;
...
@@ -289,7 +295,8 @@ int takeOffAndWait(void) {
...
@@ -289,7 +295,8 @@ int takeOffAndWait(void) {
while
(
telemetry
->
flight_mode
()
==
Telemetry
::
FlightMode
::
Takeoff
)
while
(
telemetry
->
flight_mode
()
==
Telemetry
::
FlightMode
::
Takeoff
)
sleep_for
(
seconds
(
1
));
sleep_for
(
seconds
(
1
));
return
doAction
(
&
Action
::
transition_to_fixedwing
,
"Transition to fixedwing failed"
);
return
doAction
(
&
Action
::
transition_to_fixedwing
,
"Transition to fixedwing failed"
);
}
}
int
triggerParachute
(
void
)
{
int
triggerParachute
(
void
)
{
...
@@ -299,7 +306,8 @@ int triggerParachute(void) {
...
@@ -299,7 +306,8 @@ int triggerParachute(void) {
log
(
"Landing..."
);
log
(
"Landing..."
);
MavlinkPassthrough
::
CommandLong
command
;
MavlinkPassthrough
::
CommandLong
command
;
command
.
command
=
MAV_CMD_DO_PARACHUTE
;
command
.
command
=
MAV_CMD_DO_PARACHUTE
;
command
.
param1
=
2
;
//see https://mavlink.io/en/messages/common.html#PARACHUTE_ACTION
//see https://mavlink.io/en/messages/common.html#PARACHUTE_ACTION
command
.
param1
=
2
;
command
.
target_sysid
=
mavlink_passthrough
->
get_target_sysid
();
command
.
target_sysid
=
mavlink_passthrough
->
get_target_sysid
();
command
.
target_compid
=
mavlink_passthrough
->
get_target_compid
();
command
.
target_compid
=
mavlink_passthrough
->
get_target_compid
();
return
doMavlinkCommand
(
command
,
"Parachute release failed"
);
return
doMavlinkCommand
(
command
,
"Parachute release failed"
);
...
@@ -307,19 +315,25 @@ int triggerParachute(void) {
...
@@ -307,19 +315,25 @@ int triggerParachute(void) {
// Flight management functions
// Flight management functions
static
int
setAltitude
(
float
altitude
)
{
static
int
doOverride
(
float
altitude
,
float
speed
,
const
char
*
failure_msg
)
{
if
(
!
mavsdk_started
)
if
(
!
mavsdk_started
)
return
-
1
;
return
-
1
;
MavlinkPassthrough
::
CommandLong
command
;
MavlinkPassthrough
::
CommandLong
command
;
command
.
command
=
MAV_CMD_DO_OVERRIDE
;
command
.
command
=
MAV_CMD_DO_OVERRIDE
;
command
.
param1
=
1
|
2
|
4
|
8
;
command
.
param1
=
1
|
2
|
4
|
8
;
command
.
param2
=
1
|
2
|
8
;
command
.
param2
=
1
|
2
|
4
|
8
;
command
.
param3
=
altitude
;
command
.
param3
=
altitude
;
command
.
param4
=
speed
;
command
.
target_sysid
=
mavlink_passthrough
->
get_target_sysid
();
command
.
target_sysid
=
mavlink_passthrough
->
get_target_sysid
();
command
.
target_compid
=
mavlink_passthrough
->
get_target_compid
();
command
.
target_compid
=
mavlink_passthrough
->
get_target_compid
();
return
doMavlinkCommand
(
command
,
"Setting altitude failed"
);
return
doMavlinkCommand
(
command
,
failure_msg
);
}
static
int
setAltitude
(
float
altitude
)
{
last_override_altitude
=
altitude
;
return
doOverride
(
altitude
,
last_override_speed
,
"Setting altitude failed"
);
}
}
int
loiter
(
double
la
,
double
lo
,
float
a
,
float
radius
)
{
int
loiter
(
double
la
,
double
lo
,
float
a
,
float
radius
)
{
...
@@ -329,18 +343,9 @@ int loiter(double la, double lo, float a, float radius) {
...
@@ -329,18 +343,9 @@ int loiter(double la, double lo, float a, float radius) {
}
}
int
setAirSpeed
(
float
airspeed
)
{
int
setAirSpeed
(
float
airspeed
)
{
if
(
!
mavsdk_started
)
last_override_speed
=
airspeed
;
return
-
1
;
return
doOverride
(
last_override_altitude
,
airspeed
,
"Setting airspeed failed"
);
MavlinkPassthrough
::
CommandLong
command
;
command
.
command
=
MAV_CMD_DO_OVERRIDE
;
command
.
param1
=
1
|
2
|
4
|
8
;
command
.
param2
=
2
|
4
|
8
;
command
.
param4
=
airspeed
;
command
.
target_sysid
=
mavlink_passthrough
->
get_target_sysid
();
command
.
target_compid
=
mavlink_passthrough
->
get_target_compid
();
return
doMavlinkCommand
(
command
,
"Setting airspeed failed"
);
}
}
int
setTargetCoordinates
(
double
la
,
double
lo
,
float
a
)
{
int
setTargetCoordinates
(
double
la
,
double
lo
,
float
a
)
{
...
@@ -399,7 +404,8 @@ double *getPositionArray(void) {
...
@@ -399,7 +404,8 @@ double *getPositionArray(void) {
float
*
getSpeedArray
(
void
)
{
float
*
getSpeedArray
(
void
)
{
Telemetry
::
FixedwingMetrics
metrics
=
telemetry
->
fixedwing_metrics
();
Telemetry
::
FixedwingMetrics
metrics
=
telemetry
->
fixedwing_metrics
();
float
*
speedArray
=
(
float
*
)
malloc
(
SPEED_ARRAY_SIZE
*
sizeof
(
float
));
float
*
speedArray
=
(
float
*
)
malloc
(
SPEED_ARRAY_SIZE
*
sizeof
(
float
));
speedArray
[
0
]
=
getYaw
();
speedArray
[
0
]
=
getYaw
();
speedArray
[
1
]
=
metrics
.
airspeed_m_s
;
speedArray
[
1
]
=
metrics
.
airspeed_m_s
;
speedArray
[
2
]
=
metrics
.
climb_rate_m_s
;
speedArray
[
2
]
=
metrics
.
climb_rate_m_s
;
...
...
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