static int32_t get_rc_yaw(void) { const int32_t max_rc_r = (int32_t) ANGLE_BFP_OF_REAL(STABILIZATION_ATTITUDE_SP_MAX_R); int32_t yaw = radio_control.values[RADIO_YAW]; DeadBand(yaw, STABILIZATION_ATTITUDE_DEADBAND_R); return yaw * max_rc_r / (MAX_PPRZ - STABILIZATION_ATTITUDE_DEADBAND_R); }
void guidance_v_read_rc(void) { /* used in RC_DIRECT directly and as saturation in CLIMB and HOVER */ guidance_v_rc_delta_t = (int32_t)radio_control.values[RADIO_THROTTLE]; /* used in RC_CLIMB */ guidance_v_rc_zd_sp = ((MAX_PPRZ/2) - (int32_t)radio_control.values[RADIO_THROTTLE]) * GUIDANCE_V_RC_CLIMB_COEF; DeadBand(guidance_v_rc_zd_sp, GUIDANCE_V_RC_CLIMB_DEAD_BAND); }
static float get_rc_pitch_f(void) { int32_t pitch = radio_control.values[RADIO_PITCH]; #if STABILIZATION_ATTITUDE_DEADBAND_E DeadBand(pitch, STABILIZATION_ATTITUDE_DEADBAND_E); return pitch * STABILIZATION_ATTITUDE_SP_MAX_THETA / (MAX_PPRZ - STABILIZATION_ATTITUDE_DEADBAND_E); #else return pitch * STABILIZATION_ATTITUDE_SP_MAX_THETA / MAX_PPRZ; #endif }
static float get_rc_roll_f(void) { int32_t roll = radio_control.values[RADIO_ROLL]; #if STABILIZATION_ATTITUDE_DEADBAND_A DeadBand(roll, STABILIZATION_ATTITUDE_DEADBAND_A); return roll * STABILIZATION_ATTITUDE_SP_MAX_PHI / (MAX_PPRZ - STABILIZATION_ATTITUDE_DEADBAND_A); #else return roll * STABILIZATION_ATTITUDE_SP_MAX_PHI / MAX_PPRZ; #endif }
static int32_t get_rc_pitch(void) { const int32_t max_rc_theta = (int32_t) ANGLE_BFP_OF_REAL(STABILIZATION_ATTITUDE_SP_MAX_THETA); int32_t pitch = radio_control.values[RADIO_PITCH]; #if STABILIZATION_ATTITUDE_DEADBAND_E DeadBand(pitch, STABILIZATION_ATTITUDE_DEADBAND_E); return pitch * max_rc_theta / (MAX_PPRZ - STABILIZATION_ATTITUDE_DEADBAND_E); #else return pitch * max_rc_theta / MAX_PPRZ; #endif }
static int32_t get_rc_roll(void) { const int32_t max_rc_phi = (int32_t) ANGLE_BFP_OF_REAL(STABILIZATION_ATTITUDE_SP_MAX_PHI); int32_t roll = radio_control.values[RADIO_ROLL]; #if STABILIZATION_ATTITUDE_DEADBAND_A DeadBand(roll, STABILIZATION_ATTITUDE_DEADBAND_A); return roll * max_rc_phi / (MAX_PPRZ - STABILIZATION_ATTITUDE_DEADBAND_A); #else return roll * max_rc_phi / MAX_PPRZ; #endif }
void guidance_v_read_rc(void) { // used in RC_DIRECT directly and as saturation in CLIMB and HOVER #ifndef USE_HELI guidance_v_rc_delta_t = (int32_t)radio_control.values[RADIO_THROTTLE] * 200 / MAX_PPRZ; #else guidance_v_rc_delta_t = (int32_t)radio_control.values[RADIO_THROTTLE] * 4 / 5; #endif // used in RC_CLIMB guidance_v_rc_zd_sp = ((MAX_PPRZ/2) - (int32_t)radio_control.values[RADIO_THROTTLE]) * GUIDANCE_V_RC_CLIMB_COEF; DeadBand(guidance_v_rc_zd_sp, GUIDANCE_V_RC_CLIMB_DEAD_BAND); }
void guidance_v_read_rc(void) { /* used in RC_DIRECT directly and as saturation in CLIMB and HOVER */ guidance_v_rc_delta_t = (int32_t)radio_control.values[RADIO_THROTTLE]; /* used in RC_CLIMB */ guidance_v_rc_zd_sp = (MAX_PPRZ/2) - (int32_t)radio_control.values[RADIO_THROTTLE]; DeadBand(guidance_v_rc_zd_sp, GUIDANCE_V_CLIMB_RC_DEADBAND); static const int32_t climb_scale = ABS(SPEED_BFP_OF_REAL(GUIDANCE_V_MAX_RC_CLIMB_SPEED) / (MAX_PPRZ/2 - GUIDANCE_V_CLIMB_RC_DEADBAND)); static const int32_t descent_scale = ABS(SPEED_BFP_OF_REAL(GUIDANCE_V_MAX_RC_DESCENT_SPEED) / (MAX_PPRZ/2 - GUIDANCE_V_CLIMB_RC_DEADBAND)); if(guidance_v_rc_zd_sp > 0) guidance_v_rc_zd_sp *= descent_scale; else guidance_v_rc_zd_sp *= climb_scale; }
static inline float get_rc_yaw_f(void) { int32_t yaw = radio_control.values[RADIO_YAW]; DeadBand(yaw, STABILIZATION_ATTITUDE_DEADBAND_R); return yaw * STABILIZATION_ATTITUDE_SP_MAX_R / (MAX_PPRZ - STABILIZATION_ATTITUDE_DEADBAND_R); }