T4 actuators and T4 AOA now usable in Paparazzi master (#3401)
Issues due date / Add labels to issues (push) Has been cancelled
Doxygen / build (push) Has been cancelled

* T4 actuators and T4 AOA now usable in Paparazzi master

* Rename ACTUATORS_T4_UART_DEV to ACTUATORS_T4_UART_PORT

since build failure on semaphore test  gave:
modules/actuators/actuators_t4_uart.c:194:19: error: ‘ACTUATORS_T4_PORT’ undeclared

* Rename ACTUATORS_T4_UART_PORT to ACTUATORS_T4_PORT

Wrongly named, FYI since for the future plans port could be as well CAN or I2C type no specific reference to UART device just plain ACTUATORS_T4_PORT
This commit is contained in:
OpenUAS
2025-10-19 19:55:09 +02:00
committed by GitHub
parent f6b8c3f798
commit b4ba0dac47
20 changed files with 2369 additions and 36 deletions
+9
View File
@@ -265,6 +265,15 @@
<field name="stamp" type="uint32_t" unit="us"/>
<field name="relpos" type="struct RelPosNED *"/>
</message>
<message name="ACTUATORS_T4_OUT" id="40">
<field name="actuators_t4_out_ptr" type="struct ActuatorsT4Out *">Pointer pointing at the actuators_t4_out struct</field>
<field name="actuators_t4_extra_data_out_ptr" type="float *">Pointer pointing at the actuators_t4_extra_data_out array</field>
</message>
<message name="ACTUATORS_T4_IN" id="41">
<field name="actuators_t4_in_ptr" type="struct ActuatorsT4In *">Pointer pointing at the actuators_t4_in struct</field>
<field name="actuators_t4_extra_data_in_ptr" type="float *">Pointer pointing at the actuators_t4_extra_data_in array</field>
</message>
</msg_class>
File diff suppressed because it is too large Load Diff
+18
View File
@@ -0,0 +1,18 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="actuators_t4" dir="actuators" task="actuators">
<doc>
<description>
Intermediate Actuators Driver when using a T4 actuators board
</description>
</doc>
<dep>
<depends>actuators</depends>
<provides>actuators</provides>
</dep>
<header>
<file name="actuators_t4.h"/>
</header>
<makefile>
<file_arch name="actuators_t4_arch.c"/>
</makefile>
</module>
+42
View File
@@ -0,0 +1,42 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="actuators_t4_uart" dir="actuators" task="actuators">
<doc>
<description>
Actuators Driver using T4 protocol to a T4 actuators board via UART bus.
If you have a T4 Actuator Board, use this module to set serialbus servos, PWM ESC's, DShot ESC's and PWM servos connected to a T4 Actuators Board.
Prominent use-case is that one can use status information that is returned in the autopilot control loop.
All the information like: RPM, Angle, Torque, Temperature, Current, usable state information for more precisly contolled flights.
For the hardware and software used to make your own T4 Actuators board, find all information here: https://github.com/tudelft/t4_actuators_board/
</description>
<configure name="ACTUATORS_T4_PORT" value="UARTX" description="UART port the T4 board is connected to (default uart2)"/>
<configure name="ACTUATORS_T4_BAUD" value="B921600" description="Baudrate for the Flightcontroller to T4 actuators board, make they are the same (default B1500000)"/>
</doc>
<header>
<file name="actuators_t4_uart.h"/>
</header>
<init fun="actuators_t4_uart_init()"/>
<event fun="actuators_t4_uart_event()"/>
<makefile target="ap|fbw">
<configure name="ACTUATORS_T4_PORT" default="uart2" case="upper|lower"/>
<configure name="ACTUATORS_T4_BAUD" default="B1500000"/>
<define name="USE_$(ACTUATORS_T4_PORT_UPPER)"/>
<define name="USE_$(ACTUATORS_T4_PORT_UPPER)_TX" value="TRUE"/>
<define name="ACTUATORS_T4_PORT" value="$(ACTUATORS_T4_PORT_LOWER)"/>
<define name="$(ACTUATORS_T4_PORT_UPPER)_BAUD" value="$(ACTUATORS_T4_BAUD)"/>
<file name="actuators_t4_uart.c" dir="modules/actuators"/>
</makefile>
<makefile target="sim|nps">
<define name="ACTUATORS_T4_SIM" value="TRUE"/>
<configure name="ACTUATORS_T4_PORT" default="UART4" case="upper|lower"/>
<configure name="ACTUATORS_T4_BAUD" default="B1500000"/>
<define name="ACTUATORS_T4_PORT" value="$(ACTUATORS_T4_PORT_LOWER)"/>
<file name="actuators_t4_uart.c" dir="modules/actuators"/>
<test>
<define name="USE_UART2"/>
<define name="PERIODIC_FREQUENCY" value="500"/>
<define name="ACTUATORS_T4_PORT" value="uart2"/>
</test>
</makefile>
</module>
+75
View File
@@ -0,0 +1,75 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="aoa_t4" dir="sensors">
<doc>
<description>
Angle of Attack (AOA) sensor using angle input from a modiefied hall servo connected to a T4 Actuators Board.
For the hardware and software used to make your own T4 Actuators board, find all information here:
https://github.com/tudelft/t4_actuators_board/
To make it work, the motor of the servo needs to be removed, only the hall sensors is used for angle feedback.
If the MOTOR is NOT REMOVED from the servo there will be to much friction and the sensor will NOT WORK properly.
Budget wise it is a flexible solution for angle of attack sensor if one uses a T4 Actuators Board already.
Aditionall a second servo can added to be assigned to fuction as a SideSlip angle (SSA) sensor.
If SSA is added, it is assumed that both sensors are the same, offset and direction can be set to different values.
A Servo modified for sensor use which works well is a Feetech STS3032. It is a 360 degree serial bus servo with hall sensor feedback.
Simply add the "aoa_t4" module to your myname_airframe.xml file to be able to use this solution.
Also for initial offset determination, enabeling the SYNC message is very helpfull. Just add the SYNC_SEND_AOA_T4 define.
For a 3D design of a vane that can be 3D printed and mounted on the servo used, download it here:
</description>
<define name="AOA_T4_SERVO_ID" value="10" description="Set the Servo ID of servo to use as an Angle Of Attack(AOA) sensor."/>
<define name="AOA_T4_ANGLE_OFFSET" value="3.14" description="How the sensor is physically mounted, a global offset in radian corresponding to the sensor mounting (default: 3.14)"/>
<define name="AOA_T4_OFFSET" value="-0.123" description="Initial offset on the neutral angle value."/>
<define name="AOA_T4_REVERSE" value="TRUE|FALSE" description="Set to TRUE to reverse AOA output rotation direction (sign)"/>
<define name="AOA_T4_USE_FILTER" value="TRUE|FALSE" description="Filter the AOA angle sensor output to avoid to much angle fluctuation"/>
<define name="AOA_T4_FILTER" value="0.08" description="If filtered is true, then set how much to filter the output"/>
<define name="AOA_T4_SYNC_SEND" value="TRUE|FALSE" description="Enable telemetry report from AOA or SSA sensor, best set to TRUE to determine the neutral angle to set in offset"/>
<define name="AOA_T4_USE_COMPENSATION" value="TRUE|FALSE" description="Compensate the output"/>
<define name="USE_AOA" value="TRUE|FALSE" description="Enable AOA sensor values to the state (default: TRUE)"/>
<define name="AOA_T4_COMP_A1" value="0.0" description=""/>
<define name="AOA_T4_COMP_B1" value="0.0" description=""/>
<define name="AOA_T4_COMP_A2" value="-0.34" description=""/>
<define name="AOA_T4_COMP_B2" value="0.0" description=""/>
<!-- Optionally if a SideSlip Angle(SSA) sensor is available -->
<define name="SSA_T4_SERVO_ID" value="9" description="Set the Servo ID of servo to use as an SideSlip Angle(SSA) sensor"/>
<define name="SSA_T4_ANGLE_OFFSET" value="3.14" description="How the sensor is physically mounted, a global offset in radian corresponding to the sensor mounting (default: 3.14)"/>
<define name="SSA_T4_OFFSET" value="-0.456" description="Initial offset on the neutral angle value."/>
<define name="SSA_T4_REVERSE" value="TRUE|FALSE" description="Set to TRUE to reverse AOA output rotation direction (sign)"/>
<define name="SSA_T4_USE_FILTER" value="TRUE|FALSE" description="Filter the AOA angle sensor output to avoid to much angle fluctuation"/>
<define name="SSA_T4_FILTER" value="0.15" description="If filtered is true, then set how much to filter the output"/>
<define name="USE_SIDESLIP" value="TRUE|FALSE" description="Enable SSA sensor values into the state"/>
</doc>
<settings>
<dl_settings>
<dl_settings name="AOA T4">
<dl_setting var="aoa_send_type" min="0" max="1" step="1" shortname="Send AOA or SSA" module="modules/sensors/aoa_t4" values="AOA|SIDESLIP"/>
<dl_setting var="aoa_t4.offset" min="-3.14" max="3.14" step="0.01" shortname="AOA Offset" module="modules/sensors/aoa_t4" param="AOA_OFFSET" unit="rad" alt_unit="deg"/>
<dl_setting var="aoa_t4.filter" min="0.0" max="0.95" step="0.01" shortname="AOA Filter" module="modules/sensors/aoa_t4" param="AOA_FILTER"/>
<dl_setting var="ssa_t4.offset" min="-3.14" max="3.14" step="0.01" shortname="SSA Offset" module="modules/sensors/aoa_t4" param="SSA_OFFSET" unit="rad" alt_unit="deg"/>
<dl_setting var="ssa_t4.filter" min="0.0" max="0.95" step="0.01" shortname="SSA Filter" module="modules/sensors/aoa_t4" param="SSA_FILTER"/>
<dl_setting var="aoa_t4_a1" min="-1" max="1" step="0.001" shortname="Comp A1" />
<dl_setting var="aoa_t4_b1" min="-1" max="1" step="0.001" shortname="Comp B1" />
<dl_setting var="aoa_t4_a2" min="-1" max="1" step="0.001" shortname="Comp A2" />
<dl_setting var="aoa_t4_b2" min="-1" max="1" step="0.001" shortname="Comp B2" />
</dl_settings>
</dl_settings>
</settings>
<header>
<file name="aoa_t4.h"/>
</header>
<init fun="aoa_t4_init()"/>
<periodic fun="aoa_t4_update()" freq="200."/>
<makefile target="ap|sim|nps">
<file name="aoa_t4.c"/>
</makefile>
</module>
+1 -2
View File
@@ -50,7 +50,7 @@
<configure name="UBX2_GPS_BAUD" default="$(GPS2_BAUD)"/>
<define name="USE_$(UBX2_GPS_PORT_UPPER)" cond="ifneq ($(UBX2_GPS_PORT)$(SECONDARY_GPS),)"/>
<define name="UBX2_GPS_PORT" value="$(UBX2_GPS_PORT_LOWER)" cond="ifneq ($(UBX2_GPS_PORT)$(SECONDARY_GPS),)"/>
<define name="$(UBX2_GPS_PORT_UPPER)_BAUD" value="$(UBX2_GPS_BAUD)" cond="ifneq ($(UBX2_GPS_BAUD)$(SECONDARY_GPS),)"/>
<define name="$(UBX2_GPS_PORT_UPPER)_BAUD" value="$(UBX2_GPS_BAUD)" cond="ifdef SECONDARY_GPS"/>
<raw>
ifdef SECONDARY_GPS
@@ -85,4 +85,3 @@
</test>
</makefile>
</module>
@@ -0,0 +1,91 @@
<?xml version="1.0"?>
<!DOCTYPE telemetry SYSTEM "telemetry.dtd">
<telemetry>
<process name="Ap">
<mode name="default">
<message name="AUTOPILOT_VERSION" period="11.1"/>
<message name="AIRSPEED" period="1"/>
<message name="ALIVE" period="5"/>
<message name="GPS" period="0.25"/>
<message name="NAVIGATION" period="1."/>
<message name="ATTITUDE" period="0.4"/>
<message name="ESTIMATOR" period="0.5"/>
<message name="ENERGY" period="1.1"/>
<message name="WP_MOVED" period="0.4"/>
<message name="CIRCLE" period="1.05"/>
<message name="DESIRED" period="1.05"/>
<message name="SEGMENT" period="1.2"/>
<message name="CALIBRATION" period="2.1"/>
<message name="NAVIGATION_REF" period="4."/>
<message name="PPRZ_MODE" period="2."/>
<message name="SETTINGS" period="2."/>
<message name="STATE_FILTER_STATUS" period="3."/>
<message name="DATALINK_REPORT" period="5.1"/>
<message name="DL_VALUE" period="1.5"/>
<message name="IMU_GYRO" period="1.1"/>
<message name="SURVEY" period="2.1"/>
<message name="GPS_SOL" period="2.0"/>
<message name="CAM" period="0.5"/>
<message name="CAM_POINT" period="1.0"/>
<message name="COMMANDS" period="5"/>
<message name="FBW_STATUS" period="2"/>
<message name="AIR_DATA" period="0.9"/>
<message name="ACTUATORS_T4_OUT" period="0.8"/>
<message name="ACTUATORS_T4_IN" period="0.8"/>
<message name="AOA" period="0.5"/>
</mode>
<mode name="minimal">
<message name="ALIVE" period="5"/>
<message name="ATTITUDE" period="4"/>
<message name="GPS" period="1.05"/>
<message name="ESTIMATOR" period="1.3"/>
<message name="WP_MOVED" period="1.4"/>
<message name="CIRCLE" period="3.05"/>
<message name="DESIRED" period="4.05"/>
<message name="ENERGY" period="1.1"/>
<message name="SEGMENT" period="3.2"/>
<message name="CALIBRATION" period="5.1"/>
<message name="NAVIGATION_REF" period="9."/>
<message name="NAVIGATION" period="3."/>
<message name="PPRZ_MODE" period="5."/>
<message name="STATE_FILTER_STATUS" period="5."/>
<message name="DATALINK_REPORT" period="5.1"/>
<message name="DL_VALUE" period="1.5"/>
<message name="IMU_GYRO" period="10.1"/>
<message name="SURVEY" period="2.1"/>
<message name="GPS_SOL" period="5.0"/>
</mode>
<mode name="extremal">
<message name="ALIVE" period="5"/>
<message name="GPS" period="5.1"/>
<message name="ESTIMATOR" period="5.3"/>
<message name="ENERGY" period="10.1"/>
<message name="DESIRED" period="10.2"/>
<message name="NAVIGATION" period="5.4"/>
<message name="PPRZ_MODE" period="5.5"/>
<message name="STATE_FILTER_STATUS" period="7."/>
<message name="DATALINK_REPORT" period="5.7"/>
</mode>
<mode name="raw_sensors">
<message name="DL_VALUE" period="0.5"/>
<message name="ALIVE" period="2.1"/>
<message name="BARO_RAW" period="0.5"/>
<message name="IMU_GYRO_RAW" period="0.1"/>
<message name="AIRSPEED_RAW" period="0.5"/>
</mode>
</process>
<process name="Fbw">
<mode name="default">
<message name="COMMANDS" period="5"/>
<message name="FBW_STATUS" period="2"/>
<message name="ACTUATORS" period="5"/> <!-- For trimming -->
</mode>
<mode name="debug">
<message name="PPM" period="0.5"/>
<message name="RC" period="0.5"/>
<message name="COMMANDS" period="0.5"/>
<message name="FBW_STATUS" period="1"/>
<message name="ACTUATORS" period="5"/> <!-- For trimming -->
</mode>
</process>
</telemetry>
+11
View File
@@ -1,4 +1,15 @@
<conf>
<aircraft
name="Seal_EVO"
ac_id="136"
airframe="airframes/OPENUAS/openuas_atomrc_seal_evo.xml"
radio="radios/OPENUAS/openuas_openrxsr_sbus_16_out.xml"
telemetry="telemetry/t4_actuators_board_debugdata.xml"
flight_plan="flight_plans/basic.xml"
settings="settings/fixedwing_basic.xml"
settings_modules="modules/ahrs_float_cmpl_quat.xml modules/air_data.xml modules/airspeed_sdp3x.xml modules/aoa_t4.xml modules/electrical.xml modules/geo_mag.xml modules/gps.xml modules/gps_ublox.xml modules/guidance_full_pid_fw.xml modules/imu_common.xml modules/imu_heater.xml modules/nav_basic_fw.xml modules/nav_smooth.xml modules/nav_survey_poly_osam.xml modules/photogrammetry_calculator.xml modules/stabilization_adaptive_fw.xml modules/tune_airspeed.xml"
gui_color="yellow"
/>
<aircraft
name="Minimag"
ac_id="233"
+61 -32
View File
@@ -36,8 +36,6 @@
</program>
<program name="Hardware in the Loop" command="sw/simulator/simhitl"/>
<program name="Environment Simulator" command="sw/simulator/gaia"/>
<program name="Attitude Visualizer" command="sw/tools/attitude_viz.py"/>
<program name="App Server" command="sw/ground_segment/tmtc/app_server"/>
<program name="Ivy2Nmea" command="sw/ground_segment/tmtc/ivy2nmea">
@@ -165,33 +163,6 @@
</program>
<program name="Link Combiner"/>
</session>
<session name="OpenUAS testflights 2020">
<program name="GCS">
<arg flag="-speech"/>
<arg flag="-layout" constant="OPENUAS/openuas_bottom_settings.xml"/>
<arg flag="-maximize"/>
<arg flag="-maps_fill"/>
<arg flag="-center_ac"/>
<arg flag="-mercator"/>
<arg flag="-maps_no_http"/>
<arg flag="-track_size" constant="200"/>
<arg flag="-zoom" constant="0.5"/>
<arg flag="-no_confirm_kill"/>
<arg flag="-srtm"/>
</program>
<program name="Data Link">
<arg flag="-d" constant="/dev/ttyUSB0"/>
<arg flag="-s" constant="57600"/>
</program>
<program name="Server"/>
</session>
<session name="Flight USB-serial@9600">
<program name="Data Link">
<arg flag="-d" constant="/dev/ttyUSB0"/>
</program>
<program name="Server"/>
<program name="GCS"/>
</session>
<session name="SupperBitRF cable telemetry">
<program name="Data Link">
<arg flag="-d" constant="/dev/ttyACM1"/>
@@ -200,7 +171,6 @@
<program name="Server"/>
<program name="GCS"/>
<program name="Messages"/>
<program name="Messages"/>
</session>
<session name="Accelo only Debug Graphs">
<program name="Real-time Plotter">
@@ -246,7 +216,7 @@
</session>
<session name="OU Simulation">
<program name="Simulator">
<arg flag="-a" constant="VivifyMK1"/>
<arg flag="-a" constant="@AIRCRAFT"/>
<arg flag="-t" constant="sim"/>
<arg flag="--boot"/>
<arg flag="--norc"/>
@@ -258,6 +228,35 @@
<program name="Environment Simulator"/>
<program name="Messages"/>
</session>
<session name="OUAS Replay flight">
<program name="Log Plotter"/>
<program name="Log File Player"/>
<program name="Server">
<arg flag="-n"/>
</program>
<program name="GCS">
<arg flag="-speech"/>
<arg flag="-layout" constant="OPENUAS/openuas_bottom_settings.xml"/>
<arg flag="-maximize"/>
<arg flag="-maps_fill"/>
<arg flag="-center_ac"/>
<arg flag="-mercator"/>
<arg flag="-maps_no_http"/>
<arg flag="-track_size" constant="200"/>
<arg flag="-zoom" constant="0.5"/>
<arg flag="-no_confirm_kill"/>
<arg flag="-srtm"/>
</program>
</session>
<session name="OpenUAS Forward AC via UDP">
<program name="Ivy2Udp">
<arg flag="-b" constant="127:2010"/>
<arg flag="-h" constant="192.168.78.1"/>
<arg flag="-p" constant="4242"/>
<arg flag="-dp" constant="4243"/>
<arg flag="-id" constant="16"/>
</program>
</session>
<session name="OpenUAS Simulation with OBC GUI">
<program name="GCS">
<arg flag="-speech"/>
@@ -271,12 +270,42 @@
<arg flag="-n"/>
</program>
<program name="Simulator">
<arg flag="-a" constant="VivfifyMK1"/>
<arg flag="-a" constant="@AIRCRAFT"/>
<arg flag="-boot"/>
<arg flag="-norc"/>
</program>
<program name="Environment Simulator"/>
</session>
<session name="OpenUAS testflights 2024">
<program name="GCS">
<arg flag="-speech"/>
<arg flag="-layout" constant="OPENUAS/openuas_bottom_settings.xml"/>
<arg flag="-maximize"/>
<arg flag="-maps_fill"/>
<arg flag="-center_ac"/>
<arg flag="-mercator"/>
<arg flag="-maps_no_http"/>
<arg flag="-track_size" constant="200"/>
<arg flag="-zoom" constant="0.5"/>
<arg flag="-no_confirm_kill"/>
<arg flag="-srtm"/>
</program>
<program name="Data Link">
<arg flag="-d" constant="/dev/ttyUSB0"/>
<arg flag="-s" constant="57600"/>
</program>
<program name="Server"/>
</session>
<session name="Desktest">
<program name="Data Link">
<arg flag="-d" constant="/dev/ttyUSB0"/>
<arg flag="-s" constant="57600"/>
</program>
<program name="Server"/>
<program name="GCS"/>
<program name="Messages"/>
<program name="Real-time Plotter"/>
</session>
<session name="Raw Sensors">
<program name="Data Link">
<arg flag="-d" constant="/dev/ttyUSB0"/>
@@ -0,0 +1,102 @@
/*
* Copyright (C) 2024 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 arch/chibios/modules/actuators/actuators_t4_arch.c
* @brief Actuator interface for T4 driver
* @author Sunyou Hwang
*/
#include "modules/actuators/actuators_t4_arch.h"
#include "modules/actuators/actuators_t4.h"
#include "modules/core/abi.h"
#ifndef ACTUATORS_T4_REFRESH_FREQUENCY
#define ACTUATORS_T4_REFRESH_FREQUENCY 200;
#endif
#ifndef ACTUATORS_T4_NUM_MAX_SERVOS
#define ACTUATORS_T4_NUM_MAX_SERVOS 12
#endif
#ifndef ACTUATORS_T4_NUM_MAX_ESCS
#define ACTUATORS_T4_NUM_MAX_ESCS 4
#endif
/**
* Print the configuration variables from the header
*/
PRINT_CONFIG_VAR(ACTUATORS_T4_NB)
int32_t actuators_t4_values[ACTUATORS_T4_NB];
struct ActuatorsT4Out actuators_t4_out_local;
float actuators_t4_extra_data_out_local[255] __attribute__((aligned));
void actuators_t4_arch_init(void) {
/* Arm ESCs and servos by default, Note that only armed servo directly provide force needed for e.g. landing gear */
//TODO: Add option set or check is disarmed / is armed as a default value per actuator
actuators_t4_out_local.esc_arm = (1 << ACTUATORS_T4_NUM_MAX_ESCS) -1;
actuators_t4_out_local.servo_arm = (1 << ACTUATORS_T4_NUM_MAX_SERVOS) - 1;
/* comm_refresh_frequency [Hz] */
actuators_t4_extra_data_out_local[0] = ACTUATORS_T4_REFRESH_FREQUENCY;
}
void actuators_t4_commit(void) {
/*
For developers wanting to improve here note that:
DRIVER_NO: <servo no="DRIVER_NO"/> and SERVO_IDX: defined order in AF config
actuators_t4_values[driver_no] = actuators[servo_idx].val;
get_servo_min_T4(_idx);
get_servo_max_T4(_idx);
get_servo_idx_T4(_idx_driver); returns servo idx
*/
/* Yes, indeed it could well be that we waste two bytes here, feel free to improve
Servos connected to pin outputs 1~10 (Serial Bus),
Note that connector 0 does not exist on a T4 actuators board,
indeed we waste two bytes here, feel free to improve.
*/
actuators_t4_out_local.servo_1_cmd = (int16_t)(actuators_t4_values[1]);
actuators_t4_out_local.servo_2_cmd = (int16_t)(actuators_t4_values[2]);
actuators_t4_out_local.servo_3_cmd = (int16_t)(actuators_t4_values[3]);
actuators_t4_out_local.servo_4_cmd = (int16_t)(actuators_t4_values[4]);
actuators_t4_out_local.servo_5_cmd = (int16_t)(actuators_t4_values[5]);
actuators_t4_out_local.servo_6_cmd = (int16_t)(actuators_t4_values[6]);
actuators_t4_out_local.servo_7_cmd = (int16_t)(actuators_t4_values[7]);
actuators_t4_out_local.servo_8_cmd = (int16_t)(actuators_t4_values[8]);
actuators_t4_out_local.servo_9_cmd = (int16_t)(actuators_t4_values[9]);
actuators_t4_out_local.servo_10_cmd = (int16_t)(actuators_t4_values[10]);
/* PWM Servos (or ESCs) connected to pin outputs 11~12 (PWM) */
actuators_t4_out_local.servo_11_cmd = (int16_t)(actuators_t4_values[11]);
actuators_t4_out_local.servo_12_cmd = (int16_t)(actuators_t4_values[12]);
/* DShot capable ESC's connected to pin outputs 13~16 (DShot) */
actuators_t4_out_local.esc_1_dshot_cmd = (int16_t)(actuators_t4_values[13]);
actuators_t4_out_local.esc_2_dshot_cmd = (int16_t)(actuators_t4_values[14]);
actuators_t4_out_local.esc_3_dshot_cmd = (int16_t)(actuators_t4_values[15]);
actuators_t4_out_local.esc_4_dshot_cmd = (int16_t)(actuators_t4_values[16]);
// Send ABI message
AbiSendMsgACTUATORS_T4_OUT(ABI_ACTUATORS_T4_OUT_ID, &actuators_t4_out_local, &actuators_t4_extra_data_out_local[0]);
}
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2024 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 arch/chibios/modules/actuators/actuators_t4_arch.h
* @brief Actuator interface for T4 driver
*/
#ifndef ACTUATORS_T4_ARCH_H
#define ACTUATORS_T4_ARCH_H
#include "std.h"
// Servo 1 to 12 plus ESC 1 to 4 is a total of 16
#ifndef ACTUATORS_T4_NB
#define ACTUATORS_T4_NB 17 //Not 16 since using 0 as index
#endif
extern int32_t actuators_t4_values[ACTUATORS_T4_NB];
extern void actuators_t4_commit(void);
#define ActuatorT4Set(_i, _v) { actuators_t4_values[_i] = _v; }
#define ActuatorsT4Commit actuators_t4_commit
#endif /* ACTUATORS_T4_ARCH_H */
@@ -0,0 +1,103 @@
/*
* Copyright (C) 2024 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 arch/sim/modules/actuators/actuators_t4_arch.c
* @brief Actuator interface for T4 driver
* @author Sunyou Hwang
*/
#include <stdio.h>
#include "modules/actuators/actuators_t4_arch.h"
#include "modules/actuators/actuators_t4.h"
#include "modules/core/abi.h"
#ifndef ACTUATORS_T4_REFRESH_FREQUENCY
#define ACTUATORS_T4_REFRESH_FREQUENCY 200;
#endif
#ifndef ACTUATORS_T4_NUM_MAX_SERVOS
#define ACTUATORS_T4_NUM_MAX_SERVOS 12
#endif
#ifndef ACTUATORS_T4_NUM_MAX_ESCS
#define ACTUATORS_T4_NUM_MAX_ESCS 4
#endif
/**
* Print the configuration variables from the header
*/
PRINT_CONFIG_VAR(ACTUATORS_T4_NB)
int32_t actuators_t4_values[ACTUATORS_T4_NB];
struct ActuatorsT4Out actuators_t4_out_local;
float actuators_t4_extra_data_out_local[255] __attribute__((aligned));
void actuators_t4_arch_init(void) {
/* Arm ESCs and servos by default, Note that only armed servo directly provide force needed for e.g. landing gear */
//TODO: Add option set or check is disarmed / is armed as a default value per actuator
actuators_t4_out_local.esc_arm = (1 << ACTUATORS_T4_NUM_MAX_ESCS) -1;
actuators_t4_out_local.servo_arm = (1 << ACTUATORS_T4_NUM_MAX_SERVOS) - 1;
/* comm_refresh_frequency [Hz] */
actuators_t4_extra_data_out_local[0] = ACTUATORS_T4_REFRESH_FREQUENCY;
}
void actuators_t4_commit(void) {
/*
For developers wanting to improve here note that:
DRIVER_NO: <servo no="DRIVER_NO"/> and SERVO_IDX: defined order in AF config
actuators_t4_values[driver_no] = actuators[servo_idx].val;
get_servo_min_T4(_idx);
get_servo_max_T4(_idx);
get_servo_idx_T4(_idx_driver); returns servo idx
*/
/* Yes, indeed it could well be that we waste two bytes here, feel free to improve
Servos connected to pin outputs 1~10 (Serial Bus),
Note that connector 0 does not exist on a T4 actuators board,
indeed we waste two bytes here, feel free to improve.
*/
actuators_t4_out_local.servo_1_cmd = (int16_t)(actuators_t4_values[1]);
actuators_t4_out_local.servo_2_cmd = (int16_t)(actuators_t4_values[2]);
actuators_t4_out_local.servo_3_cmd = (int16_t)(actuators_t4_values[3]);
actuators_t4_out_local.servo_4_cmd = (int16_t)(actuators_t4_values[4]);
actuators_t4_out_local.servo_5_cmd = (int16_t)(actuators_t4_values[5]);
actuators_t4_out_local.servo_6_cmd = (int16_t)(actuators_t4_values[6]);
actuators_t4_out_local.servo_7_cmd = (int16_t)(actuators_t4_values[7]);
actuators_t4_out_local.servo_8_cmd = (int16_t)(actuators_t4_values[8]);
actuators_t4_out_local.servo_9_cmd = (int16_t)(actuators_t4_values[9]);
actuators_t4_out_local.servo_10_cmd = (int16_t)(actuators_t4_values[10]);
/* PWM Servos (or ESCs) connected to pin outputs 11~12 (PWM) */
actuators_t4_out_local.servo_11_cmd = (int16_t)(actuators_t4_values[11]);
actuators_t4_out_local.servo_12_cmd = (int16_t)(actuators_t4_values[12]);
/* DShot capable ESC's connected to pin outputs 13~16 (DShot) */
actuators_t4_out_local.esc_1_dshot_cmd = (int16_t)(actuators_t4_values[13]);
actuators_t4_out_local.esc_2_dshot_cmd = (int16_t)(actuators_t4_values[14]);
actuators_t4_out_local.esc_3_dshot_cmd = (int16_t)(actuators_t4_values[15]);
actuators_t4_out_local.esc_4_dshot_cmd = (int16_t)(actuators_t4_values[16]);
// Send ABI message
AbiSendMsgACTUATORS_T4_OUT(ABI_ACTUATORS_T4_OUT_ID, &actuators_t4_out_local, &actuators_t4_extra_data_out_local[0]);
}
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2024 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 arch/sim/modules/actuators/actuators_t4_arch.h
* @brief Actuator interface for T4 driver
*/
#ifndef ACTUATORS_T4_ARCH_H
#define ACTUATORS_T4_ARCH_H
#include "std.h"
// Servo 1 to 12 plus ESC 1 to 4 is a total of 16
#ifndef ACTUATORS_T4_NB
#define ACTUATORS_T4_NB 17 //Not 16 since using 0 as index
#endif
extern int32_t actuators_t4_values[ACTUATORS_T4_NB];
extern void actuators_t4_commit(void);
#define ActuatorT4Set(_i, _v) { actuators_t4_values[_i] = _v; }
#define ActuatorsT4Commit actuators_t4_commit
#endif /* ACTUATORS_T4_ARCH_H */
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2024 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 "modules/actuators/actuators_t4.h"
* @author Alessandro Mancinelli, Sunyou Hwang, OpenUAS
* @brief Uses a T4 Actuators Board as fly by wire system. This Board can control serial bus servos, ESC's and PWM servos, with as big benefir providing real time telemetry in return into the autopilot state.
* Read more on how to create your own T4 Board here: https://github.com/tudelft/t4_actuators_board/
*/
#ifndef ACTUATORS_T4_H
#define ACTUATORS_T4_H
#include "modules/actuators/actuators_t4_arch.h"
#include "actuators_t4_uart.h" //#include "modules/actuators/actuators_t4_uart.h"
/** Arch dependent init file.
* implemented in arch files
*/
extern void actuators_t4_arch_init(void);
#define ActuatorsT4Init() actuators_t4_arch_init()
#endif /* ACTUATORS_T4_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,149 @@
/*
* Copyright (C) 2024 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 "modules/actuators/actuators_t4_uart.h"
* @author Alessandro Mancinelli, Sunyou Hwang, OpenUAS
* @brief Uses a T4 Actuators Board as fly by wire system. This Board can control serial bus servos, ESC's and PWM servos, with as big benefir providing real time telemetry in return into the autopilot state.
* Read more on how to create your own T4 Board here: https://github.com/tudelft/t4_actuators_board/
*
*/
#ifndef ACTUATORS_T4_UART_H
#define ACTUATORS_T4_UART_H
#define START_BYTE_ACTUATORS_T4 0x9A //1st start block identifier byte
#include "std.h"
#include <stdbool.h>
#include <stdlib.h>
#include "generated/airframe.h"
#include "pprzlink/pprz_transport.h"
struct __attribute__((__packed__)) ActuatorsT4In {
/* ESCs telemetry & error code */
/* RPM output from ESC's to flightcontroller */
int16_t esc_1_rpm;
int16_t esc_2_rpm;
int16_t esc_3_rpm;
int16_t esc_4_rpm;
/* Error code from ESC's to flightcontroller */
int16_t esc_1_error_code;
int16_t esc_2_error_code;
int16_t esc_3_error_code;
int16_t esc_4_error_code;
/* Current (mA) output from ESC's to flightcontroller */
int16_t esc_1_current;
int16_t esc_2_current;
int16_t esc_3_current;
int16_t esc_4_current;
/* Voltage (mV) output from ESC's to flightcontroller */
int16_t esc_1_voltage;
int16_t esc_2_voltage;
int16_t esc_3_voltage;
int16_t esc_4_voltage;
/* Temperature (Celcius) not implemented, since it will take away bus bandwidth, feel free to add if really nned it, preferably with low message rate */
//int16_t esc_1_temperature; // FIXME Kelvin as SI it is might be better?
//int16_t esc_2_temperature;
//int16_t esc_3_temperature;
//int16_t esc_4_temperature;
/* SERVOS telemetry where angle is in Degrees times 100 */
int16_t servo_1_angle;
int16_t servo_2_angle;
int16_t servo_3_angle;
int16_t servo_4_angle;
int16_t servo_5_angle;
int16_t servo_6_angle;
int16_t servo_7_angle;
int16_t servo_8_angle;
int16_t servo_9_angle;
int16_t servo_10_angle;
/* Note that PWM servos nor PWM ESC's give feedback in real life. Servos have estimated angles */
int16_t servo_11_angle;
int16_t servo_12_angle;
/* Servo load in UNDEFINED Units */
int16_t servo_1_load;
int16_t servo_2_load;
int16_t servo_3_load;
int16_t servo_4_load;
int16_t servo_5_load;
int16_t servo_6_load;
int16_t servo_7_load;
int16_t servo_8_load;
int16_t servo_9_load;
int16_t servo_10_load;
/* Note that PWM servos or ESC (11 and 12) give no real feedback on load */
//int16_t servo_11_load;
//int16_t servo_12_load;
uint16_t bitmask_servo_health; //Bitmask of servo health status
/* Rolling message in */
float rolling_msg_in;
uint8_t rolling_msg_in_id;
/* CHECKSUM for the data packages */
uint8_t checksum_in;
};
struct __attribute__((__packed__)) ActuatorsT4Out {
/* Arming Command */
uint8_t esc_arm; //Arm ESC boolean in bitfield
uint16_t servo_arm; //Arm servo boolean in bitfield
/* ESC cmd values 0 - 1999 */
int16_t esc_1_dshot_cmd;
int16_t esc_2_dshot_cmd;
int16_t esc_3_dshot_cmd;
int16_t esc_4_dshot_cmd;
/* Servo cmd in Degrees * 100 */
int16_t servo_1_cmd;
int16_t servo_2_cmd;
int16_t servo_3_cmd;
int16_t servo_4_cmd;
int16_t servo_5_cmd;
int16_t servo_6_cmd;
int16_t servo_7_cmd;
int16_t servo_8_cmd;
int16_t servo_9_cmd;
int16_t servo_10_cmd;
int16_t servo_11_cmd;
int16_t servo_12_cmd;
/* Rolling message out */
float rolling_msg_out;
uint8_t rolling_msg_out_id;
/* CHECKSUM */
uint8_t checksum_out;
};
extern void actuators_t4_uart_init(void);
extern void actuators_t4_uart_parse_msg_in(void);
extern void actuators_t4_uart_event(void);
#endif /* ACTUATORS_T4_UART_H */
+2 -1
View File
@@ -22,7 +22,7 @@
/**
* @file modules/core/abi_common.h
*
* Common tools for ABI middelware.
* Common tools for ABI middleware.
*/
#ifndef ABI_COMMON_H
@@ -35,6 +35,7 @@
#include "modules/gps/gps.h"
#include "modules/radio_control/radio_control.h"
#include "modules/actuators/actuators.h"
#include "modules/actuators/actuators_t4_uart.h"
/* Include here headers with structure definition you may want to use with ABI
* Ex: '#include "modules/gps/gps.h"' in order to use the GpsState structure
*/
+5 -1
View File
@@ -120,7 +120,7 @@
#endif
/*
* IDs of Incidence angles (message 24)
* IDs of Incidence angles (message 25)
*/
#ifndef AOA_ADC_ID
#define AOA_ADC_ID 1
@@ -130,6 +130,10 @@
#define AOA_PWM_ID 2
#endif
#ifndef AOA_T4_ID
#define AOA_T4_ID 3
#endif
#ifndef INCIDENCE_NPS_ID
#define INCIDENCE_NPS_ID 20
#endif
File diff suppressed because it is too large Load Diff
+68
View File
@@ -0,0 +1,68 @@
/*
* Copyright (C) 2024 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 modules/sensors/aoa_t4.h
* @author Sunyou Hwang, OpenUAS
* @brief Angle of Attack and optionally Sideslip Angle sensor using T4 Actuators Board and a modified serial bus servo
* The servo as AOA sensor must be of hall effect type and have motor and gears removed to minimize friction and this solution to work.
*
* Read more on how to create your own T4 Board here: https://github.com/tudelft/t4_actuators_board/
*
* SENSOR, example : Feetech 3032 Serial Bus Servo
*/
#ifndef AOA_T4_H
#define AOA_T4_H
#include "std.h"
struct Aoa_T4 {
uint32_t raw; ///< Measurement in degrees times 100 from the sensor before applying direction and offset and unit scale conversion
float angle; ///< Angle of attack in radians after applying direction and offset
float offset; ///< Angle of attack offset in radians
float filter; ///< Filter level for sensor output, where 0.0 is no filtering and 0.95 for extreme filtering, were 1.0 would output an (useless) constant value.
};
extern struct Aoa_T4 aoa_t4; // Stores values of angle of attack sensor
/* To allow for separate filter options an own SSA structure is available */
extern struct Aoa_T4 ssa_t4; // Stores values of sideslip angle sensor
/** Selection of sensor type to be send over telemetry for debugging or online logging
*/
enum Aoa_Type {
SEND_TYPE_AOA,
SEND_TYPE_SIDESLIP
};
extern enum Aoa_Type aoa_send_type;
/* Compensation Sensor angle to theta angle */
extern float aoa_t4_a1;
extern float aoa_t4_b1;
extern float aoa_t4_a2;
extern float aoa_t4_b2;
void aoa_t4_init(void);
void aoa_t4_update(void);
void aoa_t4_init_filters(void);
#endif /* AOA_T4_H */