Skip to content

Commit

Permalink
Care Free mode
Browse files Browse the repository at this point in the history
  • Loading branch information
EwoudSmeur committed Mar 8, 2013
1 parent 4733bc4 commit 7636a96
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 5 deletions.
2 changes: 0 additions & 2 deletions conf/airframes/esden/gain_scheduling_example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@
<subsystem name="radio_control" type="ppm">
<configure name="RADIO_CONTROL_PPM_PIN" value="UART1_RX"/>
</subsystem>

<configure name="AHRS_PROPAGATE_FREQUENCY" value="500"/>
</target>

<target name="nps" board="pc">
Expand Down
5 changes: 5 additions & 0 deletions sw/airborne/firmwares/rotorcraft/autopilot.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ void autopilot_set_mode(uint8_t new_autopilot_mode) {
case AP_MODE_RATE_Z_HOLD:
guidance_h_mode_changed(GUIDANCE_H_MODE_RATE);
break;
case AP_MODE_CARE_FREE:
//Take the current psi as the reference for pitch and roll
care_free_heading = stateGetNedToBodyEulers_f()->psi;
case AP_MODE_ATTITUDE_RC_CLIMB:
case AP_MODE_ATTITUDE_DIRECT:
case AP_MODE_ATTITUDE_CLIMB:
case AP_MODE_ATTITUDE_Z_HOLD:
Expand Down Expand Up @@ -181,6 +185,7 @@ void autopilot_set_mode(uint8_t new_autopilot_mode) {
case AP_MODE_RATE_DIRECT:
case AP_MODE_ATTITUDE_DIRECT:
case AP_MODE_HOVER_DIRECT:
case AP_MODE_CARE_FREE:
guidance_v_mode_changed(GUIDANCE_V_MODE_RC_DIRECT);
break;
case AP_MODE_RATE_RC_CLIMB:
Expand Down
4 changes: 2 additions & 2 deletions sw/airborne/firmwares/rotorcraft/autopilot.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
#define AP_MODE_HOVER_CLIMB 10
#define AP_MODE_HOVER_Z_HOLD 11
#define AP_MODE_NAV 12
#define AP_MODE_RC_DIRECT 13 // Safety Pilot Direct Commands for helicopter direct control: appropriately chosen as mode "13"

#define AP_MODE_RC_DIRECT 13 // Safety Pilot Direct Commands for helicopter direct control: appropriately chosen as mode "13"
#define AP_MODE_CARE_FREE 14

extern uint8_t autopilot_mode;
extern uint8_t autopilot_mode_auto2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@


#include STABILIZATION_ATTITUDE_TYPE_H

extern float care_free_heading;

extern void stabilization_attitude_init(void);
extern void stabilization_attitude_read_rc(bool_t in_flight);
extern void stabilization_attitude_enter(void);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ struct Int32Eulers stabilization_att_sum_err;
int32_t stabilization_att_fb_cmd[COMMANDS_NB];
int32_t stabilization_att_ff_cmd[COMMANDS_NB];

float care_free_heading = 0;

#define IERROR_SCALE 1024
#define GAIN_PRESCALER_FF 48
#define GAIN_PRESCALER_P 48
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include "subsystems/radio_control.h"
#include "state.h"
#include "firmwares/rotorcraft/autopilot.h"

#if defined STABILIZATION_ATTITUDE_TYPE_INT
#define SP_MAX_PHI (int32_t)ANGLE_BFP_OF_REAL(STABILIZATION_ATTITUDE_SP_MAX_PHI)
Expand Down Expand Up @@ -187,7 +188,15 @@ static inline void stabilization_attitude_read_rc_setpoint_quat_f(struct FloatQu
/* get current heading */
const struct FloatVect3 zaxis = {0., 0., 1.};
struct FloatQuat q_yaw;
FLOAT_QUAT_OF_AXIS_ANGLE(q_yaw, zaxis, stateGetNedToBodyEulers_f()->psi);

//Care Free mode
if(autopilot_mode == AP_MODE_CARE_FREE) {
//care_free_heading has been set to current psi when entering care free mode.
FLOAT_QUAT_OF_AXIS_ANGLE(q_yaw, zaxis, care_free_heading);
}
else {
FLOAT_QUAT_OF_AXIS_ANGLE(q_yaw, zaxis, stateGetNedToBodyEulers_f()->psi);
}

/* roll/pitch commands applied to to current heading */
struct FloatQuat q_rp_sp;
Expand Down
1 change: 1 addition & 0 deletions sw/airborne/modules/gain_scheduling/gain_scheduling.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

//Include for scheduling on transition_status
#include "firmwares/rotorcraft/guidance/guidance_h.h"
#include "firmwares/rotorcraft/stabilization.h"

// #include "state.h"
#include "math/pprz_algebra_int.h"
Expand Down

0 comments on commit 7636a96

Please sign in to comment.