[boards] Remove swing

This commit is contained in:
Freek van Tienen
2022-05-18 13:34:07 +02:00
parent 0a4e9d4d51
commit 85d6056d37
16 changed files with 0 additions and 1135 deletions
-37
View File
@@ -1,37 +0,0 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
# Copyright (C) 2017 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/>.
#
#
# This Makefile uses the generic Makefile.arm-linux and adds upload rules for the Parrot Swing
#
include $(PAPARAZZI_SRC)/conf/Makefile.arm-linux
DRONE = $(PAPARAZZI_SRC)/sw/tools/parrot/swing.py
# Program the device and start it.
upload program: $(OBJDIR)/$(TARGET).elf
$(Q)$(PREFIX)-strip $(OBJDIR)/$(TARGET).elf
$(Q)$(DRONE) --host=$(HOST) upload_file_and_run $(OBJDIR)/$(TARGET).elf $(SUB_DIR)
# Listing of phony targets.
.PHONY : upload program
-213
View File
@@ -1,213 +0,0 @@
<!DOCTYPE airframe SYSTEM "../airframe.dtd">
<airframe name="swing">
<firmware name="rotorcraft">
<configure name="PREFIX" value="/opt/arm-2012.03/bin/arm-none-linux-gnueabi"/>
<target name="ap" board="swing"/>
<target name="nps" board="pc">
<module name="fdm" type="jsbsim"/>
</target>
<!--define name="USE_SONAR" value="TRUE"/-->
<module name="radio_control" type="datalink"/>
<module name="telemetry" type="transparent_udp"/>
<module name="motor_mixing"/>
<module name="actuators" type="swing"/>
<module name="imu" type="swing"/>
<module name="gps" type="datalink"/>
<module name="stabilization" type="int_quat"/>
<module name="ahrs" type="int_cmpl_quat"/>
<module name="ins"/>
<module name="air_data"/>
</firmware>
<commands>
<axis name="PITCH" failsafe_value="0"/>
<axis name="ROLL" failsafe_value="0"/>
<axis name="YAW" failsafe_value="0"/>
<axis name="THRUST" failsafe_value="0"/>
</commands>
<servos>
<servo name="BOTTOM_RIGHT" no="0" min="0" neutral="15" max="511"/>
<servo name="TOP_RIGHT" no="1" min="0" neutral="15" max="511"/>
<servo name="BOTTOM_LEFT" no="2" min="0" neutral="15" max="511"/>
<servo name="TOP_LEFT" no="3" min="0" neutral="15" max="511"/>
</servos>
<section name="MIXING" prefix="MOTOR_MIXING_">
<define name="TRIM_ROLL" value="0"/>
<define name="TRIM_PITCH" value="0"/>
<define name="TRIM_YAW" value="0"/>
<define name="NB_MOTOR" value="4"/>
<define name="SCALE" value="256"/>
<define name="MAX_SATURATION_OFFSET" value="3*MAX_PPRZ"/>
<!-- Time cross layout (X), with order NW (CW), NE (CCW), SE (CW), SW (CCW) -->
<define name="ROLL_COEF" value="{ -81, -81, 81, 81}"/>
<define name="PITCH_COEF" value="{ 243, -243, 243, -243}"/>
<define name="YAW_COEF" value="{ 128, -128, -128, 128}"/>
<define name="THRUST_COEF" value="{ 256, 256, 256, 256}"/>
</section>
<command_laws>
<call fun="motor_mixing_run(autopilot_get_motors_on(),FALSE,values)"/>
<set servo="BOTTOM_RIGHT" value="motor_mixing.commands[0]"/>
<set servo="TOP_RIGHT" value="motor_mixing.commands[1]"/>
<set servo="BOTTOM_LEFT" value="motor_mixing.commands[2]"/>
<set servo="TOP_LEFT" value="motor_mixing.commands[3]"/>
</command_laws>
<section name="AIR_DATA" prefix="AIR_DATA_">
<define name="CALC_AIRSPEED" value="FALSE"/>
<define name="CALC_TAS_FACTOR" value="FALSE"/>
<define name="CALC_AMSL_BARO" value="TRUE"/>
</section>
<section name="IMU" prefix="IMU_">
<!-- Magneto calibration -->
<define name="MAG_X_NEUTRAL" value="18"/>
<define name="MAG_Y_NEUTRAL" value="157"/>
<define name="MAG_Z_NEUTRAL" value="49"/>
<define name="MAG_X_SENS" value="10.5007722373" integer="16"/>
<define name="MAG_Y_SENS" value="11.1147400462" integer="16"/>
<define name="MAG_Z_SENS" value="11.6479371722" integer="16"/>
<!-- Magneto current calibration -->
<define name="MAG_X_CURRENT_COEF" value="0.0"/>
<define name="MAG_Y_CURRENT_COEF" value="0.0"/>
<define name="MAG_Z_CURRENT_COEF" value="0.0"/>
<define name="BODY_TO_IMU_PHI" value="0." unit="deg"/>
<define name="BODY_TO_IMU_THETA" value="0." unit="deg"/>
<define name="BODY_TO_IMU_PSI" value="0." unit="deg"/>
</section>
<!-- local magnetic field -->
<!-- http://wiki.paparazziuav.org/wiki/Subsystem/ahrs#Local_Magnetic_Field -->
<section name="AHRS" prefix="AHRS_">
<!-- Toulouse -->
<!--define name="H_X" value="0.513081"/>
<define name="H_Y" value="-0.00242783"/>
<define name="H_Z" value="0.858336"/-->
<!-- Delft -->
<define name="H_X" value="0.3892503"/>
<define name="H_Y" value="0.0017972"/>
<define name="H_Z" value="0.9211303"/>
</section>
<section name="INS" prefix="INS_">
<define name="SONAR_MAX_RANGE" value="2.2"/>
</section>
<section name="STABILIZATION_RATE" prefix="STABILIZATION_RATE_">
<!-- setpoints -->
<define name="SP_MAX_P" value="10000"/>
<define name="SP_MAX_Q" value="10000"/>
<define name="SP_MAX_R" value="10000"/>
<define name="DEADBAND_P" value="20"/>
<define name="DEADBAND_Q" value="20"/>
<define name="DEADBAND_R" value="200"/>
<define name="REF_TAU" value="4"/>
<!-- feedback -->
<define name="GAIN_P" value="400"/>
<define name="GAIN_Q" value="400"/>
<define name="GAIN_R" value="350"/>
<define name="IGAIN_P" value="75"/>
<define name="IGAIN_Q" value="75"/>
<define name="IGAIN_R" value="50"/>
<!-- feedforward -->
<define name="DDGAIN_P" value="300"/>
<define name="DDGAIN_Q" value="300"/>
<define name="DDGAIN_R" value="300"/>
</section>
<section name="STABILIZATION_ATTITUDE" prefix="STABILIZATION_ATTITUDE_">
<!-- setpoints -->
<define name="SP_MAX_PHI" value="45" unit="deg"/>
<define name="SP_MAX_THETA" value="45" unit="deg"/>
<define name="SP_MAX_R" value="300" unit="deg/s"/>
<define name="DEADBAND_A" value="0"/>
<define name="DEADBAND_E" value="0"/>
<define name="DEADBAND_R" value="50"/>
<!-- reference -->
<define name="REF_OMEGA_P" value="450" unit="deg/s"/>
<define name="REF_ZETA_P" value="0.9"/>
<define name="REF_MAX_P" value="600." unit="deg/s"/>
<define name="REF_MAX_PDOT" value="RadOfDeg(8000.)"/>
<define name="REF_OMEGA_Q" value="450" unit="deg/s"/>
<define name="REF_ZETA_Q" value="0.9"/>
<define name="REF_MAX_Q" value="600." unit="deg/s"/>
<define name="REF_MAX_QDOT" value="RadOfDeg(8000.)"/>
<define name="REF_OMEGA_R" value="450" unit="deg/s"/>
<define name="REF_ZETA_R" value="0.9"/>
<define name="REF_MAX_R" value="600." unit="deg/s"/>
<define name="REF_MAX_RDOT" value="RadOfDeg(8000.)"/>
<!-- feedback -->
<define name="PHI_PGAIN" value="650"/>
<define name="PHI_DGAIN" value="300"/>
<define name="PHI_IGAIN" value="0"/>
<define name="THETA_PGAIN" value="650"/>
<define name="THETA_DGAIN" value="300"/>
<define name="THETA_IGAIN" value="0"/>
<define name="PSI_PGAIN" value="300"/>
<define name="PSI_DGAIN" value="250"/>
<define name="PSI_IGAIN" value="0"/>
<!-- feedforward -->
<define name="PHI_DDGAIN" value="0"/>
<define name="THETA_DDGAIN" value="0"/>
<define name="PSI_DDGAIN" value="0"/>
</section>
<section name="GUIDANCE_V" prefix="GUIDANCE_V_">
<define name="HOVER_KP" value="283"/>
<define name="HOVER_KD" value="82"/>
<define name="HOVER_KI" value="13"/>
<define name="NOMINAL_HOVER_THROTTLE" value="0.655"/>
<define name="ADAPT_THROTTLE_ENABLED" value="TRUE"/>
</section>
<section name="GUIDANCE_H" prefix="GUIDANCE_H_">
<!-- Good weather -->
<define name="MAX_BANK" value="20" unit="deg"/>
<!-- Bad weather -->
<!-- define name="MAX_BANK" value="32" unit="deg"/ -->
<define name="PGAIN" value="79"/>
<define name="DGAIN" value="100"/>
<define name="IGAIN" value="30"/>
</section>
<section name="SIMULATOR" prefix="NPS_">
<define name="ACTUATOR_NAMES" value="nw_motor, ne_motor, se_motor, sw_motor" type="string[]"/>
<define name="JSBSIM_MODEL" value="simple_x_quad_ccw" type="string"/>
<define name="SENSORS_PARAMS" value="nps_sensors_params_default.h" type="string"/>
</section>
<section name="AUTOPILOT">
<define name="MODE_STARTUP" value="AP_MODE_KILL"/>
<define name="MODE_MANUAL" value="AP_MODE_ATTITUDE_DIRECT"/>
<define name="MODE_AUTO1" value="AP_MODE_ATTITUDE_DIRECT"/>
<define name="MODE_AUTO2" value="AP_MODE_ATTITUDE_Z_HOLD"/>
</section>
<section name="BAT">
<define name="CATASTROPHIC_BAT_LEVEL" value="3.1" unit="V"/>
<define name="CRITIC_BAT_LEVEL" value="3.3" unit="V"/>
<define name="LOW_BAT_LEVEL" value="3.5" unit="V"/>
<define name="MAX_BAT_LEVEL" value="4.1" unit="V"/>
</section>
</airframe>
-51
View File
@@ -1,51 +0,0 @@
# Hey Emacs, this is a -*- makefile -*-
#
# swing.makefile
#
# http://wiki.paparazziuav.org/wiki/Swing
#
BOARD=swing
BOARD_CFG=\"boards/$(BOARD).h\"
ARCH=linux
$(TARGET).ARCHDIR = $(ARCH)
# include conf/Makefile.swing (with specific upload rules) instead of only Makefile.linux:
ap.MAKEFILE = swing
FLOAT_ABI =
ARCH_CFLAGS = -march=armv5
# -----------------------------------------------------------------------
USER=foobar
HOST?=192.168.4.1
SUB_DIR=paparazzi
FTP_DIR=/data/edu
TARGET_DIR=$(FTP_DIR)/$(SUB_DIR)
# -----------------------------------------------------------------------
# The datalink default uses UDP
MODEM_HOST ?= 192.168.4.255
# The GPS sensor is connected internally
GPS_PORT ?= UART1
GPS_BAUD ?= B230400
# handle linux signals by hand
$(TARGET).CFLAGS += -DUSE_LINUX_SIGNAL -D_GNU_SOURCE
# board specific init function
$(TARGET).srcs += $(SRC_BOARD)/board.c
# Link static (Done for GLIBC)
$(TARGET).CFLAGS += -DLINUX_LINK_STATIC
$(TARGET).LDFLAGS += -static
# -----------------------------------------------------------------------
# default LED configuration
RADIO_CONTROL_LED ?= none
BARO_LED ?= none
AHRS_ALIGNER_LED ?= none
GPS_LED ?= none
SYS_TIME_LED ?= 0
-4
View File
@@ -36,10 +36,6 @@ else ifeq ($(BOARD), disco)
BARO_BOARD_SRCS += peripherals/ms5611_i2c.c
BARO_BOARD_SRCS += boards/baro_board_ms5611_i2c.c
# Swing baro
else ifeq ($(BOARD), swing)
BARO_BOARD_SRCS += $(SRC_BOARD)/baro_board.c
# Lisa/M baro
else ifeq ($(BOARD), lisa_m)
ifeq ($(BOARD_VERSION), 1.0)
-20
View File
@@ -1,20 +0,0 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="actuators_swing" dir="actuators" task="actuators">
<doc>
<description>
Actuators Driver for Swing
</description>
</doc>
<dep>
<depends>actuators</depends>
<provides>actuators</provides>
</dep>
<header>
<file name="actuators.h" dir="boards/swing"/>
</header>
<makefile target="ap">
<file name="actuators.c" dir="$(SRC_BOARD)"/>
</makefile>
</module>
-17
View File
@@ -1,17 +0,0 @@
<!DOCTYPE module SYSTEM "../module.dtd">
<module name="swing" dir="boards">
<doc>
<description>
Specific configuration for Parrot Swing
</description>
</doc>
<dep>
<depends>baro_board_common</depends>
<provides>baro</provides>
</dep>
<makefile target="!sim|nps|fbw">
<file name="baro_board.c" dir="$(SRC_BOARD)"/>
</makefile>
</module>
-35
View File
@@ -1,35 +0,0 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="imu_swing" dir="imu" task="sensors">
<doc>
<description>
Driver for IMU on the Parrot Swing drone.
- Accelerometer/Gyroscope: MPU6000 via I2C0
</description>
</doc>
<dep>
<depends>i2c,imu_common</depends>
<provides>imu</provides>
</dep>
<autoload name="imu_nps"/>
<autoload name="imu_sim"/>
<!--autoload name="sonar_bebop"/-->
<header>
<file name="imu_swing.h"/>
</header>
<init fun="imu_swing_init()"/>
<periodic fun="imu_swing_periodic()"/>
<event fun="imu_swing_event()"/>
<makefile target="!sim|nps|fbw">
<define name="USE_I2C0"/>
<define name="IMU_TYPE_H" value="modules/imu/imu_swing.h" type="string"/>
<file name="mpu60x0.c" dir="peripherals"/>
<file name="mpu60x0_i2c.c" dir="peripherals"/>
<file name="imu_swing.c"/>
<test>
<define name="IMU_TYPE_H" value="modules/imu/imu_swing.h" type="string"/>
<define name="USE_I2C0"/>
<define name="PERIODIC_FREQUENCY" value="512"/>
</test>
</makefile>
</module>
-64
View File
@@ -1,64 +0,0 @@
/*
* Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
* Copyright (C) 2017 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, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifndef CONFIG_SWING
#define CONFIG_SWING
#define BOARD_SWING
#include "std.h"
/** uart connected to GPS internally */
#define UART1_DEV /dev/ttyPA1
#define GPS_UBX_ENABLE_NMEA_DATA_MASK 0xff
/** FTDI cable for stereoboard or external GPS */
#define UART2_DEV /dev/ttyUSB0
/* Default actuators driver */
#define DEFAULT_ACTUATORS "boards/swing/actuators.h"
#define ActuatorDefaultSet(_x,_y) ActuatorsSwingSet(_x,_y)
#define ActuatorsDefaultInit() ActuatorsSwingInit()
#define ActuatorsDefaultCommit() ActuatorsSwingCommit()
/* by default activate onboard baro */
#ifndef USE_BARO_BOARD
#define USE_BARO_BOARD 1
#endif
/* The ADC from the sonar */
#if USE_ADC0
#define ADC0_ID 0
#define ADC0_CHANNELS 2
#define ADC0_CHANNELS_CNT 1
#define ADC0_BUF_LENGTH 8192
#endif
/* The SPI from the sonar */
#if USE_SPI0
#define SPI0_MODE 0
#define SPI0_BITS_PER_WORD 8
#define SPI0_MAX_SPEED_HZ 320000
#endif
#endif /* CONFIG_SWING */
-126
View File
@@ -1,126 +0,0 @@
/*
* Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
* Copyright (C) 2017 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, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* @file boards/swing/actuators.c
* Actuator driver for the swing
*/
#include <sys/ioctl.h>
#include <fcntl.h>
/* build ioctl unique identifiers for R/W operations */
#define PWM_MAGIC 'p'
typedef struct { unsigned int val[4]; } __attribute__ ((packed)) pwm_delos_quadruplet;
#define PWM_DELOS_SET_RATIOS _IOR(PWM_MAGIC, 9, pwm_delos_quadruplet*)
#define PWM_DELOS_SET_SPEEDS _IOR(PWM_MAGIC, 10, pwm_delos_quadruplet*)
#define PWM_DELOS_SET_CTRL _IOR(PWM_MAGIC, 11, unsigned int)
#define PWM_DELOS_REQUEST _IO(PWM_MAGIC, 12)
#define PWM_NB_BITS (9)
/* PWM can take value between 0 and 511 */
#ifndef PWM_TOTAL_RANGE
#define PWM_TOTAL_RANGE (1<<PWM_NB_BITS)
#endif
#define PWM_REG_RATIO_PRECISION_MASK (PWM_NB_BITS<<16)
#define PWM_REG_SATURATION (PWM_REG_RATIO_PRECISION_MASK|PWM_TOTAL_RANGE)
#include "modules/actuators/actuators.h"
#include "modules/actuators/motor_mixing.h"
#include "actuators.h"
#include "autopilot.h"
struct ActuatorsSwing actuators_swing;
static int actuators_fd;
// Start/stop PWM
enum {
SiP6_PWM0_START = (1<<0),
SiP6_PWM1_START = (1<<1),
SiP6_PWM2_START = (1<<2),
SiP6_PWM3_START = (1<<3),
};
void actuators_swing_init(void)
{
actuators_fd = open("/dev/pwm", O_RDWR);
pwm_delos_quadruplet m = {{ 1, 1, 1, 1 }};
int ret __attribute__((unused)) = ioctl(actuators_fd, PWM_DELOS_SET_SPEEDS, &m);
#if ACTUATORS_SWING_DEBUG
printf("Return Speeds: %d\n", ret);
#endif
actuators_swing_commit();
unsigned int control_reg = (SiP6_PWM0_START|SiP6_PWM1_START|SiP6_PWM2_START|SiP6_PWM3_START);
ret = ioctl(actuators_fd, PWM_DELOS_SET_CTRL, &control_reg);
#if ACTUATORS_SWING_DEBUG
printf("Return control: %d\n", ret);
#endif
}
void actuators_swing_commit(void)
{
pwm_delos_quadruplet m;
m.val[0] = actuators_swing.rpm_ref[0] & 0xffff;
m.val[1] = actuators_swing.rpm_ref[1] & 0xffff;
m.val[2] = actuators_swing.rpm_ref[2] & 0xffff;
m.val[3] = actuators_swing.rpm_ref[3] & 0xffff;
if( actuators_swing.rpm_ref[0] > (PWM_TOTAL_RANGE) ) { m.val[0] = PWM_REG_SATURATION; }
if( actuators_swing.rpm_ref[1] > (PWM_TOTAL_RANGE) ) { m.val[1] = PWM_REG_SATURATION; }
if( actuators_swing.rpm_ref[2] > (PWM_TOTAL_RANGE) ) { m.val[2] = PWM_REG_SATURATION; }
if( actuators_swing.rpm_ref[3] > (PWM_TOTAL_RANGE) ) { m.val[3] = PWM_REG_SATURATION; }
if( actuators_swing.rpm_ref[0] < 0 ) { m.val[0] = 0; }
if( actuators_swing.rpm_ref[1] < 0 ) { m.val[1] = 0; }
if( actuators_swing.rpm_ref[2] < 0 ) { m.val[2] = 0; }
if( actuators_swing.rpm_ref[3] < 0 ) { m.val[3] = 0; }
/* The upper 16-bit word of the ratio register contains the number
* of bits used to code the ratio command */
m.val[0] |= PWM_REG_RATIO_PRECISION_MASK;
m.val[1] |= PWM_REG_RATIO_PRECISION_MASK;
m.val[2] |= PWM_REG_RATIO_PRECISION_MASK;
m.val[3] |= PWM_REG_RATIO_PRECISION_MASK;
int ret __attribute__((unused)) = ioctl(actuators_fd, PWM_DELOS_SET_RATIOS, &m);
#if ACTUATORS_SWING_DEBUG
RunOnceEvery(512, printf("Return ratios: %d (ratios: %d %d %d %d, pwm: %d %d %d %d\n",
ret,
m.val[0], m.val[1], m.val[2], m.val[3],
actuators_swing.rpm_ref[0],
actuators_swing.rpm_ref[1],
actuators_swing.rpm_ref[2],
actuators_swing.rpm_ref[3])
);
#endif
}
-46
View File
@@ -1,46 +0,0 @@
/*
* Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
* Copyright (C) 2017 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, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* @file boards/swing/actuators.h
* Actuator driver for the swing
*/
#ifndef ACTUATORS_SWING_H_
#define ACTUATORS_SWING_H_
#include <stdint.h>
struct ActuatorsSwing {
uint16_t rpm_ref[4]; ///< Reference RPM
};
#define ActuatorsSwingSet(_i, _v) { actuators_swing.rpm_ref[_i] = _v; }
#define ActuatorsSwingCommit() actuators_swing_commit();
#define ActuatorsSwingInit() actuators_swing_init();
extern struct ActuatorsSwing actuators_swing;
extern void actuators_swing_commit(void);
extern void actuators_swing_init(void);
#endif /* ACTUATORS_SWING_H_ */
-104
View File
@@ -1,104 +0,0 @@
/*
* Copyright (C) 2017 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 boards/swing/baro_board.c
* Paparazzi Swing Baro Sensor implementation.
* Sensor is LPS22HB (I2C) from ST but is accessed through sysfs interface
*/
#include "modules/sensors/baro.h"
#include "modules/core/abi.h"
#include "baro_board.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <pthread.h>
#include <linux/input.h>
static bool baro_swing_available;
static int32_t baro_swing_raw;
static pthread_mutex_t baro_swing_mutex = PTHREAD_MUTEX_INITIALIZER;
/**
* Check baro thread
* TODO something better ?
*/
static void *baro_read(void *data __attribute__((unused)))
{
struct input_event ev;
ssize_t n;
int fd_sonar = open("/dev/input/baro_event", O_RDONLY);
if (fd_sonar == -1) {
printf("Unable to open baro event to read pressure\n");
return NULL;
}
while (TRUE) {
/* Check new pressure */
n = read(fd_sonar, &ev, sizeof(ev));
if (n == sizeof(ev) && ev.type == EV_ABS && ev.code == ABS_PRESSURE) {
pthread_mutex_lock(&baro_swing_mutex);
baro_swing_available = true;
baro_swing_raw = ev.value;
pthread_mutex_unlock(&baro_swing_mutex);
}
// Wait 100ms
//usleep(100000);
}
return NULL;
}
void baro_init(void)
{
baro_swing_available = false;
baro_swing_raw = 0;
/* Start baro reading thread */
pthread_t baro_thread;
if (pthread_create(&baro_thread, NULL, baro_read, NULL) != 0) {
printf("[swing_board] Could not create baro reading thread!\n");
}
pthread_setname_np(baro_thread, "pprz_baro_thread");
}
void baro_periodic(void) {}
void baro_event(void)
{
pthread_mutex_lock(&baro_swing_mutex);
if (baro_swing_available) {
// From datasheet: raw_pressure / 4096 -> pressure in hPa
// send data in Pa
uint32_t now_ts = get_sys_time_usec();
float pressure = 100.f * ((float)baro_swing_raw) / 4096.f;
AbiSendMsgBARO_ABS(BARO_BOARD_SENDER_ID, now_ts, pressure);
baro_swing_available = false;
}
pthread_mutex_unlock(&baro_swing_mutex);
}
-38
View File
@@ -1,38 +0,0 @@
/*
* Copyright (C) 2017 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 boards/swing/baro_board.h
* Paparazzi Swing Baro Sensor implementation.
* Sensor is LPS22HB (I2C) from ST but is accessed through sysfs interface
*/
#ifndef BOARDS_SWING_BARO_H
#define BOARDS_SWING_BARO_H
// only for printing the baro type during compilation
#ifndef BARO_BOARD
#define BARO_BOARD BARO_SWING
#endif
extern void baro_event(void);
#define BaroEvent baro_event
#endif /* BOARDS_SWING_BARO_H */
-131
View File
@@ -1,131 +0,0 @@
/*
* Copyright (C) 2017 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, see
* <http://www.gnu.org/licenses/>.
*/
/**
* @file boards/swing/board.c
*
* Swing specific board initialization function.
*
*/
#include "boards/swing.h"
#include "mcu.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <pthread.h>
#include <linux/input.h>
#include "modules/energy/electrical.h"
/**
* Battery reading thread
*/
static void *bat_read(void *data __attribute__((unused)))
{
FILE *fp;
char path[16];
while (TRUE) {
/* Open the command for reading. */
fp = popen("cat /sys/devices/platform/p6-spi.2/spi2.0/vbat", "r");
if (fp == NULL) {
printf("Failed to read battery\n");
} else {
/* Read the output a line at a time - output it. */
while (fgets(path, sizeof(path) - 1, fp) != NULL) {
int raw_bat = atoi(path);
// from /bin/mcu_vbat.sh: MILLIVOLTS_VALUE=$(( ($RAW_VALUE * 4250) / 1023 ))
electrical.vsupply = (float)((raw_bat * 4250) / 1023) / 1000.f;
}
/* close */
pclose(fp);
}
// Wait 100ms
// reading is done at 10Hz like the electrical_periodic from rotorcraft main program
usleep(100000);
}
return NULL;
}
/**
* Check button thread
*/
static void *button_read(void *data __attribute__((unused)))
{
struct input_event ev;
ssize_t n;
/* Open power button event sysfs file */
int fd_button = open("/dev/input/pm_mcu_event", O_RDONLY);
if (fd_button == -1) {
printf("Unable to open mcu_event to read power button state\n");
return NULL;
}
while (TRUE) {
/* Check power button (read is blocking) */
n = read(fd_button, &ev, sizeof(ev));
if (n == sizeof(ev) && ev.type == EV_KEY && ev.code == KEY_POWER && ev.value > 0) {
printf("Stopping Paparazzi from power button and rebooting\n");
usleep(1000);
int ret __attribute__((unused)) = system("reboot.sh");
exit(0);
}
}
return NULL;
}
void board_init(void)
{
/*
* Stop original processes using pstop/ptart commands
* Don't kill to avoid automatic restart
*
*/
int ret __attribute__((unused));
ret = system("pstop delosd");
ret = system("pstop dragon-prog");
usleep(50000); /* Give 50ms time to end on a busy system */
/* Start bat reading thread */
pthread_t bat_thread;
if (pthread_create(&bat_thread, NULL, bat_read, NULL) != 0) {
printf("[swing_board] Could not create battery reading thread!\n");
}
pthread_setname_np(bat_thread, "pprz_bat_thread");
/* Start button reading thread */
pthread_t button_thread;
if (pthread_create(&button_thread, NULL, button_read, NULL) != 0) {
printf("[swing_board] Could not create button reading thread!\n");
}
pthread_setname_np(button_thread, "pprz_button_thread");
}
void board_init2(void)
{
}
-118
View File
@@ -1,118 +0,0 @@
/*
* Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
* Copyright (C) 2017 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, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* @file modules/imu/imu_swing.c
* Driver for the Swing accelerometer and gyroscope
*/
#include "modules/imu/imu.h"
#include "modules/core/abi.h"
#include "mcu_periph/i2c.h"
/* defaults suitable for Swing */
#ifndef SWING_MPU_I2C_DEV
#define SWING_MPU_I2C_DEV i2c0
#endif
PRINT_CONFIG_VAR(SWING_MPU_I2C_DEV)
#if !defined SWING_LOWPASS_FILTER && !defined SWING_SMPLRT_DIV
#if (PERIODIC_FREQUENCY == 60) || (PERIODIC_FREQUENCY == 120)
/* Accelerometer: Bandwidth 44Hz, Delay 4.9ms
* Gyroscope: Bandwidth 42Hz, Delay 4.8ms sampling 1kHz
*/
#define SWING_LOWPASS_FILTER MPU60X0_DLPF_42HZ
#define SWING_SMPLRT_DIV 9
PRINT_CONFIG_MSG("Gyro/Accel output rate is 100Hz at 1kHz internal sampling")
#elif PERIODIC_FREQUENCY == 512
/* Accelerometer: Bandwidth 260Hz, Delay 0ms
* Gyroscope: Bandwidth 256Hz, Delay 0.98ms sampling 8kHz
*/
#define SWING_LOWPASS_FILTER MPU60X0_DLPF_256HZ
#define SWING_SMPLRT_DIV 3
PRINT_CONFIG_MSG("Gyro/Accel output rate is 2kHz at 8kHz internal sampling")
#endif
#endif
PRINT_CONFIG_VAR(SWING_SMPLRT_DIV)
PRINT_CONFIG_VAR(SWING_LOWPASS_FILTER)
PRINT_CONFIG_VAR(SWING_GYRO_RANGE)
PRINT_CONFIG_VAR(SWING_ACCEL_RANGE)
/** Basic Navstik IMU data */
struct ImuSwing imu_swing;
/**
* Navstik IMU initializtion of the MPU-60x0 and HMC58xx
*/
void imu_swing_init(void)
{
/* MPU-60X0 */
mpu60x0_i2c_init(&imu_swing.mpu, &(SWING_MPU_I2C_DEV), MPU60X0_ADDR);
imu_swing.mpu.config.smplrt_div = SWING_SMPLRT_DIV;
imu_swing.mpu.config.dlpf_cfg = SWING_LOWPASS_FILTER;
imu_swing.mpu.config.gyro_range = SWING_GYRO_RANGE;
imu_swing.mpu.config.accel_range = SWING_ACCEL_RANGE;
}
/**
* Handle all the periodic tasks of the Navstik IMU components.
* Read the MPU60x0 every periodic call
*/
void imu_swing_periodic(void)
{
// Start reading the latest gyroscope data
mpu60x0_i2c_periodic(&imu_swing.mpu);
}
/**
* Handle all the events of the Navstik IMU components.
* When there is data available convert it to the correct axis and save it in the imu structure.
*/
void imu_swing_event(void)
{
uint32_t now_ts = get_sys_time_usec();
/* MPU-60x0 event taks */
mpu60x0_i2c_event(&imu_swing.mpu);
if (imu_swing.mpu.data_available) {
/* default orientation of the MPU is upside down and in plane mode
* turn it to have rotorcraft mode by default */
RATES_ASSIGN(imu.gyro_unscaled,
-imu_swing.mpu.data_rates.rates.r,
-imu_swing.mpu.data_rates.rates.q,
-imu_swing.mpu.data_rates.rates.p);
VECT3_ASSIGN(imu.accel_unscaled,
-imu_swing.mpu.data_accel.vect.z,
-imu_swing.mpu.data_accel.vect.y,
-imu_swing.mpu.data_accel.vect.x);
imu_swing.mpu.data_available = false;
imu_scale_gyro(&imu);
imu_scale_accel(&imu);
AbiSendMsgIMU_GYRO_INT32(IMU_BOARD_ID, now_ts, &imu.gyro);
AbiSendMsgIMU_ACCEL_INT32(IMU_BOARD_ID, now_ts, &imu.accel);
}
}
-83
View File
@@ -1,83 +0,0 @@
/*
* Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
* Copyright (C) 2017 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, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* @file modules/imu/imu_swing.h
* Interface for the Swing accelerometer and gyroscope
*/
#ifndef IMU_SWING_H
#define IMU_SWING_H
#include "generated/airframe.h"
#include "modules/imu/imu.h"
#include "peripherals/mpu60x0_i2c.h"
#ifndef SWING_GYRO_RANGE
#define SWING_GYRO_RANGE MPU60X0_GYRO_RANGE_1000
#endif
#ifndef SWING_ACCEL_RANGE
#define SWING_ACCEL_RANGE MPU60X0_ACCEL_RANGE_8G
#endif
// Set default sensitivity based on range if needed
#if !defined IMU_GYRO_P_SENS & !defined IMU_GYRO_Q_SENS & !defined IMU_GYRO_R_SENS
#define IMU_GYRO_P_SENS MPU60X0_GYRO_SENS[SWING_GYRO_RANGE]
#define IMU_GYRO_P_SENS_NUM MPU60X0_GYRO_SENS_FRAC[SWING_GYRO_RANGE][0]
#define IMU_GYRO_P_SENS_DEN MPU60X0_GYRO_SENS_FRAC[SWING_GYRO_RANGE][1]
#define IMU_GYRO_Q_SENS MPU60X0_GYRO_SENS[SWING_GYRO_RANGE]
#define IMU_GYRO_Q_SENS_NUM MPU60X0_GYRO_SENS_FRAC[SWING_GYRO_RANGE][0]
#define IMU_GYRO_Q_SENS_DEN MPU60X0_GYRO_SENS_FRAC[SWING_GYRO_RANGE][1]
#define IMU_GYRO_R_SENS MPU60X0_GYRO_SENS[SWING_GYRO_RANGE]
#define IMU_GYRO_R_SENS_NUM MPU60X0_GYRO_SENS_FRAC[SWING_GYRO_RANGE][0]
#define IMU_GYRO_R_SENS_DEN MPU60X0_GYRO_SENS_FRAC[SWING_GYRO_RANGE][1]
#endif
// Set default sensitivity based on range if needed
#if !defined IMU_ACCEL_X_SENS & !defined IMU_ACCEL_Y_SENS & !defined IMU_ACCEL_Z_SENS
#define IMU_ACCEL_X_SENS MPU60X0_ACCEL_SENS[SWING_ACCEL_RANGE]
#define IMU_ACCEL_X_SENS_NUM MPU60X0_ACCEL_SENS_FRAC[SWING_ACCEL_RANGE][0]
#define IMU_ACCEL_X_SENS_DEN MPU60X0_ACCEL_SENS_FRAC[SWING_ACCEL_RANGE][1]
#define IMU_ACCEL_Y_SENS MPU60X0_ACCEL_SENS[SWING_ACCEL_RANGE]
#define IMU_ACCEL_Y_SENS_NUM MPU60X0_ACCEL_SENS_FRAC[SWING_ACCEL_RANGE][0]
#define IMU_ACCEL_Y_SENS_DEN MPU60X0_ACCEL_SENS_FRAC[SWING_ACCEL_RANGE][1]
#define IMU_ACCEL_Z_SENS MPU60X0_ACCEL_SENS[SWING_ACCEL_RANGE]
#define IMU_ACCEL_Z_SENS_NUM MPU60X0_ACCEL_SENS_FRAC[SWING_ACCEL_RANGE][0]
#define IMU_ACCEL_Z_SENS_DEN MPU60X0_ACCEL_SENS_FRAC[SWING_ACCEL_RANGE][1]
#endif
/** Everything that is in the swing IMU */
struct ImuSwing {
struct Mpu60x0_I2c mpu; ///< The MPU gyro/accel device
};
extern struct ImuSwing imu_swing;
extern void imu_swing_init(void);
extern void imu_swing_periodic(void);
extern void imu_swing_event(void);
#endif /* IMU_SWING_H */
-48
View File
@@ -1,48 +0,0 @@
#!/usr/bin/env python
#
# Copyright (C) 2012-2017 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, see
# <http://www.gnu.org/licenses/>.
#
from __future__ import print_function
from parrot_utils import ParrotUtils
class Swing(ParrotUtils):
uav_name = 'Swing'
address = '192.168.4.1'
version_file = None
upload_path = '/data/edu/'
prompt = '$ '
def uav_status(self):
print('Parrot version:\t\t' + str(self.check_version()))
def init_extra_parser(self):
# nothing here
pass
def parse_extra_args(self, args):
# nothing here
pass
if __name__ == "__main__":
swing = Swing()
swing.parse_args()
exit(0)