aboutsummaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2013-05-23 08:54:08 +0200
committerLorenz Meier <lm@inf.ethz.ch>2013-05-23 08:54:08 +0200
commit81acd98997ff3d605c8c797f04e81e64db180a57 (patch)
treec263291c559b5c15ebf20ee0cbc0ca4fb3177830 /src/examples
parentc6b6b7ffcdd037965f13d82628cdad53072fcb23 (diff)
downloadpx4-firmware-81acd98997ff3d605c8c797f04e81e64db180a57.tar.gz
px4-firmware-81acd98997ff3d605c8c797f04e81e64db180a57.tar.bz2
px4-firmware-81acd98997ff3d605c8c797f04e81e64db180a57.zip
Added limit to heading command
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/fixedwing_control/main.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/examples/fixedwing_control/main.c b/src/examples/fixedwing_control/main.c
index 1753070e2..6a9ad9e1d 100644
--- a/src/examples/fixedwing_control/main.c
+++ b/src/examples/fixedwing_control/main.c
@@ -154,7 +154,14 @@ void control_heading(const struct vehicle_global_position_s *pos, const struct v
/* calculate heading error */
float yaw_err = att->yaw - bearing;
/* apply control gain */
- att_sp->roll_body = yaw_err * p.hdng_p;
+ float roll_command = yaw_err * p.hdng_p;
+
+ /* limit output, this commonly is a tuning parameter, too */
+ if (att_sp->roll_body < -0.5f) {
+ att_sp->roll_body = -0.5f;
+ } else if (att_sp->roll_body > 0.5f) {
+ att_sp->roll_body = 0.5f;
+ }
}
/* Main Thread */