Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Toggle main menu visibility
Main Page
Related Pages
Topics
Data Structures
Data Structures
Data Structure Index
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
m
n
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
v
w
z
Enumerator
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
Loading...
Searching...
No Matches
copilot_common.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2016 2017 Michal Podhradsky <http://github.com/podhrmic>
3
*
4
* This file is part of paparazzi.
5
*
6
* paparazzi is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
9
* any later version.
10
*
11
* paparazzi is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with paparazzi; see the file COPYING. If not, write to
18
* the Free Software Foundation, 59 Temple Place - Suite 330,
19
* Boston, MA 02111-1307, USA.
20
*
21
*/
44
#include "
modules/mission/copilot.h
"
45
#include "
modules/datalink/telemetry.h
"
46
47
bool
send_cam_snapshot
;
48
bool
send_cam_payload
;
49
bool
send_copilot_status
;
50
51
struct
CameraPayload
cam_payload
;
52
struct
CameraSnapshot
cam_snapshot
;
53
struct
CopilotStatus
copilot_status
;
54
55
pprz_mutex_t
copilot_cam_snapshot_mtx
;
56
pprz_mutex_t
copilot_cam_payload_mtx
;
57
pprz_mutex_t
copilot_status_mtx
;
58
60
void
copilot_init
(
void
)
61
{
62
send_cam_snapshot
=
false
;
63
send_cam_payload
=
false
;
64
send_copilot_status
=
false
;
65
66
memset
(&
cam_payload
, 0,
sizeof
(
cam_payload
));
67
memset
(&
cam_snapshot
, 0,
sizeof
(
cam_snapshot
));
68
memset
(&
copilot_status
, 0,
sizeof
(
copilot_status
));
69
70
pprz_mtx_init
(&
copilot_cam_snapshot_mtx
);
71
pprz_mtx_init
(&
copilot_cam_payload_mtx
);
72
pprz_mtx_init
(&
copilot_status_mtx
);
73
}
60
void
copilot_init
(
void
) {
…
}
74
76
void
copilot_periodic
(
void
)
77
{
78
pprz_mtx_lock
(&
copilot_cam_snapshot_mtx
);
79
if
(
send_cam_snapshot
) {
80
// send down to GCS
81
DOWNLINK_SEND_CAMERA_SNAPSHOT
(
DefaultChannel
,
DefaultDevice
,
82
&
cam_snapshot
.
cam_id
, &
cam_snapshot
.
cam_state
,
83
&
cam_snapshot
.
snapshot_num
, &
cam_snapshot
.
snapshot_valid
,
84
&
cam_snapshot
.
lens_temp
, &
cam_snapshot
.
array_temp
);
85
86
send_cam_snapshot
=
false
;
87
}
88
pprz_mtx_unlock
(&
copilot_cam_snapshot_mtx
);
89
90
pprz_mtx_lock
(&
copilot_cam_payload_mtx
);
91
if
(
send_cam_payload
) {
92
// NOTE: to send the message over the EXTRA_DL port
93
// use "DOWNLINK_SEND_CAMERA_PAYLOAD(extra_pprz_tp, EXTRA_DOWNLINK_DEVICE,"
94
95
// send down to GCS
96
DOWNLINK_SEND_CAMERA_PAYLOAD
(
DefaultChannel
,
DefaultDevice
,
97
&
cam_payload
.
timestamp
, &
cam_payload
.
used_mem
, &
cam_payload
.
used_disk
,
98
&
cam_payload
.
door_status
, &
cam_payload
.
error_code
);
99
100
send_cam_payload
=
false
;
101
}
102
pprz_mtx_unlock
(&
copilot_cam_payload_mtx
);
103
104
pprz_mtx_lock
(&
copilot_status_mtx
);
105
// send down to GCS
106
if
(
send_copilot_status
) {
107
DOWNLINK_SEND_COPILOT_STATUS
(
DefaultChannel
,
DefaultDevice
,
108
&
copilot_status
.
timestamp
, &
copilot_status
.
used_mem
,
109
&
copilot_status
.
used_disk
, &
copilot_status
.
status
,
110
&
copilot_status
.
error_code
);
111
112
send_copilot_status
=
false
;
113
}
114
pprz_mtx_unlock
(&
copilot_status_mtx
);
115
116
}
76
void
copilot_periodic
(
void
) {
…
}
117
127
void
copilot_parse_cam_snapshot_dl
(
uint8_t
*buf)
128
{
129
pprz_mtx_lock
(&
copilot_cam_snapshot_mtx
);
130
131
// copy CAMERA_SNAPSHOT message and mark it to be sent
132
cam_snapshot
.
cam_id
=
DL_CAMERA_SNAPSHOT_DL_camera_id
(buf);
133
cam_snapshot
.
cam_state
=
DL_CAMERA_SNAPSHOT_DL_camera_state
(buf);
134
cam_snapshot
.
snapshot_num
=
DL_CAMERA_SNAPSHOT_DL_snapshot_image_number
(buf);
135
cam_snapshot
.
snapshot_valid
=
DL_CAMERA_SNAPSHOT_DL_snapshot_valid
(buf);
136
cam_snapshot
.
lens_temp
=
DL_CAMERA_SNAPSHOT_DL_lens_temp
(buf);
137
cam_snapshot
.
array_temp
=
DL_CAMERA_SNAPSHOT_DL_array_temp
(buf);
138
139
send_cam_snapshot
=
true
;
140
141
pprz_mtx_unlock
(&
copilot_cam_snapshot_mtx
);
142
}
127
void
copilot_parse_cam_snapshot_dl
(
uint8_t
*buf) {
…
}
143
147
void
copilot_parse_cam_payload_dl
(
uint8_t
*buf)
148
{
149
pprz_mtx_lock
(&
copilot_cam_payload_mtx
);
150
151
cam_payload
.
timestamp
=
DL_CAMERA_PAYLOAD_DL_timestamp
(buf);
152
cam_payload
.
used_mem
=
DL_CAMERA_PAYLOAD_DL_used_memory
(buf);
153
cam_payload
.
used_disk
=
DL_CAMERA_PAYLOAD_DL_used_disk
(buf);
154
cam_payload
.
door_status
=
DL_CAMERA_PAYLOAD_DL_door_status
(buf);
155
cam_payload
.
error_code
=
DL_CAMERA_PAYLOAD_DL_error_code
(buf);
156
157
send_cam_payload
=
true
;
158
159
pprz_mtx_unlock
(&
copilot_cam_payload_mtx
);
160
}
147
void
copilot_parse_cam_payload_dl
(
uint8_t
*buf) {
…
}
161
165
void
copilot_parse_copilot_status_dl
(
uint8_t
*buf)
166
{
167
pprz_mtx_lock
(&
copilot_status_mtx
);
168
169
copilot_status
.
timestamp
=
DL_COPILOT_STATUS_DL_timestamp
(buf);
170
copilot_status
.
used_mem
=
DL_COPILOT_STATUS_DL_used_memory
(buf);
171
copilot_status
.
used_disk
=
DL_COPILOT_STATUS_DL_used_disk
(buf);
172
copilot_status
.
status
=
DL_COPILOT_STATUS_DL_status
(buf);
173
copilot_status
.
error_code
=
DL_COPILOT_STATUS_DL_error_code
(buf);
174
175
send_copilot_status
=
true
;
176
177
pprz_mtx_unlock
(&
copilot_status_mtx
);
178
}
165
void
copilot_parse_copilot_status_dl
(
uint8_t
*buf) {
…
}
179
184
void
copilot_parse_payload_command_dl
(
uint8_t
*buf
__attribute__
((unused)))
185
{
186
#if FORWARD_PAYLOAD
187
MESSAGE
(
"Forwarding PAYLOAD_COMMAND messages."
)
188
// Check if message was for us
189
if
(
DL_PAYLOAD_COMMAND_ac_id
(buf) ==
AC_ID
) {
190
uint8_t
len =
DL_PAYLOAD_COMMAND_command_length
(buf);
191
192
if
(buf ==
extra_dl_buffer
) {
193
// Message came from extra_dl, forward to GCS via telemetry
194
DOWNLINK_SEND_PAYLOAD
(
DefaultChannel
,
DefaultDevice
,
195
len,
DL_PAYLOAD_COMMAND_command
(buf));
196
}
197
198
if
(buf ==
dl_buffer
) {
199
// Message came from GCS/Telemetry, forward to extra_dl
200
DOWNLINK_SEND_PAYLOAD
(
extra_pprz_tp
,
EXTRA_DOWNLINK_DEVICE
,
201
len,
DL_PAYLOAD_COMMAND_command
(buf));
202
}
203
}
204
#endif
/* FORWARD_PAYLOAD */
205
}
184
void
copilot_parse_payload_command_dl
(
uint8_t
*buf
__attribute__
((unused))) {
…
}
pprz_mtx_unlock
int pprz_mtx_unlock(pprz_mutex_t *mtx)
Definition
threads_arch.c:32
pprz_mtx_init
int pprz_mtx_init(pprz_mutex_t *mtx)
Definition
threads_arch.c:18
pprz_mtx_lock
int pprz_mtx_lock(pprz_mutex_t *mtx)
Definition
threads_arch.c:23
copilot.h
Mission Computer module, interfacing the mission computer (also known as Copilot),...
CameraSnapshot::lens_temp
float lens_temp
Definition
copilot.h:69
CameraPayload::door_status
uint8_t door_status
Definition
copilot.h:60
CameraSnapshot::snapshot_num
uint16_t snapshot_num
Definition
copilot.h:67
CopilotStatus::used_disk
uint8_t used_disk
Definition
copilot.h:76
CameraPayload::used_disk
uint8_t used_disk
Definition
copilot.h:59
CameraSnapshot::snapshot_valid
uint8_t snapshot_valid
Definition
copilot.h:68
CameraSnapshot::cam_state
uint8_t cam_state
Definition
copilot.h:66
CameraSnapshot::array_temp
float array_temp
Definition
copilot.h:70
CopilotStatus::used_mem
uint8_t used_mem
Definition
copilot.h:75
CopilotStatus::error_code
uint8_t error_code
Definition
copilot.h:78
CameraPayload::used_mem
uint8_t used_mem
Definition
copilot.h:58
CameraPayload::error_code
uint8_t error_code
Definition
copilot.h:61
CopilotStatus::status
uint8_t status
Definition
copilot.h:77
CameraPayload::timestamp
float timestamp
Definition
copilot.h:57
CameraSnapshot::cam_id
uint16_t cam_id
Definition
copilot.h:65
CopilotStatus::timestamp
float timestamp
Definition
copilot.h:74
CameraPayload
Definition
copilot.h:56
CameraSnapshot
Definition
copilot.h:64
CopilotStatus
Definition
copilot.h:73
cam_payload
struct CameraPayload cam_payload
Definition
copilot_common.c:51
copilot_init
void copilot_init(void)
Init function.
Definition
copilot_common.c:60
copilot_cam_snapshot_mtx
pprz_mutex_t copilot_cam_snapshot_mtx
Definition
copilot_common.c:55
copilot_status
struct CopilotStatus copilot_status
Definition
copilot_common.c:53
copilot_parse_cam_snapshot_dl
void copilot_parse_cam_snapshot_dl(uint8_t *buf)
copy CAMERA_SNAPSHOT message and mark it to be sent
Definition
copilot_common.c:127
copilot_status_mtx
pprz_mutex_t copilot_status_mtx
Definition
copilot_common.c:57
send_cam_payload
bool send_cam_payload
Definition
copilot_common.c:48
copilot_cam_payload_mtx
pprz_mutex_t copilot_cam_payload_mtx
Definition
copilot_common.c:56
copilot_parse_cam_payload_dl
void copilot_parse_cam_payload_dl(uint8_t *buf)
copy CAMERA_PAYLOAD message and mark it to be sent
Definition
copilot_common.c:147
send_cam_snapshot
bool send_cam_snapshot
Definition
copilot_common.c:47
copilot_parse_payload_command_dl
void copilot_parse_payload_command_dl(uint8_t *buf)
Pass through PAYLOAD_COMMAND message and send it as PAYLOAD msg over telemetry.
Definition
copilot_common.c:184
cam_snapshot
struct CameraSnapshot cam_snapshot
Definition
copilot_common.c:52
copilot_parse_copilot_status_dl
void copilot_parse_copilot_status_dl(uint8_t *buf)
copy COPILOT_STATUS message and mark it to be sent
Definition
copilot_common.c:165
send_copilot_status
bool send_copilot_status
Definition
copilot_common.c:49
copilot_periodic
void copilot_periodic(void)
Periodic function.
Definition
copilot_common.c:76
DefaultDevice
#define DefaultDevice
Definition
downlink.h:45
DefaultChannel
#define DefaultChannel
Definition
downlink.h:41
extra_pprz_tp
struct pprz_transport extra_pprz_tp
Definition
extra_pprz_dl.c:57
extra_dl_buffer
uint8_t extra_dl_buffer[MSG_SIZE]
Definition
extra_pprz_dl.c:55
dl_buffer
uint8_t dl_buffer[MSG_SIZE]
Definition
main_demo5.c:63
foo
uint16_t foo
Definition
main_demo5.c:58
pprzMutex
Definition
threads_arch.h:22
telemetry.h
Periodic telemetry system header (includes downlink utility and generated code).
uint8_t
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition
vl53l1_types.h:98
sw
airborne
modules
mission
copilot_common.c
Generated on Fri Apr 4 2025 14:56:51 for Paparazzi UAS by
1.9.8