Skip to content

Commit

Permalink
Remove command_pitch and command_roll and command_yaw (#3208)
Browse files Browse the repository at this point in the history
... when not used
  • Loading branch information
dewagter committed Dec 19, 2023
1 parent 1ea818d commit 20ef416
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
3 changes: 0 additions & 3 deletions conf/airframes/tudelft/rot_wing_v3d.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@
<axis name="SKEW" failsafe_value="0"/>
<!-- default commands -->
<axis name="THRUST" failsafe_value="0"/>
<axis name="ROLL" failsafe_value="0"/>
<axis name="PITCH" failsafe_value="0"/>
<axis name="YAW" failsafe_value="0"/>
</commands>

<command_laws>
Expand Down
4 changes: 4 additions & 0 deletions sw/airborne/firmwares/rotorcraft/autopilot_firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ static void send_rotorcraft_rc(struct transport_tx *trans, struct link_device *d
}
#endif

#if defined(COMMAND_ROLL) && defined(COMMAND_PITCH) && defined(COMMAND_YAW)
static void send_rotorcraft_cmd(struct transport_tx *trans, struct link_device *dev)
{
pprz_msg_send_ROTORCRAFT_CMD(trans, dev, AC_ID,
Expand All @@ -233,6 +234,9 @@ static void send_rotorcraft_cmd(struct transport_tx *trans, struct link_device *
&stabilization_cmd[COMMAND_YAW],
&stabilization_cmd[COMMAND_THRUST]);
}
#else
static void send_rotorcraft_cmd(struct transport_tx *trans UNUSED, struct link_device *dev UNUSED) {}
#endif


void autopilot_firmware_init(void)
Expand Down
8 changes: 7 additions & 1 deletion sw/airborne/firmwares/rotorcraft/autopilot_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ uint8_t ap_mode_of_two_switches(void)
void WEAK set_rotorcraft_commands(pprz_t *cmd_out, int32_t *cmd_in, bool in_flight __attribute__((unused)), bool motors_on __attribute__((unused)))
{
#if !ROTORCRAFT_IS_HELI
#if !ROTORCRAFT_COMMANDS_YAW_ALWAYS_ENABLED
#if !ROTORCRAFT_COMMANDS_YAW_ALWAYS_ENABLED && defined(COMMAND_YAW)
if (!in_flight) {
cmd_in[COMMAND_YAW] = 0;
}
Expand All @@ -130,9 +130,15 @@ void WEAK set_rotorcraft_commands(pprz_t *cmd_out, int32_t *cmd_in, bool in_flig
cmd_in[COMMAND_THRUST] = 0;
}
#endif
#ifdef COMMAND_ROLL
cmd_out[COMMAND_ROLL] = cmd_in[COMMAND_ROLL];
#endif
#ifdef COMMAND_PITCH
cmd_out[COMMAND_PITCH] = cmd_in[COMMAND_PITCH];
#endif
#ifdef COMMAND_YAW
cmd_out[COMMAND_YAW] = cmd_in[COMMAND_YAW];
#endif
cmd_out[COMMAND_THRUST] = cmd_in[COMMAND_THRUST];
}

6 changes: 6 additions & 0 deletions sw/airborne/firmwares/rotorcraft/guidance/guidance_flip.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ void guidance_flip_enter(void)

void guidance_flip_run(void)
{
#if defined(COMMAND_ROLL) && defined(COMMAND_PITCH) && defined(COMMAND_YAW)

uint32_t timer;
int32_t phi;
static uint32_t timer_save = 0;
Expand Down Expand Up @@ -138,4 +140,8 @@ void guidance_flip_run(void)
stabilization_cmd[COMMAND_THRUST] = 8000; //Some thrust to come out of the roll?
break;
}
#else
autopilot_set_mode(autopilot_mode_old);
stab_att_sp_euler.psi = heading_save;
#endif
}
10 changes: 10 additions & 0 deletions sw/airborne/firmwares/rotorcraft/guidance/guidance_h.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static void send_href(struct transport_tx *trans, struct link_device *dev)
&guidance_h.ref.accel.y);
}

#if defined(COMMAND_ROLL) && defined(COMMAND_PITCH) && defined(COMMAND_YAW)
static void send_tune_hover(struct transport_tx *trans, struct link_device *dev)
{
pprz_msg_send_ROTORCRAFT_TUNE_HOVER(trans, dev, AC_ID,
Expand All @@ -97,6 +98,9 @@ static void send_tune_hover(struct transport_tx *trans, struct link_device *dev)
&(stateGetNedToBodyEulers_i()->theta),
&(stateGetNedToBodyEulers_i()->psi));
}
#else
static void send_tune_hover(struct transport_tx *trans UNUSED, struct link_device *dev UNUSED) {}
#endif

#endif

Expand Down Expand Up @@ -426,9 +430,15 @@ void guidance_h_from_nav(bool in_flight)
}

if (nav.horizontal_mode == NAV_HORIZONTAL_MODE_MANUAL) {
#ifdef COMMAND_ROLL
stabilization_cmd[COMMAND_ROLL] = nav.cmd_roll;
#endif
#ifdef COMMAND_PITCH
stabilization_cmd[COMMAND_PITCH] = nav.cmd_pitch;
#endif
#ifdef COMMAND_YAW
stabilization_cmd[COMMAND_YAW] = nav.cmd_yaw;
#endif
} else if (nav.horizontal_mode == NAV_HORIZONTAL_MODE_ATTITUDE) {
if (nav.setpoint_mode == NAV_SETPOINT_MODE_QUAT) {
// directly apply quat setpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ void stabilization_none_enter(void)
void stabilization_none_run(bool in_flight __attribute__((unused)))
{
/* just directly pass rc commands through */
#ifdef COMMAND_ROLL
stabilization_cmd[COMMAND_ROLL] = stabilization_none_rc_cmd.p;
#endif
#ifdef COMMAND_PITCH
stabilization_cmd[COMMAND_PITCH] = stabilization_none_rc_cmd.q;
#endif
#ifdef COMMAND_YAW
stabilization_cmd[COMMAND_YAW] = stabilization_none_rc_cmd.r;
#endif
}

0 comments on commit 20ef416

Please sign in to comment.