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
0ba38960
Commit
0ba38960
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 dt time difference calculation
parent
a310980a
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
+10
-12
10 additions, 12 deletions
src/modules/mc_pos_control/mc_pos_control_main.cpp
with
10 additions
and
12 deletions
src/modules/mc_pos_control/mc_pos_control_main.cpp
+
10
−
12
View file @
0ba38960
...
...
@@ -67,6 +67,8 @@
#include
"PositionControl.hpp"
#include
"Utility/ControlMath.hpp"
using
namespace
time_literals
;
/**
* Multicopter position control app start / stop handling function
*/
...
...
@@ -573,7 +575,9 @@ MulticopterPositionControl::print_status()
void
MulticopterPositionControl
::
run
()
{
// do subscriptions
hrt_abstime
_time_stamp_last_loop
=
hrt_absolute_time
();
// time stamp of last loop iteration
// initialize all subscriptions
_vehicle_status_sub
=
orb_subscribe
(
ORB_ID
(
vehicle_status
));
_vehicle_land_detected_sub
=
orb_subscribe
(
ORB_ID
(
vehicle_land_detected
));
_control_mode_sub
=
orb_subscribe
(
ORB_ID
(
vehicle_control_mode
));
...
...
@@ -583,13 +587,10 @@ MulticopterPositionControl::run()
_home_pos_sub
=
orb_subscribe
(
ORB_ID
(
home_position
));
_traj_wp_avoidance_sub
=
orb_subscribe
(
ORB_ID
(
vehicle_trajectory_waypoint
));
// get initial values for all parameters and subscribtions
parameters_update
(
true
);
// get an initial update for all sensor and status data
poll_subscriptions
();
hrt_abstime
t_prev
=
0
;
// Let's be safe and have the landing gear down by default
_att_sp
.
landing_gear
=
vehicle_attitude_setpoint_s
::
LANDING_GEAR_DOWN
;
...
...
@@ -607,15 +608,12 @@ MulticopterPositionControl::run()
}
poll_subscriptions
();
parameters_update
(
false
);
hrt_abstime
t
=
hrt_absolute_time
();
const
float
dt
=
t_prev
!=
0
?
(
t
-
t_prev
)
/
1e6
f
:
0.004
f
;
t_prev
=
t
;
// set dt for control blocks
setDt
(
dt
);
// measure _dt the time difference since the last loop iteration in seconds
const
hrt_abstime
_time_stamp_current
=
hrt_absolute_time
();
setDt
((
_time_stamp_current
-
_time_stamp_last_loop
)
/
1e6
f
);
_time_stamp_last_loop
=
_time_stamp_current
;
const
bool
was_in_failsafe
=
_in_failsafe
;
_in_failsafe
=
false
;
...
...
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