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
a310980a
Commit
a310980a
authored
6 years ago
by
Matthias Grob
Committed by
Beat Küng
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
mc_pos_control: refactor loop polling
parent
013a2655
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/mc_pos_control/mc_pos_control_main.cpp
+7
-12
7 additions, 12 deletions
src/modules/mc_pos_control/mc_pos_control_main.cpp
with
7 additions
and
12 deletions
src/modules/mc_pos_control/mc_pos_control_main.cpp
+
7
−
12
View file @
a310980a
...
@@ -593,21 +593,16 @@ MulticopterPositionControl::run()
...
@@ -593,21 +593,16 @@ MulticopterPositionControl::run()
// Let's be safe and have the landing gear down by default
// Let's be safe and have the landing gear down by default
_att_sp
.
landing_gear
=
vehicle_attitude_setpoint_s
::
LANDING_GEAR_DOWN
;
_att_sp
.
landing_gear
=
vehicle_attitude_setpoint_s
::
LANDING_GEAR_DOWN
;
// wakeup source
// setup file descriptor to poll the local position as loop wakeup source
px4_pollfd_struct_t
fds
[
1
];
px4_pollfd_struct_t
poll_fd
=
{.
fd
=
_local_pos_sub
,
.
events
=
POLLIN
};
fds
[
0
].
fd
=
_local_pos_sub
;
fds
[
0
].
events
=
POLLIN
;
while
(
!
should_exit
())
{
while
(
!
should_exit
())
{
// wait for up to 20ms for data
// poll for new data on the local position state topic (wait for up to 20ms)
int
pret
=
px4_poll
(
&
fds
[
0
],
(
sizeof
(
fds
)
/
sizeof
(
fds
[
0
])),
20
);
const
int
poll_return
=
px4_poll
(
&
poll_fd
,
1
,
20
);
// poll_return == 0: go through the loop anyway to copy manual input at 50 Hz
// pret == 0: go through the loop anyway to copy manual input at 50 Hz.
// this is undesirable but not much we can do
// this is undesirable but not much we can do
if
(
p
ret
<
0
)
{
if
(
p
oll_return
<
0
)
{
PX4_ERR
(
"poll error %d, %
d
"
,
p
ret
,
errno
);
PX4_ERR
(
"poll error
:
%d, %
s
"
,
p
oll_return
,
strerror
(
errno
)
)
;
continue
;
continue
;
}
}
...
...
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