Remove command_pitch and command_roll and command_yaw (#3208)

... when not used
This commit is contained in:
Christophe De Wagter
2023-12-19 09:58:39 +01:00
committed by GitHub
parent 1ea818de9c
commit 20ef4162bc
6 changed files with 33 additions and 4 deletions
-3
View File
@@ -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>
@@ -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,
@@ -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)
@@ -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;
}
@@ -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];
}
@@ -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;
@@ -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
}
@@ -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,
@@ -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
@@ -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
@@ -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
}