From 81acd98997ff3d605c8c797f04e81e64db180a57 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 23 May 2013 08:54:08 +0200 Subject: [PATCH] Added limit to heading command --- src/examples/fixedwing_control/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/examples/fixedwing_control/main.c b/src/examples/fixedwing_control/main.c index 1753070e2f..6a9ad9e1d1 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 */