diff --git a/conf/airframes/TUDELFT/tudelft_conf.xml b/conf/airframes/TUDELFT/tudelft_conf.xml index 60e681616a..8761fb7b5c 100644 --- a/conf/airframes/TUDELFT/tudelft_conf.xml +++ b/conf/airframes/TUDELFT/tudelft_conf.xml @@ -117,7 +117,7 @@ telemetry="telemetry/default_rotorcraft_slow.xml" flight_plan="flight_plans/TUDELFT/tudelft_delft_basic.xml" settings="settings/rotorcraft_basic.xml settings/control/rotorcraft_guidance.xml [settings/control/stabilization_att_int_quat.xml] settings/control/stabilization_indi.xml settings/estimation/body_to_imu.xml" - settings_modules="modules/geo_mag.xml modules/air_data.xml modules/gps_ubx_ucenter.xml" + settings_modules="modules/geo_mag.xml [modules/air_data.xml] modules/gps_ubx_ucenter.xml" gui_color="#ffffcccaccca" /> + + + @@ -80,6 +83,7 @@ + diff --git a/conf/modules/px4_gimbal.xml b/conf/modules/px4_gimbal.xml new file mode 100644 index 0000000000..c95b89173f --- /dev/null +++ b/conf/modules/px4_gimbal.xml @@ -0,0 +1,19 @@ + + + + + Control gimbal camera axis through px4 from rc + + + + + +
+ +
+ + + + +
+ diff --git a/sw/airborne/modules/px4_gimbal/px4_gimbal.c b/sw/airborne/modules/px4_gimbal/px4_gimbal.c new file mode 100644 index 0000000000..dc08850c85 --- /dev/null +++ b/sw/airborne/modules/px4_gimbal/px4_gimbal.c @@ -0,0 +1,60 @@ +/* + * Copyright (C) Kevin van Hecke + * + * This file is part of paparazzi + * + */ +/** + * @file "modules/px4_gimbal/px4_gimbal.c" + * @author Kevin van Hecke + * Control gimbal camera axis through px4 from rc + */ + +#include "modules/px4_gimbal/px4_gimbal.h" +#include "subsystems/radio_control.h" + +#include "generated/airframe.h" // AC_ID is required +#include "subsystems/actuators.h" + +#ifndef PX4_GIMBAL_PWM_CHAN +#define PX4_GIMBAL_PWM_CHAN 0 +#endif +#ifndef PX4_GIMBAL_RC_CHAN +#define PX4_GIMBAL_RC_CHAN RADIO_AUX2 +#endif + +#ifndef PX4_GIMBAL_PWM_MIN +#define PX4_GIMBAL_PWM_MIN 900 +#endif + +#ifndef PX4_GIMBAL_PWM_MAX +#define PX4_GIMBAL_PWM_MAX 1500 +#endif + + +void px4_gimbal_init() { +#ifdef INTER_MCU_AP + actuators_init(); +#endif +} + + void px4_set_gimbal_angle_periodic() { + //reroute gimbal rc input from fbw to pwm output on ap + + float value =radio_control.values[PX4_GIMBAL_RC_CHAN]; + + float range = PX4_GIMBAL_PWM_MAX - PX4_GIMBAL_PWM_MIN; + value = ((MAX_PPRZ-value) / (float)MAX_PPRZ) * range + PX4_GIMBAL_PWM_MIN; + if (value < 1) {value=1;} // 0 does not seem to work + + ActuatorPwmSet(PX4_GIMBAL_PWM_CHAN, (int32_t)value); + +#ifdef INTER_MCU_AP + AllActuatorsCommit(); +#endif + + + } + + + diff --git a/sw/airborne/modules/px4_gimbal/px4_gimbal.h b/sw/airborne/modules/px4_gimbal/px4_gimbal.h new file mode 100644 index 0000000000..65bda05138 --- /dev/null +++ b/sw/airborne/modules/px4_gimbal/px4_gimbal.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) Kevin van Hecke + * + * This file is part of paparazzi + * + */ +/** + * @file "modules/px4_gimbal/px4_gimbal.h" + * @author Kevin van Hecke + * Control gimbal camera axis through px4 from rc + */ + +#ifndef PX4_GIMBAL_H +#define PX4_GIMBAL_H + + extern void px4_gimbal_init(void); + extern void px4_set_gimbal_angle_periodic(void); + +#endif +