[actuators] converting more actuators drivers

- heli looks obsolete and should be replaced by one of the pwm driver
- pwm_supervion is merged into pwm (direct)
- maybe supervision should have its own subsystem
This commit is contained in:
Gautier Hattenberger
2012-10-16 17:54:34 +02:00
parent d7a80cce92
commit 76f01ceae5
19 changed files with 66 additions and 170 deletions
@@ -1,3 +0,0 @@
ap.srcs += $(SRC_FIRMWARE)/actuators/actuators_heli.c
ap.srcs += $(SRC_ARCH)/subsystems/actuators/actuators_pwm_arch.c
@@ -1,9 +0,0 @@
ap.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
ap.srcs += $(SRC_FIRMWARE)/actuators/actuators_pwm_supervision.c
ap.srcs += $(SRC_ARCH)/subsystems/actuators/actuators_pwm_arch.c
# Simulator
nps.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
nps.srcs += $(SRC_FIRMWARE)/actuators/actuators_pwm_supervision.c
nps.srcs += $(SRC_ARCH)/subsystems/actuators/actuators_pwm_arch.c
@@ -1,4 +1,5 @@
# asctec controllers
$(TARGET).CFLAGS += -DACTUATORS
ap.srcs += subsystems/actuators/actuators_asctec.c
ifeq ($(ARCH), lpc21)
@@ -1,8 +1,6 @@
# asctec controllers v2
#
# <section name="SUPERVISION" prefix="SUPERVISION_">
# <define name="MIN_MOTOR" value="2"/>
# <define name="MAX_MOTOR" value="210"/>
# <define name="TRIM_A" value="2"/>
# <define name="TRIM_E" value="-1"/>
# <define name="TRIM_R" value="3"/>
@@ -16,9 +14,10 @@
#
#
ap.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
$(TARGET).CFLAGS += -DACTUATORS
ap.srcs += subsystems/actuators/supervision.c
ap.CFLAGS += -DACTUATORS_ASCTEC_V2_PROTOCOL
ap.srcs += $(SRC_FIRMWARE)/actuators/actuators_asctec.c
ap.srcs += subsystems/actuators/actuators_asctec.c
ifeq ($(ARCH), lpc21)
ap.CFLAGS += -DACTUATORS_ASCTEC_DEVICE=i2c0
@@ -31,6 +30,6 @@ ap.CFLAGS += -DUSE_I2C1
endif
# Simulator
nps.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
nps.srcs += $(SRC_FIRMWARE)/actuators/actuators_asctec.c
nps.srcs += subsystems/actuators/supervision.c
nps.srcs += subsystems/actuators/actuators_asctec.c
nps.CFLAGS += -DUSE_I2C0 -DACTUATORS_ASCTEC_DEVICE=i2c0
@@ -18,8 +18,6 @@
# </section>
#
# <section name="SUPERVISION" prefix="SUPERVISION_">
# <define name="MIN_MOTOR" value="2"/>
# <define name="MAX_MOTOR" value="210"/>
# <define name="TRIM_A" value="2"/>
# <define name="TRIM_E" value="-1"/>
# <define name="TRIM_R" value="3"/>
@@ -33,8 +31,9 @@
#
#
ap.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
ap.srcs += $(SRC_FIRMWARE)/actuators/actuators_mkk.c
$(TARGET).CFLAGS += -DACTUATORS
ap.srcs += subsystems/actuators/supervision.c
ap.srcs += subsystems/actuators/actuators_mkk.c
ifeq ($(ARCH), lpc21)
@@ -52,6 +51,6 @@ ap.CFLAGS += -DUSE_I2C1
endif
# Simulator
nps.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
nps.srcs += $(SRC_FIRMWARE)/actuators/actuators_mkk.c
nps.srcs += subsystems/actuators/supervision.c
nps.srcs += subsystems/actuators/actuators_mkk.c
nps.CFLAGS += -DUSE_I2C0 -DACTUATORS_MKK_DEVICE=i2c0
@@ -0,0 +1,6 @@
$(TARGET).CFLAGS += -DACTUATORS -DUSE_SUPERVISION
$(TARGET).srcs += subsystems/actuators/supervision.c
$(TARGET).srcs += subsystems/actuators/actuators_pwm.c
$(TARGET).srcs += $(SRC_ARCH)/subsystems/actuators/actuators_pwm_arch.c
@@ -34,6 +34,7 @@ ifeq ($(SKIRON_I2C_SCL_TIME), )
SKIRON_I2C_SCL_TIME=150
endif
$(TARGET).CFLAGS += -DACTUATORS
ap.srcs += subsystems/actuators/supervision.c
ap.srcs += subsystems/actuators/actuators_skiron.c
@@ -49,7 +49,7 @@ const uint8_t pwm_latch_value = 0
#endif
;
void actuators_pwm_init ( void ) {
void actuators_pwm_arch_init ( void ) {
/* configure pins for PWM */
#if defined PWM_SERVO_0
@@ -40,6 +40,7 @@ PWM6 PWM2 SSEL0 EINT2 P0.7
#endif
#define COMMAND_(i) SERVO_REG_ ## i
/** Actuator set macro */
#define ActuatorPwmSet(_i, _v) { COMMAND_(_i) = SERVOS_TICS_OF_USEC(_v); }
#define PWM_PINSEL_MASK_VAL 3
@@ -88,11 +89,11 @@ PWM6 PWM2 SSEL0 EINT2 P0.7
extern const uint8_t pwm_latch_value;
/** Actuator commit macro */
#define ActuatorsPwmCommit() { \
PWMLER = pwm_latch_value; \
}
extern void actuators_pwm_init(void);
#define ActuatorsPwmInit() actuators_pwm_init()
extern void actuators_pwm_arch_init(void);
#endif /* ACTUATORS_PWM_ARCH_H */
@@ -30,6 +30,8 @@
#include <libopencm3/stm32/f1/rcc.h>
#include <libopencm3/stm32/timer.h>
int32_t actuators_pwm_values[ACTUATORS_PWM_NB];
#define PCLK 72000000
#define ONE_MHZ_CLK 1000000
#ifndef SERVO_HZ
@@ -38,15 +38,19 @@
#define ACTUATORS_PWM_NB 6
#endif
/* Needs to be included after ACTUATORS_PWM_NB is defined!
* Otherwise ACTUATORS_PWM_NB is not declared in actuators_pwm.h
*/
#include "subsystems/actuators/actuators_pwm.h"
///* Needs to be included after ACTUATORS_PWM_NB is defined!
// * Otherwise ACTUATORS_PWM_NB is not declared in actuators_pwm.h
// */
//#include "subsystems/actuators/actuators_pwm.h"
extern int32_t actuators_pwm_values[ACTUATORS_PWM_NB];
extern void actuators_pwm_arch_init(void);
extern void actuators_pwm_commit(void);
#define SERVOS_TICS_OF_USEC(_v) (_v)
#define ActuatorsCommit actuators_pwm_commit
#define ActuatorPwmSet(_i, _v) { actuators_pwm_values[_i] = _v; }
#define ActuatorsPwmCommit actuators_pwm_commit
#endif /* ACTUATORS_PWM_ARCH_H */
@@ -26,7 +26,6 @@
#include "subsystems/actuators.h"
#include "subsystems/actuators/actuators_asctec.h"
#include "firmwares/rotorcraft/commands.h"
#include "mcu_periph/i2c.h"
#include "mcu_periph/sys_time.h"
@@ -98,10 +97,6 @@ void actuators_asctec_set(bool_t motors_on) {
actuators_asctec.cmds[YAW] = 0;
actuators_asctec.cmds[THRUST] = 0;
#else /* ! KILL_MOTORS */
// actuators_asctec.cmds[PITCH] = ((commands[COMMAND_PITCH] + SUPERVISION_TRIM_E) * ASCTEC_MAX_CMD) / MAX_PPRZ;
// actuators_asctec.cmds[ROLL] = ((commands[COMMAND_ROLL] + SUPERVISION_TRIM_A) * ASCTEC_MAX_CMD) / MAX_PPRZ;
// actuators_asctec.cmds[YAW] = ((commands[COMMAND_YAW] + SUPERVISION_TRIM_R) * ASCTEC_MAX_CMD) / MAX_PPRZ;
// actuators_asctec.cmds[THRUST] = (commands[COMMAND_THRUST] * ASCTEC_MAX_THROTTLE) / MAX_PPRZ;
Bound(actuators_asctec.cmds[PITCH],ASCTEC_MIN_CMD, ASCTEC_MAX_CMD);
Bound(actuators_asctec.cmds[ROLL], ASCTEC_MIN_CMD, ASCTEC_MAX_CMD);
Bound(actuators_asctec.cmds[YAW], ASCTEC_MIN_CMD, ASCTEC_MAX_CMD);
@@ -147,7 +142,7 @@ void actuators_asctec_set(bool_t motors_on) {
}
#else /* ! ACTUATORS_ASCTEC_V2_PROTOCOL */
void actuators_set(bool_t motors_on) {
void actuators_asctec_set(bool_t motors_on) {
#if defined ACTUATORS_START_DELAY && ! defined SITL
if (!actuators_delay_done) {
if (SysTimeTimer(actuators_delay_time) < USEC_OF_SEC(ACTUATORS_START_DELAY)) {
@@ -174,7 +169,6 @@ void actuators_set(bool_t motors_on) {
return;
}
supervision_run(motors_on, FALSE, commands);
#ifdef KILL_MOTORS
actuators_asctec.i2c_trans.buf[0] = 0;
actuators_asctec.i2c_trans.buf[1] = 0;
@@ -182,10 +176,10 @@ void actuators_set(bool_t motors_on) {
actuators_asctec.i2c_trans.buf[3] = 0;
actuators_asctec.i2c_trans.buf[4] = 0xAA;
#else
actuators_asctec.i2c_trans.buf[0] = supervision.commands[SERVO_FRONT];
actuators_asctec.i2c_trans.buf[1] = supervision.commands[SERVO_BACK];
actuators_asctec.i2c_trans.buf[2] = supervision.commands[SERVO_LEFT];
actuators_asctec.i2c_trans.buf[3] = supervision.commands[SERVO_RIGHT];
actuators_asctec.i2c_trans.buf[0] = actuators_asctec.cmds[SERVO_FRONT];
actuators_asctec.i2c_trans.buf[1] = actuators_asctec.cmds[SERVO_BACK];
actuators_asctec.i2c_trans.buf[2] = actuators_asctec.cmds[SERVO_LEFT];
actuators_asctec.i2c_trans.buf[3] = actuators_asctec.cmds[SERVO_RIGHT];
actuators_asctec.i2c_trans.buf[4] = 0xAA + actuators_asctec.i2c_trans.buf[0] + actuators_asctec.i2c_trans.buf[1] +
actuators_asctec.i2c_trans.buf[2] + actuators_asctec.i2c_trans.buf[3];
#endif
@@ -1,49 +0,0 @@
/*
* Copyright (C) 2010 The Paparazzi Team
*
* 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, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "generated/airframe.h"
#include "firmwares/rotorcraft/actuators.h"
#include "firmwares/rotorcraft/commands.h"
#include "subsystems/actuators/actuators_pwm.h"
#define ESC_STOPPED SERVOS_TICS_OF_USEC(0)
#ifndef KILL_MOTORS
#define ESC_HOVER SERVOS_TICS_OF_USEC(5500)
#else
#define ESC_HOVER SERVOS_TICS_OF_USEC(0)
#endif
int32_t actuators_pwm_values[ACTUATORS_PWM_NB];
void actuators_init(void)
{
actuators_pwm_arch_init();
}
void actuators_set(bool_t motors_on)
{
SetActuatorsFromCommands(commands);
}
@@ -23,10 +23,9 @@
* Actuators driver for Mikrokopter motor controllers.
*/
#include "firmwares/rotorcraft/actuators.h"
#include "firmwares/rotorcraft/actuators/actuators_mkk.h"
#include "subsystems/actuators.h"
#include "subsystems/actuators/actuators_mkk.h"
#include "firmwares/rotorcraft/commands.h"
#include "mcu_periph/i2c.h"
#include "mcu_periph/sys_time.h"
@@ -37,7 +36,7 @@ struct ActuatorsMkk actuators_mkk;
uint32_t actuators_delay_time;
bool_t actuators_delay_done;
void actuators_init(void) {
void actuators_mkk_init(void) {
supervision_init();
const uint8_t actuators_addr[ACTUATORS_MKK_NB] = ACTUATORS_MKK_ADDR;
@@ -59,7 +58,7 @@ void actuators_init(void) {
}
void actuators_set(bool_t motors_on) {
void actuators_mkk_set(void) {
#if defined ACTUATORS_START_DELAY && ! defined SITL
if (!actuators_delay_done) {
if (SysTimeTimer(actuators_delay_time) < USEC_OF_SEC(ACTUATORS_START_DELAY)) return;
@@ -67,12 +66,9 @@ void actuators_set(bool_t motors_on) {
}
#endif
supervision_run(motors_on, FALSE, commands);
for (uint8_t i=0; i<ACTUATORS_MKK_NB; i++) {
#ifdef KILL_MOTORS
actuators_mkk.trans[i].buf[0] = 0;
#else
actuators_mkk.trans[i].buf[0] = supervision.commands[i];
#endif
i2c_submit(&ACTUATORS_MKK_DEVICE, &actuators_mkk.trans[i]);
}
@@ -30,6 +30,7 @@
#include "mcu_periph/i2c.h"
#include "generated/airframe.h"
#include "subsystems/actuators/supervision.h"
struct ActuatorsMkk {
@@ -38,9 +39,11 @@ struct ActuatorsMkk {
extern struct ActuatorsMkk actuators_mkk;
extern void actuators_mkk_init(void);
extern void actuators_mkk_set(void);
#include "firmwares/rotorcraft/actuators/supervision.h"
#define ActuatorMkkSet(_i, _v) { actuators_mkk.trans[i].buf[0] = _v; }
#define ActuatorsMkkInit() actuators_mkk_init()
#define ActuatorsMkkCommit() actuators_mkk_set()
#endif /* ACTUATORS_MKK_H */
@@ -19,7 +19,14 @@
* Boston, MA 02111-1307, USA.
*/
#include "actuators_pwm.h"
#include "subsystems/actuators/actuators_pwm.h"
int32_t actuators_pwm_values[SERVOS_PWM_NB];
void actuators_pwm_init(void)
{
#if USE_SUPERVISION
supervision_init();
#endif
// implemented in arch files
actuators_pwm_arch_init();
}
@@ -28,6 +28,14 @@
#include BOARD_CONFIG
#include "subsystems/actuators/actuators_pwm_arch.h"
extern int32_t actuators_pwm_values[SERVOS_PWM_NB];
#if USE_SUPERVISION
#include "subsystems/actuators/supervision.h"
#endif
extern void actuators_pwm_init(void);
#define ActuatorsPwmInit() actuators_pwm_init()
/* ActuatorSet and ActuatorsPwmCommit are implemented in arch files
*/
#endif /* ACTUATORS_PWM_H */
@@ -1,63 +0,0 @@
/*
* Copyright (C) 2010-2012 The Paparazzi Team
*
* 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, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/** @file actuators_pwm_supervision.h
* PWM actuators with supervision.
*/
#include "generated/airframe.h"
/* warn if SUPERVISION_STOP_MOTOR is not defined in the airframe file */
#ifndef SUPERVISION_STOP_MOTOR
#warning "STOP_MOTOR is not defined in the SUPERVISION section, are you sure you want to use the default of 0?"
#endif
#include "firmwares/rotorcraft/actuators/supervision.h"
#include "firmwares/rotorcraft/commands.h"
#include "subsystems/radio_control.h"
#include "firmwares/rotorcraft/actuators.h"
#include "subsystems/actuators/actuators_pwm.h"
/** actuator PWM values in usec. */
int32_t actuators_pwm_values[ACTUATORS_PWM_NB];
void actuators_init(void)
{
supervision_init();
actuators_pwm_arch_init();
}
void actuators_set(bool_t motors_on)
{
/* set normal control surface actuators, i.e. servos */
SetActuatorsFromCommands(commands);
/* run supervision for actuators (motor controllers) that need mixing */
supervision_run(motors_on, FALSE, commands);
for (int i = 0; i < SUPERVISION_NB_MOTOR; i++) {
actuators_pwm_values[i] = supervision.commands[i];
}
ActuatorsCommit();
}
@@ -38,7 +38,6 @@
struct ActuatorsSkiron {
struct i2c_transaction trans;
//uint8_t actuators_idx[ACTUATORS_SKIRON_NB];
};
extern struct ActuatorsSkiron actuators_skiron;