Skip to content

Commit

Permalink
[rotorcraft] split arming code definition from autopilot (#2550)
Browse files Browse the repository at this point in the history
the arming states are currently defined in autopilot_static.h, which is
not compatible with the use of generated autopilot
  • Loading branch information
gautierhattenberger committed Jul 27, 2020
1 parent c53756b commit de22fb1
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 46 deletions.
47 changes: 47 additions & 0 deletions sw/airborne/firmwares/rotorcraft/autopilot_arming.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2020 Gautier Hattenberger <gautier.hattenberger@enac.fr>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*/

/**
* @file firmwares/rotorcraft/autopilot_arming.h
*
* Arming procedure for rotorcraft
* Several options can be selected:
* - yaw stick
* - switch position
* - throttle stick
*
*/

#ifndef AUTOPILOT_ARMING_H
#define AUTOPILOT_ARMING_H

/* Include arming procedure, yaw stick by default */
#if USE_KILL_SWITCH_FOR_MOTOR_ARMING
#include "autopilot_arming_switch.h"
PRINT_CONFIG_MSG("Using kill switch for motor arming")
#elif USE_THROTTLE_FOR_MOTOR_ARMING
#include "autopilot_arming_throttle.h"
PRINT_CONFIG_MSG("Using throttle for motor arming")
#else
#include "autopilot_arming_yaw.h"
PRINT_CONFIG_MSG("Using 2 sec yaw for motor arming")
#endif

#endif /* AUTOPILOT_ARMING_H */
52 changes: 52 additions & 0 deletions sw/airborne/firmwares/rotorcraft/autopilot_arming_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2020 Gautier Hattenberger <gautier.hattenberger@enac.fr>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*/

/**
* @file firmwares/rotorcraft/autopilot_arming_common.h
*
* Arming procedure for rotorcraft, common definitions
*/

#ifndef AUTOPILOT_ARMING_COMMON_H
#define AUTOPILOT_ARMING_COMMON_H

#include "autopilot_rc_helpers.h"

/* Arming status*/
#define AP_ARMING_STATUS_NO_RC 0
#define AP_ARMING_STATUS_WAITING 1
#define AP_ARMING_STATUS_ARMING 2
#define AP_ARMING_STATUS_ARMED 3
#define AP_ARMING_STATUS_DISARMING 4
#define AP_ARMING_STATUS_KILLED 5
#define AP_ARMING_STATUS_YAW_CENTERED 6
#define AP_ARMING_STATUS_THROTTLE_DOWN 7
#define AP_ARMING_STATUS_NOT_MODE_MANUAL 8
#define AP_ARMING_STATUS_UNARMED_IN_AUTO 9
#define AP_ARMING_STATUS_THROTTLE_NOT_DOWN 10
#define AP_ARMING_STATUS_STICKS_NOT_CENTERED 11
#define AP_ARMING_STATUS_PITCH_NOT_CENTERED 12
#define AP_ARMING_STATUS_ROLL_NOT_CENTERED 13
#define AP_ARMING_STATUS_YAW_NOT_CENTERED 14
#define AP_ARMING_STATUS_AHRS_NOT_ALLIGNED 15
#define AP_ARMING_STATUS_OUT_OF_GEOFENCE 16
#define AP_ARMING_STATUS_LOW_BATTERY 17

#endif /* AUTOPILOT_ARMING_COMMON_H */
2 changes: 1 addition & 1 deletion sw/airborne/firmwares/rotorcraft/autopilot_arming_switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#ifndef AUTOPILOT_ARMING_SWITCH_H
#define AUTOPILOT_ARMING_SWITCH_H

#include "autopilot_rc_helpers.h"
#include "autopilot_arming_common.h"

#ifndef RADIO_KILL_SWITCH
#error "You need to have a RADIO_KILL_SWITCH configured to arm the motors with the switch!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#ifndef AUTOPILOT_ARMING_THROTTLE_H
#define AUTOPILOT_ARMING_THROTTLE_H

#include "autopilot_rc_helpers.h"
#include "autopilot_arming_common.h"
#include "autopilot_firmware.h"

#define AUTOPILOT_ARMING_DELAY 10
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/firmwares/rotorcraft/autopilot_arming_yaw.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#ifndef AUTOPILOT_ARMING_YAW_H
#define AUTOPILOT_ARMING_YAW_H

#include "autopilot_rc_helpers.h"
#include "autopilot_arming_common.h"
#include "autopilot_firmware.h"
#include "autopilot.h"

Expand Down
12 changes: 1 addition & 11 deletions sw/airborne/firmwares/rotorcraft/autopilot_generated.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "firmwares/rotorcraft/autopilot_generated.h"
#include "autopilot.h"
#include "autopilot_arming.h"

#include "subsystems/radio_control.h"
#include "subsystems/commands.h"
Expand All @@ -37,17 +38,6 @@

#include "generated/settings.h"

#if USE_KILL_SWITCH_FOR_MOTOR_ARMING
#include "autopilot_arming_switch.h"
PRINT_CONFIG_MSG("Using kill switch for motor arming")
#elif USE_THROTTLE_FOR_MOTOR_ARMING
#include "autopilot_arming_throttle.h"
PRINT_CONFIG_MSG("Using throttle for motor arming")
#else
#include "autopilot_arming_yaw.h"
PRINT_CONFIG_MSG("Using 2 sec yaw for motor arming")
#endif


void autopilot_generated_init(void)
{
Expand Down
13 changes: 1 addition & 12 deletions sw/airborne/firmwares/rotorcraft/autopilot_static.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*/

#include "autopilot.h"
#include "autopilot_arming.h"

#include "subsystems/radio_control.h"
#include "subsystems/commands.h"
Expand All @@ -45,7 +46,6 @@
#include "firmwares/rotorcraft/stabilization/stabilization_rate.h"
#endif

#include "firmwares/rotorcraft/autopilot_rc_helpers.h"
#include "firmwares/rotorcraft/autopilot_guided.h"

#include "generated/settings.h"
Expand All @@ -60,17 +60,6 @@
#endif
#endif

#if USE_KILL_SWITCH_FOR_MOTOR_ARMING
#include "autopilot_arming_switch.h"
PRINT_CONFIG_MSG("Using kill switch for motor arming")
#elif USE_THROTTLE_FOR_MOTOR_ARMING
#include "autopilot_arming_throttle.h"
PRINT_CONFIG_MSG("Using throttle for motor arming")
#else
#include "autopilot_arming_yaw.h"
PRINT_CONFIG_MSG("Using 2 sec yaw for motor arming")
#endif

/* Geofence exceptions */
#include "modules/nav/nav_geofence.h"

Expand Down
20 changes: 0 additions & 20 deletions sw/airborne/firmwares/rotorcraft/autopilot_static.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,6 @@
#define AP_MODE_GUIDED 19


/* Arming status*/
#define AP_ARMING_STATUS_NO_RC 0
#define AP_ARMING_STATUS_WAITING 1
#define AP_ARMING_STATUS_ARMING 2
#define AP_ARMING_STATUS_ARMED 3
#define AP_ARMING_STATUS_DISARMING 4
#define AP_ARMING_STATUS_KILLED 5
#define AP_ARMING_STATUS_YAW_CENTERED 6
#define AP_ARMING_STATUS_THROTTLE_DOWN 7
#define AP_ARMING_STATUS_NOT_MODE_MANUAL 8
#define AP_ARMING_STATUS_UNARMED_IN_AUTO 9
#define AP_ARMING_STATUS_THROTTLE_NOT_DOWN 10
#define AP_ARMING_STATUS_STICKS_NOT_CENTERED 11
#define AP_ARMING_STATUS_PITCH_NOT_CENTERED 12
#define AP_ARMING_STATUS_ROLL_NOT_CENTERED 13
#define AP_ARMING_STATUS_YAW_NOT_CENTERED 14
#define AP_ARMING_STATUS_AHRS_NOT_ALLIGNED 15
#define AP_ARMING_STATUS_OUT_OF_GEOFENCE 16
#define AP_ARMING_STATUS_LOW_BATTERY 17

/** Default RC mode.
*/
#ifndef MODE_MANUAL
Expand Down

0 comments on commit de22fb1

Please sign in to comment.