Implemented altitude and velocity hold mode

Implemented Fixedwing Velocity and Altitude hold mode based on fw_pos_control_l1. 

In this mode throttle controlls airspeed between min and max speeds (set by FW_AIRSPD_MAX and FW_AIRSPD_MIN) and pitch controls vertical speed between FW_T_CLIMB_MAX and FW_T_SINK_MAX.

I agree, and I actually was thinking about that, but for reasons of reuse it would be probably appropriate to have an enum mapping control modes not just for this class. What do you think? Than the question is where to put that enum definition.

Checked in the other changes. Do I have to send another pull request?

Date: Sun, 30 Nov 2014 08:02:15 -0800
From: notifications@github.com
To: Firmware@noreply.github.com
CC: frieludwig@hotmail.com
Subject: Re: [Firmware] Implemented altitude and velocity hold mode (#1476)

In src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp:

> @@ -198,6 +200,8 @@ class FixedwingPositionControl
>  	TECS						_tecs;
>  	fwPosctrl::mTecs				_mTecs;
>  	bool						_was_pos_control_mode;

This approach is problematic because all the fields need to be set correctly in multiple places. How about doing this with an ENUM variable as class member instead, which encoded the current control mode? The flag could be set in the main loop independent of the control mode at the end of the while() loop, and each control mode could just query if the current control mode == last control mode.


This would be much less error prone and less code and ensure that if someone adds new functionality, the mode detection logic is not broken in the future.


—
Reply to this email directly or view it on GitHub.

  
    
    
  
  
 		 	   		  =