Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
cafd2f53
Commit
cafd2f53
authored
7 years ago
by
Julien Lecoeur
Committed by
Daniel Agar
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add example usage of topic debug_array in px4_mavlink_debug app
parent
cb3d86a6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/examples/px4_mavlink_debug/CMakeLists.txt
+1
-1
1 addition, 1 deletion
src/examples/px4_mavlink_debug/CMakeLists.txt
src/examples/px4_mavlink_debug/px4_mavlink_debug.cpp
+31
-8
31 additions, 8 deletions
src/examples/px4_mavlink_debug/px4_mavlink_debug.cpp
with
32 additions
and
9 deletions
src/examples/px4_mavlink_debug/CMakeLists.txt
+
1
−
1
View file @
cafd2f53
...
...
@@ -35,6 +35,6 @@ px4_add_module(
MAIN px4_mavlink_debug
STACK_MAIN 2000
SRCS
px4_mavlink_debug.c
px4_mavlink_debug.c
pp
DEPENDS
)
This diff is collapsed.
Click to expand it.
src/examples/px4_mavlink_debug/px4_mavlink_debug.c
→
src/examples/px4_mavlink_debug/px4_mavlink_debug.c
pp
+
31
−
8
View file @
cafd2f53
...
...
@@ -32,7 +32,7 @@
****************************************************************************/
/**
* @file px4_mavlink_debug.c
* @file px4_mavlink_debug.c
pp
* Debug application example for PX4 autopilot
*
* @author Example User <mail@example.com>
...
...
@@ -41,6 +41,7 @@
#include
<px4_config.h>
#include
<unistd.h>
#include
<stdio.h>
#include
<string.h>
#include
<poll.h>
#include
<systemlib/err.h>
...
...
@@ -50,39 +51,53 @@
#include
<uORB/topics/debug_key_value.h>
#include
<uORB/topics/debug_value.h>
#include
<uORB/topics/debug_vect.h>
#include
<uORB/topics/debug_array.h>
__EXPORT
int
px4_mavlink_debug_main
(
int
argc
,
char
*
argv
[]);
extern
"C"
__EXPORT
int
px4_mavlink_debug_main
(
int
argc
,
char
*
argv
[]);
int
px4_mavlink_debug_main
(
int
argc
,
char
*
argv
[])
{
printf
(
"Hello Debug!
\n
"
);
/* advertise named debug value */
struct
debug_key_value_s
dbg_key
=
{
.
key
=
"velx"
,
.
value
=
0
.
0
f
};
struct
debug_key_value_s
dbg_key
;
strncpy
(
dbg_key
.
key
,
"velx"
,
10
);
dbg_key
.
value
=
0.0
f
;
orb_advert_t
pub_dbg_key
=
orb_advertise
(
ORB_ID
(
debug_key_value
),
&
dbg_key
);
/* advertise indexed debug value */
struct
debug_value_s
dbg_ind
=
{
.
ind
=
42
,
.
value
=
0
.
5
f
};
struct
debug_value_s
dbg_ind
;
dbg_ind
.
ind
=
42
;
dbg_ind
.
value
=
0.5
f
;
orb_advert_t
pub_dbg_ind
=
orb_advertise
(
ORB_ID
(
debug_value
),
&
dbg_ind
);
/* advertise debug vect */
struct
debug_vect_s
dbg_vect
=
{
.
name
=
"vel3D"
,
.
x
=
1
.
0
f
,
.
y
=
2
.
0
f
,
.
z
=
3
.
0
f
};
struct
debug_vect_s
dbg_vect
;
strncpy
(
dbg_vect
.
name
,
"vel3D"
,
10
);
dbg_vect
.
x
=
1.0
f
;
dbg_vect
.
y
=
2.0
f
;
dbg_vect
.
z
=
3.0
f
;
orb_advert_t
pub_dbg_vect
=
orb_advertise
(
ORB_ID
(
debug_vect
),
&
dbg_vect
);
/* advertise debug array */
struct
debug_array_s
dbg_array
;
dbg_array
.
id
=
1
;
strncpy
(
dbg_array
.
name
,
"dbg_array"
,
10
);
orb_advert_t
pub_dbg_array
=
orb_advertise
(
ORB_ID
(
debug_array
),
&
dbg_array
);
int
value_counter
=
0
;
while
(
value_counter
<
100
)
{
uint64_t
timestamp_us
=
hrt_absolute_time
();
uint32_t
timestamp_ms
=
timestamp_us
/
1000
;
/* send one named value */
dbg_key
.
value
=
value_counter
;
dbg_key
.
timestamp
=
timestamp_
ms
*
1e3
f
;
dbg_key
.
timestamp
=
timestamp_
us
;
orb_publish
(
ORB_ID
(
debug_key_value
),
pub_dbg_key
,
&
dbg_key
);
/* send one indexed value */
dbg_ind
.
value
=
0.5
f
*
value_counter
;
dbg_ind
.
timestamp
=
timestamp_
ms
*
1e3
f
;
dbg_ind
.
timestamp
=
timestamp_
us
;
orb_publish
(
ORB_ID
(
debug_value
),
pub_dbg_ind
,
&
dbg_ind
);
/* send one vector */
...
...
@@ -92,6 +107,14 @@ int px4_mavlink_debug_main(int argc, char *argv[])
dbg_vect
.
timestamp
=
timestamp_us
;
orb_publish
(
ORB_ID
(
debug_vect
),
pub_dbg_vect
,
&
dbg_vect
);
/* send one array */
for
(
size_t
i
=
0
;
i
<
debug_array_s
::
ARRAY_SIZE
;
i
++
)
{
dbg_array
.
data
[
i
]
=
value_counter
+
i
*
0.01
f
;
}
dbg_array
.
timestamp
=
timestamp_us
;
orb_publish
(
ORB_ID
(
debug_array
),
pub_dbg_array
,
&
dbg_array
);
warnx
(
"sent one more value.."
);
value_counter
++
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment