aboutsummaryrefslogtreecommitdiff
path: root/src/modules/mc_pos_control
diff options
context:
space:
mode:
authorLorenz Meier <lorenz@px4.io>2014-12-25 00:26:59 +0100
committerLorenz Meier <lorenz@px4.io>2014-12-25 00:26:59 +0100
commit9b535f6553944f3468bbec9203301623412524ad (patch)
tree9b24a4033b2dd0928fd2f1acb549ed2edca5d7aa /src/modules/mc_pos_control
parentb664fc7c8a7aaf7ab229423f6dec9cbe3ce8e3ae (diff)
parent30d851284606476642c6cf8a54070bc08ab923c6 (diff)
downloadpx4-firmware-9b535f6553944f3468bbec9203301623412524ad.tar.gz
px4-firmware-9b535f6553944f3468bbec9203301623412524ad.tar.bz2
px4-firmware-9b535f6553944f3468bbec9203301623412524ad.zip
Merge pull request #1465 from PX4/mcposoffbaltitude
MC pos control offb: read altitude sp separately
Diffstat (limited to 'src/modules/mc_pos_control')
-rw-r--r--src/modules/mc_pos_control/mc_pos_control_main.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/modules/mc_pos_control/mc_pos_control_main.cpp b/src/modules/mc_pos_control/mc_pos_control_main.cpp
index 5918d6bc5..3b631e2ce 100644
--- a/src/modules/mc_pos_control/mc_pos_control_main.cpp
+++ b/src/modules/mc_pos_control/mc_pos_control_main.cpp
@@ -652,8 +652,6 @@ MulticopterPositionControl::control_offboard(float dt)
/* control position */
_pos_sp(0) = _pos_sp_triplet.current.x;
_pos_sp(1) = _pos_sp_triplet.current.y;
- _pos_sp(2) = _pos_sp_triplet.current.z;
-
} else if (_control_mode.flag_control_velocity_enabled && _pos_sp_triplet.current.velocity_valid) {
/* control velocity */
/* reset position setpoint to current position if needed */
@@ -670,7 +668,10 @@ MulticopterPositionControl::control_offboard(float dt)
_att_sp.yaw_body = _att_sp.yaw_body + _pos_sp_triplet.current.yawspeed * dt;
}
- if (_control_mode.flag_control_altitude_enabled) {
+ if (_control_mode.flag_control_altitude_enabled && _pos_sp_triplet.current.position_valid) {
+ /* Control altitude */
+ _pos_sp(2) = _pos_sp_triplet.current.z;
+ } else if (_control_mode.flag_control_climb_rate_enabled && _pos_sp_triplet.current.velocity_valid) {
/* reset alt setpoint to current altitude if needed */
reset_alt_sp();