28 changes: 4 additions & 24 deletions conf/airframes/ENAC/quadrotor/maya_indoor.xml
Expand Up @@ -18,6 +18,7 @@
<module name="radio_control" type="sbus"/>
<configure name="BARO_PERIODIC_FREQUENCY" value="50"/>
<define name="RADIO_KILL_SWITCH" value="RADIO_GAIN1"/>
<define name="INS_EKF2_OPTITRACK" value="TRUE"/>
</target>
<target name="nps" board="pc">
<module name="fdm" type="jsbsim"/>
Expand All @@ -43,18 +44,14 @@
<module name="stabilization" type="indi"/>
<module name="guidance" type="indi"/>

<module name="ins" type="ekf2">
<define name="INS_EKF2_OPTITRACK" value="TRUE"/>
</module>
<module name="ins" type="ekf2"/>
<!-- <module name="preflight_checks"/> -->

<!--module name="filter" type="1euro_imu">
<define name="AHRS_ICQ_IMU_ID" value="IMU_F1E_ID"/>
<define name="AHRS_ALIGNER_IMU_ID" value="IMU_F1E_ID"/>
</module-->

<module name="motor_mixing"/>

<module name="tag_tracking">
<configure name="JEVOIS_UART" value="UART3"/>
</module>
Expand All @@ -73,19 +70,13 @@
<servo name="FL" no="4" min="0" neutral="100" max="2000"/>
</servos>


<commands>
<axis name="ROLL" failsafe_value="0"/>
<axis name="PITCH" failsafe_value="0"/>
<axis name="YAW" failsafe_value="0"/>
<axis name="THRUST" failsafe_value="0"/>
</commands>

<section name="MIXING" prefix="MOTOR_MIXING_">
<define name="TYPE" value="QUAD_X"/>
<define name="REVERSE" value="TRUE"/>
</section>

<command_laws>
<set servo="FR" value="autopilot_get_motors_on() ? actuators_pprz[0] : -MAX_PPRZ"/>
<set servo="BR" value="autopilot_get_motors_on() ? actuators_pprz[1] : -MAX_PPRZ"/>
Expand Down Expand Up @@ -167,23 +158,11 @@
<define name="REF_MAX_ZDD" value=" 0.4*9.81"/>
<define name="REF_MIN_ZD" value="-2."/>
<define name="REF_MAX_ZD" value=" 2."/>
<define name="HOVER_KP" value="90"/>
<define name="HOVER_KD" value="110"/>
<define name="HOVER_KI" value="10"/>
<define name="NOMINAL_HOVER_THROTTLE" value="0.35"/>
<define name="ADAPT_THROTTLE_ENABLED" value="TRUE"/>
<define name="ADAPT_NOISE_FACTOR" value="1."/>
<define name="ADAPT_INITIAL_HOVER_THROTTLE" value="0.3"/>
</section>

<section name="GUIDANCE_H" prefix="GUIDANCE_H_">
<define name="MAX_BANK" value="30" unit="deg"/>
<define name="PGAIN" value="41"/>
<define name="DGAIN" value="108"/>
<define name="IGAIN" value="20"/>
<define name="NGAIN" value="0"/>
<!-- feedforward -->
<define name="AGAIN" value="0"/>
<define name="REF_MAX_SPEED" value="0.5"/>
<define name="REF_MAX_ACCEL" value="2."/>
</section>
Expand Down Expand Up @@ -225,9 +204,10 @@
</section>

<section name="SIMULATOR" prefix="NPS_">
<define name="ACTUATOR_NAMES" value="nw_motor, ne_motor, se_motor, sw_motor" type="string[]"/>
<define name="ACTUATOR_NAMES" value="ne_motor, se_motor, sw_motor, nw_motor" type="string[]"/>
<define name="JSBSIM_MODEL" value="simple_x_quad_ccw" type="string"/>
<define name="COMMANDS_NB" value="4"/>
<define name="NO_MOTOR_MIXING" value="TRUE"/>
</section>

</airframe>
24 changes: 3 additions & 21 deletions conf/airframes/ENAC/quadrotor/maya_outdoor.xml
Expand Up @@ -63,8 +63,6 @@
<define name="AHRS_ALIGNER_IMU_ID" value="IMU_F1E_ID"/>
</module-->

<module name="motor_mixing"/>

<module name="tag_tracking">
<configure name="JEVOIS_UART" value="UART3"/>
</module>
Expand All @@ -90,11 +88,6 @@
<axis name="THRUST" failsafe_value="0"/>
</commands>

<section name="MIXING" prefix="MOTOR_MIXING_">
<define name="TYPE" value="QUAD_X"/>
<define name="REVERSE" value="TRUE"/>
</section>

<command_laws>
<set servo="FR" value="autopilot_get_motors_on() ? actuators_pprz[0] : -MAX_PPRZ"/>
<set servo="BR" value="autopilot_get_motors_on() ? actuators_pprz[1] : -MAX_PPRZ"/>
Expand Down Expand Up @@ -185,23 +178,11 @@
<define name="REF_MAX_ZDD" value=" 0.4*9.81"/>
<define name="REF_MIN_ZD" value="-2."/>
<define name="REF_MAX_ZD" value=" 2."/>
<define name="HOVER_KP" value="90"/>
<define name="HOVER_KD" value="110"/>
<define name="HOVER_KI" value="10"/>
<define name="NOMINAL_HOVER_THROTTLE" value="0.35"/>
<define name="ADAPT_THROTTLE_ENABLED" value="TRUE"/>
<define name="ADAPT_NOISE_FACTOR" value="1."/>
<define name="ADAPT_INITIAL_HOVER_THROTTLE" value="0.3"/>
</section>

<section name="GUIDANCE_H" prefix="GUIDANCE_H_">
<define name="MAX_BANK" value="30" unit="deg"/>
<define name="PGAIN" value="41"/>
<define name="DGAIN" value="108"/>
<define name="IGAIN" value="20"/>
<define name="NGAIN" value="0"/>
<!-- feedforward -->
<define name="AGAIN" value="0"/>
<define name="REF_MAX_SPEED" value="4."/>
<define name="REF_MAX_ACCEL" value="2."/>
</section>
Expand Down Expand Up @@ -243,9 +224,10 @@
</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="ACTUATOR_NAMES" value="ne_motor, se_motor, sw_motor, nw_motor" type="string[]"/>
<define name="JSBSIM_MODEL" value="anton" type="string"/>
<define name="COMMANDS_NB" value="4"/>
<define name="NO_MOTOR_MIXING" value="TRUE"/>
</section>

</airframe>
Expand Down
1 change: 1 addition & 0 deletions conf/airframes/ENAC/quadrotor/niquad_wind.xml
Expand Up @@ -258,6 +258,7 @@
<section name="SIMULATOR" prefix="NPS_">
<define name="ACTUATOR_NAMES" value="front_motor, right_motor, back_motor, left_motor" type="string[]"/>
<define name="JSBSIM_MODEL" value="simple_quad_wind" type="string"/>
<define name="COMMANDS_NB" value="4"/>
</section>

</airframe>
69 changes: 19 additions & 50 deletions conf/airframes/ENAC/quadrotor/robobee.xml
Expand Up @@ -11,13 +11,17 @@
</description>

<firmware name="rotorcraft">
<configure name="PERIODIC_FREQUENCY" value="512"/>
<configure name="PERIODIC_FREQUENCY" value="500"/>
<configure name="AHRS_PROPAGATE_FREQUENCY" value="$(PERIODIC_FREQUENCY)"/>

<target name="ap" board="tawaki_1.1">
<module name="radio_control" type="sbus"/>
<module name="radio_control" type="sbus"/>
<configure name="BARO_PERIODIC_FREQUENCY" value="50"/>
<define name="RADIO_KILL_SWITCH" value="RADIO_GAIN1"/>
<define name="RADIO_KILL_SWITCH" value="RADIO_GAIN1"/>
<module name="filter" type="1euro_imu">
<define name="AHRS_ICQ_IMU_ID" value="IMU_F1E_ID"/>
<define name="AHRS_ALIGNER_IMU_ID" value="IMU_F1E_ID"/>
</module>
</target>

<target name="nps" board="pc">
Expand All @@ -32,9 +36,7 @@

<module name="telemetry" type="xbee_api"/>

<module name="actuators" type="dshot">
<!--define name="DSHOT_SPEED" value="300"/-->
</module>
<module name="actuators" type="dshot"/>
<module name="board" type="tawaki">
<define name="IMU_MPU_LOWPASS_FILTER" value="MPU60X0_DLPF_256HZ"/>
<define name="IMU_MPU_ACCEL_LOWPASS_FILTER" value="MPU60X0_DLPF_ACC_218HZ"/>
Expand All @@ -48,12 +50,7 @@
<define name="WLS_N_U" value="4" />
<define name="WLS_N_V" value="4" />
</module>
<module name="guidance" type="indi">
<define name="GUIDANCE_INDI_SPEED_GAIN" value="3.0"/>
<define name="GUIDANCE_INDI_SPECIFIC_FORCE_GAIN" value="-500.0"/>
<define name="GUIDANCE_INDI_THRUST_DYNAMICS_FREQ" value="15.6"/>
<define name="GUIDANCE_INDI_RC_DEBUG" value="FALSE"/>
</module>
<module name="guidance" type="indi"/>

<module name="ins"/>
<module name="ahrs" type="int_cmpl_quat">
Expand All @@ -62,11 +59,6 @@
</module>
<module name="air_data"/>

<module name="filter" type="1euro_imu">
<define name="AHRS_ICQ_IMU_ID" value="IMU_F1E_ID"/>
<define name="AHRS_ALIGNER_IMU_ID" value="IMU_F1E_ID"/>
</module>

<module name="tag_tracking">
<configure name="JEVOIS_UART" value="UART4" description="dummy uart in this config"/>
</module>
Expand All @@ -75,8 +67,6 @@
<configure name="EXTRA_DL_BAUD" value="B115200"/>
</module>

<module name="motor_mixing"/>

<module name="flight_recorder"/>
<!--module name="logger" type="tune_indi"/-->
</firmware>
Expand All @@ -95,26 +85,13 @@
<axis name="THRUST" failsafe_value="0"/>
</commands>

<section name="MIXING" prefix="MOTOR_MIXING_">
<define name="TYPE" value="QUAD_X"/>
<define name="REVERSE" value="TRUE"/>
</section>

<!--command_laws>
<call fun="motor_mixing_run(autopilot_get_motors_on(),FALSE,values)"/>
<set servo="FR" value="motor_mixing.commands[MOTOR_FRONT_RIGHT]"/>
<set servo="BR" value="motor_mixing.commands[MOTOR_BACK_RIGHT]"/>
<set servo="BL" value="motor_mixing.commands[MOTOR_BACK_LEFT]"/>
<set servo="FL" value="motor_mixing.commands[MOTOR_FRONT_LEFT]"/>
</command_laws-->
<command_laws>
<set servo="FR" value="autopilot_get_motors_on() ? actuators_pprz[0] : -MAX_PPRZ"/>
<set servo="BR" value="autopilot_get_motors_on() ? actuators_pprz[1] : -MAX_PPRZ"/>
<set servo="BL" value="autopilot_get_motors_on() ? actuators_pprz[2] : -MAX_PPRZ"/>
<set servo="FL" value="autopilot_get_motors_on() ? actuators_pprz[3] : -MAX_PPRZ"/>
</command_laws>


<section name="IMU" prefix="IMU_">
<define name="GYRO_P_SIGN" value="-1"/>
<define name="GYRO_Q_SIGN" value="-1"/>
Expand Down Expand Up @@ -148,7 +125,7 @@
<define name="BODY_TO_IMU_PSI" value="0." unit="deg"/>
</section>

<include href="conf/mag/delft_valkenburg.xml"/>
<include href="conf/mag/toulouse_muret.xml"/>

<section name="INS" prefix="INS_">
<define name="INV_NXZ" value="0.25"/>
Expand Down Expand Up @@ -192,7 +169,6 @@
<define name="USE_ADAPTIVE" value="FALSE"/>
<define name="ADAPTIVE_MU" value="0.0001"/>


<!-- Full INDI -->
<!-- control effectiveness -->
<define name="G1" type="matrix">
Expand All @@ -216,28 +192,22 @@
<define name="REF_MAX_ZDD" value=" 0.4*9.81"/>
<define name="REF_MIN_ZD" value="-1.5"/>
<define name="REF_MAX_ZD" value=" 1."/>
<define name="HOVER_KP" value="90"/>
<define name="HOVER_KD" value="110"/>
<define name="HOVER_KI" value="10"/>
<define name="NOMINAL_HOVER_THROTTLE" value="0.35"/>
<define name="ADAPT_THROTTLE_ENABLED" value="TRUE"/>
<define name="ADAPT_NOISE_FACTOR" value="1."/>
<define name="ADAPT_INITIAL_HOVER_THROTTLE" value="0.3"/>
</section>


<section name="GUIDANCE_H" prefix="GUIDANCE_H_">
<define name="MAX_BANK" value="20" unit="deg"/>
<define name="PGAIN" value="41"/>
<define name="DGAIN" value="108"/>
<define name="IGAIN" value="20"/>
<define name="NGAIN" value="0"/>
<!-- feedforward -->
<define name="AGAIN" value="0"/>
<define name="REF_MAX_SPEED" value="4."/>
<define name="REF_MAX_ACCEL" value="2."/>
</section>

<section name="GUIDANCE_INDI" prefix="GUIDANCE_INDI_">
<define name="SPEED_GAIN" value="3.0"/>
<define name="SPECIFIC_FORCE_GAIN" value="-500.0"/>
<define name="THRUST_DYNAMICS_FREQ" value="15.6"/>
<define name="RC_DEBUG" value="FALSE"/>
</section>

<section name="NAV">
<define name="ARRIVED_AT_WAYPOINT" value="2.0"/>
<define name="NAV_DESCEND_VSPEED" value="-0.5"/>
Expand Down Expand Up @@ -271,10 +241,9 @@
<define name="ACTUATORS_ORDER" value="{3, 2, 1, 0}"/>
<define name="PYBULLET_MODULE" value="simple_quad_sim" type="string"/>
<define name="PYBULLET_URDF" value="robobee.urdf" type="string"/>
<!--define name="ACTUATOR_NAMES" value="nw_motor, ne_motor, se_motor, sw_motor" type="string[]"/>
<!--define name="ACTUATOR_NAMES" value="ne_motor, se_motor, sw_motor, nw_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"/>
<define name="COMMANDS_NB" value="4"/>
<define name="NO_MOTOR_MIXING" value="TRUE"/>
</section>

Expand Down
266 changes: 0 additions & 266 deletions conf/airframes/ENAC/quadrotor/ulysse_indi.xml

This file was deleted.

4 changes: 1 addition & 3 deletions conf/airframes/examples/bebop2_indi.xml
Expand Up @@ -22,9 +22,7 @@
<module name="imu" type="bebop"/>
<module name="gps" type="ublox"/>
<module name="stabilization" type="indi_simple"/>
<module name="ins" type="ekf2">
<define name="INS_EKF2_OPTITRACK" value="true"/>
</module>
<module name="ins" type="ekf2"/>

<module name="air_data"/>
<module name="gps" type="ubx_ucenter"/>
Expand Down
8 changes: 4 additions & 4 deletions conf/airframes/tudelft/rot_wing_25kg.xml
Expand Up @@ -144,7 +144,7 @@
<servo no="2" name="MOTOR_BACK" min="-8191" neutral="-5000" max="8191"/>
<servo no="3" name="MOTOR_LEFT" min="-8191" neutral="-5000" max="8191"/>
<servo no="4" name="MOTOR_PUSH" min="-8191" neutral="-8191" max="8191"/>
<servo no="5" name="SERVO_ELEVATOR" min="-8191" neutral="-8191" max="4900"/>
<servo no="5" name="SERVO_ELEVATOR" min="-3191" neutral="-3191" max="4900"/>
<servo no="6" name="SERVO_RUDDER" min="-6500" neutral="0" max="6500"/>
<servo no="7" name="ROTATION_MECH" min="8191" neutral="0" max="-8191"/>
<servo no="8" name="AIL_RIGHT" min="-8000" neutral="-1000" max="5000"/>
Expand All @@ -161,7 +161,7 @@
<servo no="2" name="BMOTOR_BACK" min="-8191" neutral="-5000" max="8191"/>
<servo no="3" name="BMOTOR_LEFT" min="-8191" neutral="-5000" max="8191"/>
<servo no="4" name="BMOTOR_PUSH" min="-8191" neutral="-8191" max="8191"/>
<servo no="5" name="BSERVO_ELEVATOR" min="-8191" neutral="-8191" max="4900"/>
<servo no="5" name="BSERVO_ELEVATOR" min="-3191" neutral="-3191" max="4900"/>
<servo no="6" name="BSERVO_RUDDER" min="-6500" neutral="0" max="6500"/>
<servo no="7" name="BROTATION_MECH" min="8191" neutral="0" max="-8191"/>
<servo no="8" name="BAIL_RIGHT" min="-8000" neutral="-1000" max="5000"/>
Expand Down Expand Up @@ -244,7 +244,7 @@
<define name="HOVER_ROLL_PITCH_COEF" value="{0.015, -0.011}"/>
<define name="HOVER_ROLL_ROLL_COEF" value="{0.0, -0.0}"/>

<define name="K_ELEVATOR" value="{ 1.27655, -13.3525, -80.0}"/>
<define name="K_ELEVATOR" value="{ 1.27655, -13.3525, -96.0}"/>
<define name="K_RUDDER" value="{-72.5037, -0.9329, -3.23651}"/>
<define name="K_AILERON" value="2.777647188"/>
<define name="K_FLAPERON" value="2.0439"/>
Expand Down Expand Up @@ -413,7 +413,7 @@
</section>

<section name="GUIDANCE_H" prefix="GUIDANCE_H_">
<define name="MAX_BANK" value="30" unit="deg"/>
<define name="MAX_BANK" value="20" unit="deg"/>
<define name="USE_SPEED_REF" value="TRUE"/>

<!-- Gains -->
Expand Down
6 changes: 3 additions & 3 deletions conf/airframes/tudelft/rot_wing_v3d.xml
Expand Up @@ -68,7 +68,7 @@
</module>
<module name="airspeed" type="ms45xx_i2c">
<define name="MS45XX_I2C_DEV" value="i2c2"/>
<define name="MS45XX_PRESSURE_SCALE" value="1.9077609"/>
<define name="MS45XX_PRESSURE_SCALE" value="1.618426"/>
<define name="USE_AIRSPEED_LOWPASS_FILTER" value="TRUE"/>
<define name="MS45XX_LOWPASS_TAU" value="0.15"/>
<define name="AIRSPEED_MS45XX_SEND_ABI" value="1"/>
Expand Down Expand Up @@ -192,7 +192,7 @@
<servo no="2" name="MOTOR_BACK" min="0" neutral="1000" max="8191"/>
<servo no="3" name="MOTOR_LEFT" min="0" neutral="1000" max="8191"/>
<servo no="4" name="MOTOR_PUSH" min="0" neutral="0" max="8191"/>
<servo no="5" name="ROTATION_MECH" min="-2842" neutral="1053" max="4947"/>
<servo no="5" name="ROTATION_MECH" min="-2375" neutral="-172" max="2031"/>
</servos>

<!-- CAN BUS 1 command outputs-->
Expand All @@ -207,7 +207,7 @@
<servo no="1" name="BMOTOR_RIGHT" min="0" neutral="1000" max="8191"/>
<servo no="2" name="BMOTOR_BACK" min="0" neutral="1000" max="8191"/>
<servo no="3" name="BMOTOR_LEFT" min="0" neutral="1000" max="8191"/>
<servo no="5" name="BROTATION_MECH" min="-2842" neutral="1053" max="4947"/>
<servo no="5" name="BROTATION_MECH" min="-2375" neutral="-172" max="2031"/>
</servos>

<!-- CAN BUS 2 command outputs-->
Expand Down
4 changes: 1 addition & 3 deletions conf/airframes/tudelft/rot_wing_v3e.xml
Expand Up @@ -197,7 +197,7 @@

<!-- CAN BUS 1 command outputs-->
<servos driver="Uavcan1Cmd">
<servo no="6" name="SERVO_ELEVATOR" min="8191" neutral="8191" max="-4349"/>
<servo no="6" name="SERVO_ELEVATOR" min="5400" neutral="5400" max="-4349"/>
<servo no="7" name="SERVO_RUDDER" min="-5225" neutral="0" max="5225"/>
</servos>

Expand Down Expand Up @@ -266,8 +266,6 @@
<set VALUE="($hover_off? ($servo_hold? -9600 : pfc_actuators_value(9, -9600)) : actuators_pprz[2])" SERVO="BMOTOR_BACK"/>
<set VALUE="($hover_off? ($servo_hold? -9600 : pfc_actuators_value(10, -9600)) : actuators_pprz[3])" SERVO="BMOTOR_LEFT"/>
<set VALUE="pfc_actuators_value(6, rotwing_state_skewing.servo_pprz_cmd)" SERVO="BROTATION_MECH"/>

<call fun="actuators_pprz[9] = (rotwing_state_skewing.servo_pprz_cmd + MAX_PPRZ) / 2."/><!-- Fill skew for NPS: see NPS_ACTUATOR_NAMES for index -->
</command_laws>

<section PREFIX="SYS_ID_" NAME="SYS_ID">
Expand Down
532 changes: 532 additions & 0 deletions conf/airframes/tudelft/rot_wing_v3f.xml

Large diffs are not rendered by default.

532 changes: 532 additions & 0 deletions conf/airframes/tudelft/rot_wing_v3g.xml

Large diffs are not rendered by default.

532 changes: 532 additions & 0 deletions conf/airframes/tudelft/rot_wing_v3h.xml

Large diffs are not rendered by default.

22 changes: 3 additions & 19 deletions conf/flight_plans/flight_plan.dtd
Expand Up @@ -28,18 +28,17 @@
<!ELEMENT exceptions (exception*)>

<!ELEMENT blocks (block+)>
<!ELEMENT block (exception|while|heading|attitude|manual|go|xyz|set|call|call_once|circle|deroute|stay|follow|survey_rectangle|for|return|eight|oval|home|path|guided)*>
<!ELEMENT block (exception|while|heading|attitude|go|xyz|set|call|call_once|circle|deroute|stay|follow|survey_rectangle|for|return|eight|oval|home|path|guided)*>

<!ELEMENT include (arg|with)*>
<!ELEMENT arg EMPTY>
<!ELEMENT with EMPTY>

<!ELEMENT while (exception|while|heading|attitude|manual|go|xyz|set|call|call_once|circle|deroute|stay|follow|survey_rectangle|for|return|eight|oval|path|guided)*>
<!ELEMENT for (exception|while|heading|attitude|manual|go|xyz|set|call|call_once|circle|deroute|stay|follow|survey_rectangle|for|return|eight|oval|path|guided)*>
<!ELEMENT while (exception|while|heading|attitude|go|xyz|set|call|call_once|circle|deroute|stay|follow|survey_rectangle|for|return|eight|oval|path|guided)*>
<!ELEMENT for (exception|while|heading|attitude|go|xyz|set|call|call_once|circle|deroute|stay|follow|survey_rectangle|for|return|eight|oval|path|guided)*>
<!ELEMENT exception EMPTY>
<!ELEMENT heading EMPTY>
<!ELEMENT attitude EMPTY>
<!ELEMENT manual EMPTY>
<!ELEMENT go EMPTY>
<!ELEMENT xyz EMPTY>
<!ELEMENT set EMPTY>
Expand Down Expand Up @@ -188,21 +187,6 @@ nav_type CDATA #IMPLIED
nav_params CDATA #IMPLIED
until CDATA #IMPLIED>

<!ATTLIST manual
pitch CDATA #REQUIRED
roll CDATA #REQUIRED
yaw CDATA #REQUIRED
vmode CDATA #IMPLIED
alt CDATA #IMPLIED
height CDATA #IMPLIED
throttle CDATA #IMPLIED
climb CDATA #IMPLIED
pre_call CDATA #IMPLIED
post_call CDATA #IMPLIED
nav_type CDATA #IMPLIED
nav_params CDATA #IMPLIED
until CDATA #IMPLIED>

<!ATTLIST go
wp CDATA #REQUIRED
wp_qdr CDATA #IMPLIED
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/ins_ext_pose.xml
Expand Up @@ -22,7 +22,7 @@
<file name="ins_ext_pose.h"/>
</header>
<init fun="ins_ext_pose_init()"/>
<periodic fun="ins_ext_pose_run()" freq="512" />
<periodic fun="ins_ext_pose_run()"/>
<datalink message="EXTERNAL_POSE" fun="ins_ext_pose_msg_update(buf)"/>

<makefile target="ap">
Expand Down
29 changes: 29 additions & 0 deletions conf/modules/lidar_vl53l5cx.xml
@@ -0,0 +1,29 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="lidar_vl53l5cx" dir="lidar" task="sensors">
<doc>
<description>
VL53L5CX multizone range sensor.
Sends LIDAR_DATA Abi messages.
</description>
<configure name="LIDAR_VL53L5CX_I2C_DEV" value="i2c2" description="I2C device to use for the VL53L5CX sensor"/>
<define name="LIDAR_VL53L5CX_I2C_ADDR" value="0x52" description="I2C address"/>
</doc>
<dep>
<depends>i2c</depends>
</dep>
<header>
<file name="lidar_vl53l5cx.h"/>
</header>
<init fun="lidar_vl53l5cx_init()"/>
<periodic fun="lidar_vl53l5cx_periodic()" freq="5.0"/>
<makefile>
<configure name="LIDAR_VL53L5CX_I2C_DEV" default="i2c2" case="lower|upper"/>
<define name="LIDAR_VL53L5CX_I2C_DEV" value="$(LIDAR_VL53L5CX_I2C_DEV_LOWER)"/>
<define name="USE_$(LIDAR_VL53L5CX_I2C_DEV_UPPER)"/>

<file_arch name="lidar_vl53l5cx.c"/>
<file name="vl53l5cx_api.c" dir="peripherals"/>
<file_arch name="vl53l5cx_platform.c"/>
<test arch="chibios"/>
</makefile>
</module>
109 changes: 109 additions & 0 deletions conf/simulator/jsbsim/aircraft/Systems/aerodynamics_falcon.xml
@@ -0,0 +1,109 @@
<aerodynamics>

<axis name="YAW">
<function name="elevon_yaw" frame="BODY" unit="FT*LBS">
<sum>
<product>
<property>fcs/ele_left_lag</property>
<value> -0.35 </value>
</product>
<product>
<property>fcs/ele_right_lag</property>
<value> -.35 </value>
</product>
</sum>
</function>
</axis>

<axis name="PITCH">
<function name="elevon_pitch" frame="BODY" unit="FT*LBS">
<sum>
<product>
<property>fcs/ele_left_lag</property>
<value> -0.0417 </value>
</product>
<product>
<property>fcs/ele_right_lag</property>
<value> .0417 </value>
</product>
</sum>
</function>
</axis>

<axis name="LIFT">

<function name="aero/force/Lift_alpha">
<description>Lift due to alpha</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<table>
<independentVar lookup="row">aero/alpha-deg</independentVar>
<tableData>
-180 0.14
-140 -0.80
-110 -0.63
-102 -0.74
-98 -0.64
-90 0.0
-85 0.15
-80 0.25
-75 0.42
0 0.0
45 0.8
90 0.0
135 -0.8
180 0.0
</tableData>
</table>
</product>
</function>

</axis>

<axis name="DRAG">

<function name="aero/force/Drag_basic">
<description>Drag</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<table>
<independentVar lookup="row">aero/alpha-deg</independentVar>
<tableData>
-180 1.7
-160 1.62
-100 0.4
-90 0.15
-85 0.17
-75 0.22
-70 0.33
-65 0.6128
-20 1.36
-4 1.45
15 1.35
30 1.12
</tableData>
</table>
<value>2.0</value> <!-- FIXME why this factor 2 ? -->
</product>
</function>

</axis>

<axis name="SIDE">

<function name="aero/force/Side_beta">
<description>Side force due to beta</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>aero/beta-rad</property>
<!--value>-4</value-->
<value>0.02</value>
</product>
</function>

</axis>

</aerodynamics>
442 changes: 442 additions & 0 deletions conf/simulator/jsbsim/aircraft/anton.xml

Large diffs are not rendered by default.

394 changes: 394 additions & 0 deletions conf/simulator/jsbsim/aircraft/falcon.xml
@@ -0,0 +1,394 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="http://jsbsim.sourceforge.net/JSBSim.xsl"?>
<fdm_config name="QUAD COMPLETE EXT" version="2.0" release="BETA" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://jsbsim.sourceforge.net/JSBSim.xsd">

<fileheader>
<author>ENAC</author>
<filecreationdate>09-06-2022</filecreationdate>
<version>Version 0.92 - beta</version>
<description>Falcon</description>
</fileheader>

<metrics>
<wingarea unit="M2"> 0.075 </wingarea>
<wingspan unit="M"> 0.9 </wingspan>
<chord unit="M"> 0.12 </chord>
<htailarea unit="M2"> 0 </htailarea>
<htailarm unit="M"> 0 </htailarm>
<vtailarea unit="M2"> 0 </vtailarea>
<vtailarm unit="M"> 0 </vtailarm>
<wing_incidence unit="DEG"> 90 </wing_incidence>
<location name="AERORP" unit="M">
<x> 0 </x>
<y> 0 </y>
<z> 0 </z>
</location>
<location name="EYEPOINT" unit="M">
<x> 0 </x>
<y> 0 </y>
<z> 0 </z>
</location>
<location name="VRP" unit="M">
<x> 0 </x>
<y> 0 </y>
<z> 0 </z>
</location>
</metrics>

<mass_balance>
<ixx unit="KG*M2"> 0.005 </ixx>
<iyy unit="KG*M2"> 0.005 </iyy>
<izz unit="KG*M2"> 0.015 </izz>
<ixy unit="KG*M2"> 0. </ixy>
<ixz unit="KG*M2"> 0. </ixz>
<iyz unit="KG*M2"> 0. </iyz>
<emptywt unit="KG"> 0.72 </emptywt>
<location name="CG" unit="M">
<x> 0 </x>
<y> 0 </y>
<z> 0 </z>
</location>
</mass_balance>

<ground_reactions>
<contact type="STRUCTURE" name="CONTACT_FRONT">
<location unit="M">
<x> -0.12 </x>
<y> 0.0 </y>
<z>-0.1 </z>
</location>
<static_friction> 0.8 </static_friction>
<dynamic_friction> 0.5 </dynamic_friction>
<spring_coeff unit="N/M"> 500 </spring_coeff>
<damping_coeff unit="N/M/SEC"> 100 </damping_coeff>
<damping_coeff_rebound type="SQUARE" unit="N/M2/SEC2"> 1000 </damping_coeff_rebound>
<max_steer unit="DEG"> 0.0 </max_steer>
<brake_group> NONE </brake_group>
<retractable>0</retractable>
</contact>

<contact type="STRUCTURE" name="CONTACT_BACK">
<location unit="M">
<x> 0.12</x>
<y> 0.0</y>
<z> -0.1</z>
</location>
<static_friction> 0.8 </static_friction>
<dynamic_friction> 0.5 </dynamic_friction>
<spring_coeff unit="N/M"> 500 </spring_coeff>
<damping_coeff unit="N/M/SEC"> 100 </damping_coeff>
<damping_coeff_rebound type="SQUARE" unit="N/M2/SEC2"> 1000 </damping_coeff_rebound>
<max_steer unit="DEG"> 0.0 </max_steer>
<brake_group> NONE </brake_group>
<retractable>0</retractable>
</contact>

<contact type="STRUCTURE" name="CONTACT_RIGHT">
<location unit="M">
<x> 0.0 </x>
<y> 0.12</y>
<z> -0.1 </z>
</location>
<static_friction> 0.8 </static_friction>
<dynamic_friction> 0.5 </dynamic_friction>
<spring_coeff unit="N/M"> 500 </spring_coeff>
<damping_coeff unit="N/M/SEC"> 100 </damping_coeff>
<damping_coeff_rebound type="SQUARE" unit="N/M2/SEC2"> 1000 </damping_coeff_rebound>
<max_steer unit="DEG"> 0.0 </max_steer>
<brake_group> NONE </brake_group>
<retractable>0</retractable>
</contact>

<contact type="STRUCTURE" name="CONTACT_LEFT">
<location unit="M">
<x> 0.0 </x>
<y>-0.12</y>
<z> -0.1 </z>
</location>
<static_friction> 0.8 </static_friction>
<dynamic_friction> 0.5 </dynamic_friction>
<spring_coeff unit="N/M"> 500 </spring_coeff>
<damping_coeff unit="N/M/SEC"> 100 </damping_coeff>
<damping_coeff_rebound type="SQUARE" unit="N/M2/SEC2"> 1000 </damping_coeff_rebound>
<max_steer unit="DEG"> 0.0 </max_steer>
<brake_group> NONE </brake_group>
<retractable>0</retractable>
</contact>
</ground_reactions>

<flight_control name="actuator_dynamics">
<property value="30.">fcs/motor_lag</property>
<property value="54.">fcs/elevon_lag</property>

<channel name="filtering">

<!--First order filter represents actuator dynamics-->
<lag_filter name="UR_lag">
<input> fcs/UR </input>
<clipto>
<min>0</min>
<max>1</max>
</clipto>
<c1> fcs/motor_lag </c1>
<output> fcs/UR_lag</output>
</lag_filter>
<lag_filter name="BR_lag">
<input> fcs/BR </input>
<clipto>
<min>0</min>
<max>1</max>
</clipto>
<c1> fcs/motor_lag </c1>
<output> fcs/BR_lag</output>
</lag_filter>
<lag_filter name="BL_lag">
<input> fcs/BL </input>
<clipto>
<min>0</min>
<max>1</max>
</clipto>
<c1> fcs/motor_lag </c1>
<output> fcs/BL_lag</output>
</lag_filter>
<lag_filter name="UL_lag">
<input> fcs/UL </input>
<clipto>
<min>0</min>
<max>1</max>
</clipto>
<c1> fcs/motor_lag </c1>
<output> fcs/UL_lag</output>
</lag_filter>

<lag_filter name="ele_left_lag">
<input> fcs/ele_left </input>
<c1> fcs/elevon_lag </c1>
<output> fcs/ele_left_lag</output>
</lag_filter>
<lag_filter name="ele_right_lag">
<input> fcs/ele_right </input>
<c1> fcs/elevon_lag </c1>
<output> fcs/ele_right_lag</output>
</lag_filter>
</channel>
</flight_control>

<external_reactions>

<property>fcs/UR</property>
<property>fcs/BR</property>
<property>fcs/BL</property>
<property>fcs/UL</property>
<property>fcs/UR_lag</property>
<property>fcs/BR_lag</property>
<property>fcs/BL_lag</property>
<property>fcs/UL_lag</property>
<property>fcs/ele_left</property>
<property>fcs/ele_left_lag</property>
<property>fcs/ele_right</property>
<property>fcs/ele_right_lag</property>

<property value="6.">fcs/motor_max_thrust</property> <!-- FIXME should be 4. from flight data -->
<property value="0.00001">fcs/motor_max_torque</property>

<!-- First the lift forces produced by each propeller -->

<force name="UR" frame="BODY" unit="LBS">
<function>
<product>
<property>fcs/UR_lag</property>
<property>fcs/motor_max_thrust</property>
<value>0.224808943</value> <!-- N to LBS -->
<table>
<independentVar lookup="row">aero/qbar-psf</independentVar>
<tableData> <!-- 1 psf = 47.88 Pa , 18m/s : 200Pa, 5m/s :15Pa 3m/s:5.5Pa-->
0. 1.
0.1148 1.
4.17 0.7 <!-- 18m/s -->
</tableData>
</table>
</product>
</function>
<location unit="M">
<x>0.105</x>
<y>0.12</y>
<z>0</z>
</location>
<direction>
<x>0.342</x>
<y>0</y>
<z>-0.94</z>
</direction>
</force>
<force name="BR" frame="BODY" unit="LBS">
<function>
<product>
<property>fcs/BR_lag</property>
<property>fcs/motor_max_thrust</property>
<value>0.224808943</value> <!-- N to LBS -->
<table>
<independentVar lookup="row">aero/qbar-psf</independentVar>
<tableData> <!-- 1 psf = 47.88 Pa , 18m/s : 200Pa, 5m/s :15Pa 3m/s:5.5Pa-->
0. 1.
0.1148 1.
4.17 0.7 <!-- 18m/s -->
</tableData>
</table>
</product>
</function>
<location unit="M">
<x>-0.105</x>
<y>0.12</y>
<z>0</z>
</location>
<direction>
<x>-0.342</x>
<y>0</y>
<z>-0.94</z>
</direction>
</force>
<force name="BL" frame="BODY" unit="LBS">
<function>
<product>
<property>fcs/BL_lag</property>
<property>fcs/motor_max_thrust</property>
<value>0.224808943</value> <!-- N to LBS -->
<table>
<independentVar lookup="row">aero/qbar-psf</independentVar>
<tableData> <!-- 1 psf = 47.88 Pa , 18m/s : 200Pa, 5m/s :15Pa 3m/s:5.5Pa-->
0. 1.
0.1148 1.
4.17 0.7 <!-- 18m/s -->
</tableData>
</table>
</product>
</function>
<location unit="M">
<x>-0.105</x>
<y>-0.12</y>
<z>0</z>
</location>
<direction>
<x>-0.342</x>
<y>0</y>
<z>-0.94</z>
</direction>
</force>
<force name="UL" frame="BODY" unit="LBS">
<function>
<product>
<property>fcs/UL_lag</property>
<property>fcs/motor_max_thrust</property>
<value>0.224808943</value> <!-- N to LBS -->
<table>
<independentVar lookup="row">aero/qbar-psf</independentVar>
<tableData> <!-- 1 psf = 47.88 Pa , 18m/s : 200Pa, 5m/s :15Pa 3m/s:5.5Pa-->
0. 1.
0.1148 1.
4.17 0.7 <!-- 18m/s -->
</tableData>
</table>
</product>
</function>
<location unit="M">
<x>0.105</x>
<y>-0.12</y>
<z>0</z>
</location>
<direction>
<x>0.342</x>
<y>0</y>
<z>-0.94</z>
</direction>
</force>

<!-- Then the Moment Couples -->

<moment name="UR_couple" frame="BODY">
<function>
<product>
<property>fcs/UR_lag</property>
<property>fcs/motor_max_torque</property>
<value> 0.738 </value> <!-- N.m to FT.LBS -->
</product>
</function>
<location unit="M">
<x>0.105</x>
<y>0.12</y>
<z>0</z>
</location>
<direction>
<x>0</x>
<y>0</y>
<z>-1</z>
</direction>
</moment>

<moment name="BR_couple" frame="BODY">
<function>
<product>
<property>fcs/BR_lag</property>
<property>fcs/motor_max_torque</property>
<value> 0.738 </value> <!-- N.m to FT.LBS -->
</product>
</function>
<location unit="M">
<x>-0.105</x>
<y>0.12</y>
<z>0</z>
</location>
<direction>
<x>0</x>
<y>0</y>
<z>1</z>
</direction>
</moment>

<moment name="BL_couple" frame="BODY">
<function>
<product>
<property>fcs/BL_lag</property>
<property>fcs/motor_max_torque</property>
<value> 0.738 </value> <!-- N.m to FT.LBS -->
</product>
</function>
<location unit="M">
<x>-0.105</x>
<y>-0.12</y>
<z>0</z>
</location>
<direction>
<x>0</x>
<y>0</y>
<z>-1</z>
</direction>
</moment>

<moment name="UL_couple" frame="BODY">
<function>
<product>
<property>fcs/UL_lag</property>
<property>fcs/motor_max_torque</property>
<value> 0.738 </value> <!-- N.m to FT.LBS -->
</product>
</function>
<location unit="M">
<x>0.105</x>
<y>-0.12</y>
<z>0</z>
</location>
<direction>
<x>0</x>
<y>0</y>
<z>1</z>
</direction>
</moment>

</external_reactions>

<propulsion/>

<flight_control name="FGFCS"/>
<aerodynamics file="Systems/aerodynamics_falcon.xml"/>

</fdm_config>
10 changes: 7 additions & 3 deletions conf/telemetry/highspeed_rotorcraft.xml
Expand Up @@ -42,7 +42,7 @@
<message name="AHRS_BIAS" period="7.5"/>
<message name="HOVER_LOOP" period="0.3"/>
<message name="GUIDANCE_H_REF_INT" period="0.31"/>
<message name="GUIDANCE_INDI_HYBRID" period="0.4"/>
<message name="GUIDANCE_INDI_HYBRID" period="0.4"/>
<message name="HYBRID_GUIDANCE" period="0.4"/>
<message name="ESC" period="0.5"/>
<message name="AHRS_REF_QUAT" period="0.1"/>
Expand All @@ -53,13 +53,15 @@
<message name="APPROACH_MOVING_TARGET" period="0.1"/>
<message name="AIRSPEED_RAW" period="0.1"/>
<message name="TARGET_POS_INFO" period="0.1"/>
<message name="ROTATING_WING_STATE" period="0.2"/>
<message name="ROTATING_WING_STATE" period="0.2"/>
<message name="ACTUATORS" period="0.02"/>
<message name="EFF_MAT_G" period="0.02"/>
<message name="GUIDANCE" period="0.02"/>
<message name="STAB_ATTITUDE" period="0.02"/>
<message name="ROTORCRAFT_CMD" period="0.2"/>
<message name="DEBUG_VECT" period="0.2"/>
<message name="EXTERNAL_POSE_DOWN" period="0.2"/>

</mode>

<mode name="calibration">
Expand Down Expand Up @@ -163,7 +165,7 @@
<mode name="vel_guidance" key_press="q">
<message name="ALIVE" period="0.9"/>
<message name="HYBRID_GUIDANCE" period="0.062"/>
<message name="GUIDANCE_INDI_HYBRID" period="0.1"/>
<message name="GUIDANCE_INDI_HYBRID" period="0.1"/>
<message name="ROTORCRAFT_FP" period="0.8"/>
<message name="ROTORCRAFT_STATUS" period="1.2"/>
<message name="ROTORCRAFT_NAV_STATUS" period="1.6"/>
Expand Down Expand Up @@ -220,6 +222,7 @@
<message name="ROTORCRAFT_STATUS" period="1.2"/>
<message name="ROTORCRAFT_FP" period="0.002"/>
<message name="ROTORCRAFT_CMD" period=".002"/>
<message name="ROTORCRAFT_RADIO_CONTROL" period="0.20"/>
<message name="COMMANDS" period=".02"/>
<message name="INS_REF" period="5.1"/>
<message name="ROTORCRAFT_NAV_STATUS" period="1.6"/>
Expand Down Expand Up @@ -255,6 +258,7 @@
<message name="AIRSPEED_RAW" period="0.01"/>
<message name="EFF_MAT_G" period="0.002"/>
<message name="GUIDANCE" period="0.002"/>
<message name="EXTERNAL_POSE_DOWN" period="0.002"/>
<message name="ROTATING_WING_STATE" period="0.1"/>
<message name="DOUBLET" period="0.002"/>
</mode>
Expand Down
33 changes: 33 additions & 0 deletions conf/userconf/tudelft/conf.xml
Expand Up @@ -593,4 +593,37 @@
settings_modules="modules/air_data.xml modules/airspeed_ms45xx_i2c.xml modules/airspeed_uavcan.xml modules/approach_moving_target.xml modules/ekf_aw.xml modules/electrical.xml modules/gps.xml modules/gps_ublox.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/imu_heater.xml modules/ins_ekf2.xml modules/logger_sd_chibios.xml modules/nav_hybrid.xml modules/nav_rotorcraft.xml modules/pfc_actuators.xml modules/preflight_checks.xml modules/rot_wing_automation.xml modules/rotwing_state.xml modules/stabilization_indi.xml modules/sys_id_auto_doublets.xml modules/sys_id_doublet.xml modules/target_pos.xml"
gui_color="red"
/>
<aircraft
name="RotatingWingV3F"
ac_id="10"
airframe="airframes/tudelft/rot_wing_v3f.xml"
radio="radios/crossfire_sbus.xml"
telemetry="telemetry/highspeed_rotorcraft.xml"
flight_plan="flight_plans/tudelft/rotating_wing_EHVB.xml"
settings="settings/rotorcraft_basic.xml"
settings_modules="modules/air_data.xml modules/airspeed_ms45xx_i2c.xml modules/airspeed_uavcan.xml modules/approach_moving_target.xml modules/ekf_aw.xml modules/electrical.xml modules/gps.xml modules/gps_ublox.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/imu_heater.xml modules/ins_ekf2.xml modules/logger_sd_chibios.xml modules/nav_hybrid.xml modules/nav_rotorcraft.xml modules/pfc_actuators.xml modules/preflight_checks.xml modules/rot_wing_automation.xml modules/rotwing_state.xml modules/stabilization_indi.xml modules/sys_id_auto_doublets.xml modules/sys_id_doublet.xml modules/target_pos.xml"
gui_color="red"
/>
<aircraft
name="RotatingWingV3G"
ac_id="11"
airframe="airframes/tudelft/rot_wing_v3g.xml"
radio="radios/crossfire_sbus.xml"
telemetry="telemetry/highspeed_rotorcraft.xml"
flight_plan="flight_plans/tudelft/rotating_wing_EHVB.xml"
settings="settings/rotorcraft_basic.xml"
settings_modules="modules/air_data.xml modules/airspeed_ms45xx_i2c.xml modules/airspeed_uavcan.xml modules/approach_moving_target.xml modules/ekf_aw.xml modules/electrical.xml modules/gps.xml modules/gps_ublox.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/imu_heater.xml modules/ins_ekf2.xml modules/logger_sd_chibios.xml modules/nav_hybrid.xml modules/nav_rotorcraft.xml modules/pfc_actuators.xml modules/preflight_checks.xml modules/rot_wing_automation.xml modules/rotwing_state.xml modules/stabilization_indi.xml modules/sys_id_auto_doublets.xml modules/sys_id_doublet.xml modules/target_pos.xml"
gui_color="red"
/>
<aircraft
name="RotatingWingV3H"
ac_id="33"
airframe="airframes/tudelft/rot_wing_v3h.xml"
radio="radios/crossfire_sbus.xml"
telemetry="telemetry/highspeed_rotorcraft.xml"
flight_plan="flight_plans/tudelft/rotating_wing_EHVB.xml"
settings="settings/rotorcraft_basic.xml"
settings_modules="modules/air_data.xml modules/airspeed_ms45xx_i2c.xml modules/airspeed_uavcan.xml modules/approach_moving_target.xml modules/ekf_aw.xml modules/electrical.xml modules/gps.xml modules/gps_ublox.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/imu_heater.xml modules/ins_ekf2.xml modules/logger_sd_chibios.xml modules/nav_hybrid.xml modules/nav_rotorcraft.xml modules/pfc_actuators.xml modules/preflight_checks.xml modules/rot_wing_automation.xml modules/rotwing_state.xml modules/stabilization_indi.xml modules/sys_id_auto_doublets.xml modules/sys_id_doublet.xml modules/target_pos.xml"
gui_color="red"
/>
</conf>
4 changes: 4 additions & 0 deletions sw/airborne/arch/chibios/mcu_periph/i2c_arch.c
Expand Up @@ -123,6 +123,8 @@ static void handle_i2c_thd(struct i2c_periph *p)
// wait for a transaction to be pushed in the queue
chSemWait(&i->sem);

i2cAcquireBus((I2CDriver *)p->reg_addr);

if (p->trans_insert_idx == p->trans_extract_idx) {
p->status = I2CIdle;
// no transaction pending
Expand Down Expand Up @@ -231,6 +233,8 @@ static void handle_i2c_thd(struct i2c_periph *p)
default:
break;
}

i2cReleaseBus((I2CDriver *)p->reg_addr);
}

/**
Expand Down
148 changes: 148 additions & 0 deletions sw/airborne/arch/chibios/modules/lidar/lidar_vl53l5cx.c
@@ -0,0 +1,148 @@
/*
* Copyright (C) 2024 Fabien-B <name.surname@gmail.com>
*
* 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/lidar/lidar_vl53l5cx.c"
* @author Fabien-B <name.surname@gmail.com>
* VL53L5CX multizone range sensor.
*/

#include "modules/lidar/lidar_vl53l5cx.h"
#include "mcu_periph/i2c.h"
#include "ch.h"
#include "lidar/vl53l5cx_platform.h"
#include "peripherals/vl53l5cx_api.h"
#include "modules/core/abi.h"
#include "modules/datalink/downlink.h"
#include "ch.h"
#include "hal.h"
#include "mcu_periph/ram_arch.h"

#ifndef LIDAR_VL53L5CX_I2C_ADDR
#define LIDAR_VL53L5CX_I2C_ADDR 0x29
#endif

#define SUBTYPE_DISTANCE 0

static IN_DMA_SECTION(VL53L5CX_Configuration vl53l5cx_dev);
static IN_DMA_SECTION(VL53L5CX_ResultsData vl53l5cx_results);

static THD_WORKING_AREA(wa_thd_lidar_vl53l5cx, 1024);
static void thd_lidar_vl53l5cx(void *arg);


char *VL53L5CX_ERROR_MSGS[] = {
"VL53L5CX_NO_ERROR",
"VL53L5CX_NOT_DETECTED",
"VL53L5CX_ULD_LOADING_FAILED",
"VL53L5CX_SET_RESOLUTION_FAILED",
"VL53L5CX_RUNTIME_ERROR",
};


void lidar_vl53l5cx_init(void)
{
vl53l5cx_dev.platform.i2cdev = &LIDAR_VL53L5CX_I2C_DEV;
vl53l5cx_dev.platform.address = LIDAR_VL53L5CX_I2C_ADDR;
vl53l5cx_dev.platform.user_data = NULL;
vl53l5cx_dev.platform.error_code = VL53L5CX_NO_ERROR;

// Create thread
vl53l5cx_dev.platform.user_data = chThdCreateStatic(wa_thd_lidar_vl53l5cx, sizeof(wa_thd_lidar_vl53l5cx),
NORMALPRIO, thd_lidar_vl53l5cx, (void *)&vl53l5cx_dev);
}

void lidar_vl53l5cx_periodic(void)
{

if (vl53l5cx_dev.platform.user_data != NULL) {
thread_t* thread_handle = (thread_t*) vl53l5cx_dev.platform.user_data;
// check thread status
if (thread_handle->state == CH_STATE_FINAL) {
vl53l5cx_dev.platform.error_code = (enum VL53L5CX_ERRORS) chThdWait(thread_handle);
vl53l5cx_dev.platform.user_data = NULL;
}
} else {

// thread exited, send error code periodically
size_t len = strlen(VL53L5CX_ERROR_MSGS[vl53l5cx_dev.platform.error_code]);
// send exitcode to telemetry
RunOnceEvery(10, DOWNLINK_SEND_INFO_MSG(DefaultChannel, DefaultDevice, len,
VL53L5CX_ERROR_MSGS[vl53l5cx_dev.platform.error_code]));
;
}


if (vl53l5cx_dev.platform.data_available) {
uint32_t now_ts = get_sys_time_usec();
AbiSendMsgLIDAR_DATA(LIDAR_DATA_VL53L5CX_ID, now_ts,
8, 8, sizeof(vl53l5cx_dev.platform.distances_mm[0]), SUBTYPE_DISTANCE,
(uint8_t *)vl53l5cx_dev.platform.distances_mm);

vl53l5cx_dev.platform.data_available = false;
}


}



static void thd_lidar_vl53l5cx(void *arg)
{
chRegSetThreadName("vl53l5cx");
VL53L5CX_Configuration *dev = (VL53L5CX_Configuration *) arg;

uint8_t status, isAlive, isReady;


chThdSleepMilliseconds(2000);

status = vl53l5cx_is_alive(dev, &isAlive);
if (!isAlive || status) {
chThdExit(VL53L5CX_NOT_DETECTED);
}

status = vl53l5cx_init(dev);
if (status) {
chThdExit(VL53L5CX_ULD_LOADING_FAILED);
}

status = vl53l5cx_set_resolution(dev, VL53L5CX_RESOLUTION_4X4);
if (status) {
chThdExit(VL53L5CX_SET_RESOLUTION_FAILED);
}

status = vl53l5cx_start_ranging(dev);

while (true) {
status = vl53l5cx_check_data_ready(dev, &isReady);
if (isReady) {
status = vl53l5cx_get_ranging_data(dev, &vl53l5cx_results);
if (status == 0) {
memcpy(dev->platform.distances_mm, vl53l5cx_results.distance_mm, 64 * sizeof(vl53l5cx_results.distance_mm[0]));
dev->platform.data_available = true;
}
}

chThdSleepMilliseconds(100);
}


}

35 changes: 35 additions & 0 deletions sw/airborne/arch/chibios/modules/lidar/lidar_vl53l5cx.h
@@ -0,0 +1,35 @@
/*
* Copyright (C) 2024 Fabien-B <name.surname@gmail.com>
*
* 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/lidar/lidar_vl53l5cx.h"
* @author Fabien-B <name.surname@gmail.com>
* VL53L5CX multizone range sensor.
*/

#ifndef LIDAR_VL53L5CX_H
#define LIDAR_VL53L5CX_H

#include "stdint.h"
#include "peripherals/vl53l5cx_api.h"

extern void lidar_vl53l5cx_init(void);
extern void lidar_vl53l5cx_periodic(void);

#endif // LIDAR_VL53L5CX_H
118 changes: 118 additions & 0 deletions sw/airborne/arch/chibios/modules/lidar/vl53l5cx_platform.c
@@ -0,0 +1,118 @@

/*
* Copyright (C) 2024 Fabien-B <name.surname@gmail.com>
*
* 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.
*/


#include "lidar/vl53l5cx_platform.h"
#include "hal.h"

#define VL53L5_I2C_TIMEOUT chTimeMS2I(100)


uint8_t RdByte(
VL53L5CX_Platform *dev,
uint16_t index,
uint8_t *p_data)
{
return RdMulti(dev, index, p_data, 1);
}

uint8_t WrByte(
VL53L5CX_Platform *dev,
uint16_t index,
uint8_t data)
{
return WrMulti(dev, index, &data, 1);
}

uint8_t WrMulti(
VL53L5CX_Platform *dev,
uint16_t index,
uint8_t *pdata,
uint32_t count)
{
I2CDriver * i2cd = (I2CDriver *)dev->i2cdev->reg_addr;

i2cAcquireBus(i2cd);

msg_t ret;

for(size_t offset = 0; offset<count; offset += VL53L5CX_I2C_BUF_SIZE) {
uint16_t reg_addr = index + offset;
dev->buf[0] = (reg_addr & 0xFF00) >> 8; // MSB first
dev->buf[1] = (reg_addr & 0x00FF);
size_t size = Min(count-offset, VL53L5CX_I2C_BUF_SIZE);
memcpy((uint8_t *) dev->buf + 2, (pdata + offset), size);
cacheBufferFlush(dev->buf, size+2);
ret = i2cMasterTransmitTimeout(i2cd, dev->address, dev->buf, size+2, NULL, 0, VL53L5_I2C_TIMEOUT);
}


i2cReleaseBus(i2cd);

return ret;
}

uint8_t RdMulti(
VL53L5CX_Platform *dev,
uint16_t index,
uint8_t *pdata,
uint32_t count)
{
I2CDriver * i2cd = (I2CDriver *)dev->i2cdev->reg_addr;

i2cAcquireBus(i2cd);

msg_t ret = 0;
for(size_t offset = 0; offset<count; offset += VL53L5CX_I2C_BUF_SIZE) {
uint16_t reg_addr = index + offset;
dev->buf[0] = (reg_addr & 0xFF00) >> 8; // MSB first
dev->buf[1] = (reg_addr & 0x00FF);
size_t size = Min(count-offset, VL53L5CX_I2C_BUF_SIZE);

cacheBufferFlush(dev->buf, 2);
ret = i2cMasterTransmitTimeout(i2cd, dev->address, dev->buf, 2, dev->buf, size, VL53L5_I2C_TIMEOUT);
cacheBufferInvalidate(dev->buf, count);
memcpy(pdata+offset, dev->buf, count);
}

i2cReleaseBus(i2cd);

return ret;
}

void SwapBuffer(
uint8_t *buffer,
uint16_t size)
{
uint32_t i, tmp;

/* Example of possible implementation using <string.h> */
for(i = 0; i < size; i = i + 4)
{
tmp = (
buffer[i]<<24)
|(buffer[i+1]<<16)
|(buffer[i+2]<<8)
|(buffer[i+3]);

memcpy(&(buffer[i]), &tmp, 4);
}
}

uint8_t WaitMs(
VL53L5CX_Platform *p_platform,
uint32_t TimeMs)
{
(void)p_platform;
chThdSleepMilliseconds(TimeMs);
return 0;
}
40 changes: 20 additions & 20 deletions sw/airborne/boards/tawaki/chibios/v2.0/board.h
Expand Up @@ -88,8 +88,8 @@
#define AUX_B2 7U
#define AUX_B3 8U
#define AUX_B4 9U
#define I2C2_SCL_EXTERNAL 10U
#define I2C2_SDA_EXTERNAL 11U
#define I2C2_SCL 10U
#define I2C2_SDA 11U
#define SPI2_EXTERNAL_CS 12U
#define PB13 13U
#define SPI2_EXTERNAL_MISO 14U
Expand Down Expand Up @@ -275,8 +275,8 @@
#define LINE_AUX_B2 PAL_LINE(GPIOB, 7U)
#define LINE_AUX_B3 PAL_LINE(GPIOB, 8U)
#define LINE_AUX_B4 PAL_LINE(GPIOB, 9U)
#define LINE_I2C2_SCL_EXTERNAL PAL_LINE(GPIOB, 10U)
#define LINE_I2C2_SDA_EXTERNAL PAL_LINE(GPIOB, 11U)
#define LINE_I2C2_SCL PAL_LINE(GPIOB, 10U)
#define LINE_I2C2_SDA PAL_LINE(GPIOB, 11U)
#define LINE_SPI2_EXTERNAL_CS PAL_LINE(GPIOB, 12U)
#define LINE_SPI2_EXTERNAL_MISO PAL_LINE(GPIOB, 14U)
#define LINE_SPI2_EXTERNAL_MOSI PAL_LINE(GPIOB, 15U)
Expand Down Expand Up @@ -450,8 +450,8 @@
PIN_MODE_ALTERNATE(AUX_B2) | \
PIN_MODE_ALTERNATE(AUX_B3) | \
PIN_MODE_ALTERNATE(AUX_B4) | \
PIN_MODE_ALTERNATE(I2C2_SCL_EXTERNAL) | \
PIN_MODE_ALTERNATE(I2C2_SDA_EXTERNAL) | \
PIN_MODE_ALTERNATE(I2C2_SCL) | \
PIN_MODE_ALTERNATE(I2C2_SDA) | \
PIN_MODE_OUTPUT(SPI2_EXTERNAL_CS) | \
PIN_MODE_INPUT(PB13) | \
PIN_MODE_ALTERNATE(SPI2_EXTERNAL_MISO) | \
Expand All @@ -467,8 +467,8 @@
PIN_OTYPE_PUSHPULL(AUX_B2) | \
PIN_OTYPE_PUSHPULL(AUX_B3) | \
PIN_OTYPE_PUSHPULL(AUX_B4) | \
PIN_OTYPE_OPENDRAIN(I2C2_SCL_EXTERNAL) | \
PIN_OTYPE_OPENDRAIN(I2C2_SDA_EXTERNAL) | \
PIN_OTYPE_OPENDRAIN(I2C2_SCL) | \
PIN_OTYPE_OPENDRAIN(I2C2_SDA) | \
PIN_OTYPE_PUSHPULL(SPI2_EXTERNAL_CS) | \
PIN_OTYPE_PUSHPULL(PB13) | \
PIN_OTYPE_PUSHPULL(SPI2_EXTERNAL_MISO) | \
Expand All @@ -484,8 +484,8 @@
PIN_OSPEED_SPEED_HIGH(AUX_B2) | \
PIN_OSPEED_SPEED_HIGH(AUX_B3) | \
PIN_OSPEED_SPEED_HIGH(AUX_B4) | \
PIN_OSPEED_SPEED_HIGH(I2C2_SCL_EXTERNAL) | \
PIN_OSPEED_SPEED_HIGH(I2C2_SDA_EXTERNAL) | \
PIN_OSPEED_SPEED_HIGH(I2C2_SCL) | \
PIN_OSPEED_SPEED_HIGH(I2C2_SDA) | \
PIN_OSPEED_SPEED_HIGH(SPI2_EXTERNAL_CS) | \
PIN_OSPEED_SPEED_VERYLOW(PB13) | \
PIN_OSPEED_SPEED_HIGH(SPI2_EXTERNAL_MISO) | \
Expand All @@ -501,8 +501,8 @@
PIN_PUPDR_FLOATING(AUX_B2) | \
PIN_PUPDR_FLOATING(AUX_B3) | \
PIN_PUPDR_FLOATING(AUX_B4) | \
PIN_PUPDR_PULLUP(I2C2_SCL_EXTERNAL) | \
PIN_PUPDR_PULLUP(I2C2_SDA_EXTERNAL) | \
PIN_PUPDR_PULLUP(I2C2_SCL) | \
PIN_PUPDR_PULLUP(I2C2_SDA) | \
PIN_PUPDR_FLOATING(SPI2_EXTERNAL_CS) | \
PIN_PUPDR_PULLDOWN(PB13) | \
PIN_PUPDR_FLOATING(SPI2_EXTERNAL_MISO) | \
Expand All @@ -518,8 +518,8 @@
PIN_ODR_LEVEL_LOW(AUX_B2) | \
PIN_ODR_LEVEL_LOW(AUX_B3) | \
PIN_ODR_LEVEL_LOW(AUX_B4) | \
PIN_ODR_LEVEL_HIGH(I2C2_SCL_EXTERNAL) | \
PIN_ODR_LEVEL_HIGH(I2C2_SDA_EXTERNAL) | \
PIN_ODR_LEVEL_HIGH(I2C2_SCL) | \
PIN_ODR_LEVEL_HIGH(I2C2_SDA) | \
PIN_ODR_LEVEL_HIGH(SPI2_EXTERNAL_CS) | \
PIN_ODR_LEVEL_LOW(PB13) | \
PIN_ODR_LEVEL_HIGH(SPI2_EXTERNAL_MISO) | \
Expand All @@ -536,8 +536,8 @@

#define VAL_GPIOB_AFRH (PIN_AFIO_AF(AUX_B3, 2) | \
PIN_AFIO_AF(AUX_B4, 2) | \
PIN_AFIO_AF(I2C2_SCL_EXTERNAL, 4) | \
PIN_AFIO_AF(I2C2_SDA_EXTERNAL, 4) | \
PIN_AFIO_AF(I2C2_SCL, 4) | \
PIN_AFIO_AF(I2C2_SDA, 4) | \
PIN_AFIO_AF(SPI2_EXTERNAL_CS, 0) | \
PIN_AFIO_AF(PB13, 0) | \
PIN_AFIO_AF(SPI2_EXTERNAL_MISO, 5) | \
Expand Down Expand Up @@ -1506,10 +1506,10 @@
#define AF_LINE_AUX_B3 2U
#define AF_AUX_B4 2U
#define AF_LINE_AUX_B4 2U
#define AF_I2C2_SCL_EXTERNAL 4U
#define AF_LINE_I2C2_SCL_EXTERNAL 4U
#define AF_I2C2_SDA_EXTERNAL 4U
#define AF_LINE_I2C2_SDA_EXTERNAL 4U
#define AF_I2C2_SCL 4U
#define AF_LINE_I2C2_SCL 4U
#define AF_I2C2_SDA 4U
#define AF_LINE_I2C2_SDA 4U
#define AF_SPI2_EXTERNAL_MISO 5U
#define AF_LINE_SPI2_EXTERNAL_MISO 5U
#define AF_SPI2_EXTERNAL_MOSI 5U
Expand Down
4 changes: 2 additions & 2 deletions sw/airborne/boards/tawaki/chibios/v2.0/tawaki_2.0.cfg
Expand Up @@ -109,8 +109,8 @@ PB06 AUX_B1 PWM AF:TIM4_CH1
PB07 AUX_B2 PWM AF:TIM4_CH2
PB08 AUX_B3 PWM AF:TIM4_CH3
PB09 AUX_B4 PWM AF:TIM4_CH4
PB10 I2C2_SCL_EXTERNAL I2C AF:I2C2_SCL
PB11 I2C2_SDA_EXTERNAL I2C AF:I2C2_SDA
PB10 I2C2_SCL I2C AF:I2C2_SCL # External
PB11 I2C2_SDA I2C AF:I2C2_SDA # External
PB12 SPI2_EXTERNAL_CS OUTPUT PUSHPULL SPEED_HIGH FLOATING LEVEL_HIGH
PB14 SPI2_EXTERNAL_MISO SPI AF:SPI2_MISO
PB15 SPI2_EXTERNAL_MOSI SPI AF:SPI2_MOSI
Expand Down
2 changes: 0 additions & 2 deletions sw/airborne/firmwares/fixedwing/nav.h
Expand Up @@ -217,8 +217,6 @@ bool nav_approaching_xy(float x, float y, float from_x, float from_y, float appr
{h_ctl_roll_setpoint = _roll;} \
}

#define NavSetManual(_roll, _pitch, _yaw) _Pragma("GCC error \"Manual mode in flight plan for fixedwing is not available\"")


#define nav_IncreaseShift(x) { if (x==0) nav_shift = 0; else nav_shift += x; }

Expand Down
21 changes: 8 additions & 13 deletions sw/airborne/firmwares/rotorcraft/guidance/guidance_h.c
Expand Up @@ -451,16 +451,8 @@ void guidance_h_from_nav(bool in_flight)
guidance_h_nav_enter();
}

if (nav.horizontal_mode == NAV_HORIZONTAL_MODE_MANUAL) {
#ifdef COMMAND_ROLL
stabilization_cmd[COMMAND_ROLL] = nav.cmd_roll;
#endif
#ifdef COMMAND_PITCH
stabilization_cmd[COMMAND_PITCH] = nav.cmd_pitch;
#endif
#ifdef COMMAND_YAW
stabilization_cmd[COMMAND_YAW] = nav.cmd_yaw;
#endif
if (nav.horizontal_mode == NAV_HORIZONTAL_MODE_NONE) {
return; // don't call guidance nor stabilization
} else if (nav.horizontal_mode == NAV_HORIZONTAL_MODE_ATTITUDE) {
if (nav.setpoint_mode == NAV_SETPOINT_MODE_QUAT) {
// directly apply quat setpoint
Expand All @@ -482,11 +474,14 @@ void guidance_h_from_nav(bool in_flight)
} else if (nav.horizontal_mode == NAV_HORIZONTAL_MODE_GUIDED) {
guidance_h_guided_run(in_flight);
} else {
// update carrot for display, even if sp is changed in speed mode
guidance_h_set_pos(nav.carrot.y, nav.carrot.x);
// update carrot for GCS display and convert ENU float -> NED int
// even if sp is changed later
guidance_h.sp.pos.x = POS_BFP_OF_REAL(nav.carrot.y);
guidance_h.sp.pos.y = POS_BFP_OF_REAL(nav.carrot.x);

switch (nav.setpoint_mode) {
case NAV_SETPOINT_MODE_POS:
// set guidance in NED
guidance_h_set_pos(nav.carrot.y, nav.carrot.x); // nav pos is in ENU frame, convert to NED
guidance_h_update_reference();
guidance_h_set_heading(nav.heading);
guidance_h_cmd = guidance_h_run_pos(in_flight, &guidance_h);
Expand Down
22 changes: 0 additions & 22 deletions sw/airborne/firmwares/rotorcraft/navigation.c
Expand Up @@ -86,9 +86,6 @@ void nav_init(void)
FLOAT_RATES_ZERO(nav.rates);

nav.throttle = 0;
nav.cmd_roll = 0;
nav.cmd_pitch = 0;
nav.cmd_yaw = 0;
nav.roll = 0.f;
nav.pitch = 0.f;
nav.heading = 0.f;
Expand Down Expand Up @@ -305,25 +302,6 @@ void nav_home(void)
nav_run();
}

/** Set manual roll, pitch and yaw without stabilization
*
* @param[in] roll command in pprz scale (int32_t)
* @param[in] pitch command in pprz scale (int32_t)
* @param[in] yaw command in pprz scale (int32_t)
*
* This function allows to directly set commands from the flight plan,
* if in nav_manual mode.
* This is for instance useful for helicopters during the spinup
*/
void nav_set_manual(int32_t roll, int32_t pitch, int32_t yaw)
{
nav.horizontal_mode = NAV_HORIZONTAL_MODE_MANUAL;
nav.setpoint_mode = NAV_SETPOINT_MODE_MANUAL;
nav.cmd_roll = roll;
nav.cmd_pitch = pitch;
nav.cmd_yaw = yaw;
}

/** Returns squared horizontal distance to given point */
float get_dist2_to_point(struct EnuCoor_f *p)
{
Expand Down
7 changes: 1 addition & 6 deletions sw/airborne/firmwares/rotorcraft/navigation.h
Expand Up @@ -86,7 +86,7 @@
#define NAV_HORIZONTAL_MODE_ROUTE 1
#define NAV_HORIZONTAL_MODE_CIRCLE 2
#define NAV_HORIZONTAL_MODE_ATTITUDE 3
#define NAV_HORIZONTAL_MODE_MANUAL 4
#define NAV_HORIZONTAL_MODE_NONE 4
#define NAV_HORIZONTAL_MODE_GUIDED 5

#define NAV_VERTICAL_MODE_MANUAL 0
Expand Down Expand Up @@ -128,9 +128,6 @@ struct RotorcraftNavigation {
struct EnuCoor_f speed; ///< speed setpoint (in m/s)
struct EnuCoor_f accel; ///< accel setpoint (in m/s)
uint32_t throttle; ///< throttle command (in pprz_t)
int32_t cmd_roll; ///< roll command (in pprz_t)
int32_t cmd_pitch; ///< pitch command (in pprz_t)
int32_t cmd_yaw; ///< yaw command (in pprz_t)
float roll; ///< roll angle (in radians)
float pitch; ///< pitch angle (in radians)
float heading; ///< heading setpoint (in radians)
Expand Down Expand Up @@ -203,7 +200,6 @@ extern float get_dist2_to_waypoint(uint8_t wp_id);
extern float get_dist2_to_point(struct EnuCoor_f *p);
extern void compute_dist2_to_home(void);
extern void nav_home(void);
extern void nav_set_manual(int32_t roll, int32_t pitch, int32_t yaw);

extern void nav_reset_reference(void) __attribute__((unused));
extern void nav_reset_alt(void) __attribute__((unused));
Expand Down Expand Up @@ -239,7 +235,6 @@ static inline void NavResurrect(void)
}


#define NavSetManual nav_set_manual
#define NavSetFailsafe nav_set_failsafe

#define NavSetGroundReferenceHere nav_reset_reference
Expand Down
6 changes: 1 addition & 5 deletions sw/airborne/firmwares/rover/guidance/rover_guidance.c
Expand Up @@ -142,11 +142,7 @@ void rover_guidance_enter(void)
// rover_guidance_nav_enter();
// }
//
// if (horizontal_mode == HORIZONTAL_MODE_MANUAL) {
// stabilization_cmd[COMMAND_ROLL] = nav_cmd_roll;
// stabilization_cmd[COMMAND_PITCH] = nav_cmd_pitch;
// stabilization_cmd[COMMAND_YAW] = nav_cmd_yaw;
// } else if (horizontal_mode == HORIZONTAL_MODE_ATTITUDE) {
// if (horizontal_mode == HORIZONTAL_MODE_ATTITUDE) {
// struct Int32Eulers sp_cmd_i;
// sp_cmd_i.phi = nav_roll;
// sp_cmd_i.theta = nav_pitch;
Expand Down
2 changes: 0 additions & 2 deletions sw/airborne/firmwares/rover/navigation.h
Expand Up @@ -197,8 +197,6 @@ static inline void NavResurrect(void)
if (autopilot_get_mode() == AP_MODE_NAV) { autopilot_set_motors_on(true); }
}


#define NavSetManual(_roll, _pitch, _yaw) _Pragma("GCC error \"Manual mode in flight plan for fixedwing is not available\"")
#define NavSetFailsafe nav_set_failsafe

#define NavSetGroundReferenceHere nav_reset_reference
Expand Down
9 changes: 9 additions & 0 deletions sw/airborne/modules/core/abi_sender_ids.h
Expand Up @@ -636,4 +636,13 @@
#define VEL_SP_FCR_ID 1 // Approach Moving Target
#endif


/*
* IDs of LIDAR_DATA senders
*/
#ifndef LIDAR_DATA_VL53L5CX_ID
#define LIDAR_DATA_VL53L5CX_ID 1
#endif


#endif /* ABI_SENDER_IDS_H */
6 changes: 3 additions & 3 deletions sw/airborne/modules/gps/gps_datalink.c
Expand Up @@ -134,15 +134,15 @@ void gps_datalink_parse_EXTERNAL_POSE(uint8_t *buf)
enu_speed.y = DL_EXTERNAL_POSE_enu_yd(buf);
enu_speed.z = DL_EXTERNAL_POSE_enu_zd(buf);

struct FloatQuat body_q;
struct FloatQuat body_q; // converted to NED
body_q.qi = DL_EXTERNAL_POSE_body_qi(buf);
body_q.qx = DL_EXTERNAL_POSE_body_qy(buf);
body_q.qy = DL_EXTERNAL_POSE_body_qx(buf);
body_q.qz = DL_EXTERNAL_POSE_body_qz(buf);
body_q.qz = -DL_EXTERNAL_POSE_body_qz(buf);

struct FloatEulers body_e;
float_eulers_of_quat(&body_e, &body_q);
float heading = -body_e.psi; // convert heading in ENU to NED
float heading = body_e.psi;

gps_datalink_publish(tow, &enu_pos, &enu_speed, heading);
}
Expand Down
69 changes: 50 additions & 19 deletions sw/airborne/modules/ins/ins_ekf2.cpp
Expand Up @@ -301,7 +301,7 @@ static void ins_ekf2_publish_attitude(uint32_t stamp);
static Ekf ekf; ///< EKF class itself
static parameters *ekf_params; ///< The EKF parameters
struct ekf2_t ekf2; ///< Local EKF2 status structure

static struct extVisionSample sample_ev = {0}; ///< External vision sample
#if PERIODIC_TELEMETRY
#include "modules/datalink/telemetry.h"

Expand Down Expand Up @@ -480,6 +480,37 @@ static void send_ahrs_quat(struct transport_tx *trans, struct link_device *dev)
&ahrs_id);
}


static void send_external_pose_down(struct transport_tx *trans, struct link_device *dev)
{
if(sample_ev.time_us==0){
return;
}
float sample_temp_ev[11];
sample_temp_ev[0] = (float) sample_ev.time_us;
sample_temp_ev[1] = sample_ev.pos(0) ;
sample_temp_ev[2] = sample_ev.pos(1) ;
sample_temp_ev[3] = sample_ev.pos(2) ;
sample_temp_ev[4] = sample_ev.vel(0) ;
sample_temp_ev[5] = sample_ev.vel(1) ;
sample_temp_ev[6] = sample_ev.vel(2) ;
sample_temp_ev[7] = sample_ev.quat(0);
sample_temp_ev[8] = sample_ev.quat(1);
sample_temp_ev[9] = sample_ev.quat(2);
sample_temp_ev[10] = sample_ev.quat(3);
pprz_msg_send_EXTERNAL_POSE_DOWN(trans, dev, AC_ID,
&sample_temp_ev[0],
&sample_temp_ev[1],
&sample_temp_ev[2],
&sample_temp_ev[3],
&sample_temp_ev[4],
&sample_temp_ev[5],
&sample_temp_ev[6],
&sample_temp_ev[7],
&sample_temp_ev[8],
&sample_temp_ev[9],
&sample_temp_ev[10] );
}
#endif

/* Initialize the EKF */
Expand Down Expand Up @@ -576,6 +607,7 @@ void ins_ekf2_init(void)
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_WIND_INFO_RET, send_wind_info_ret);
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_AHRS_BIAS, send_ahrs_bias);
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_AHRS_QUAT_INT, send_ahrs_quat);
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_EXTERNAL_POSE_DOWN, send_external_pose_down);
#endif

/*
Expand Down Expand Up @@ -700,24 +732,23 @@ void ins_ekf2_remove_gps(int32_t mode)
void ins_ekf2_parse_EXTERNAL_POSE(uint8_t *buf) {
if (DL_EXTERNAL_POSE_ac_id(buf) != AC_ID) { return; } // not for this aircraft

extVisionSample sample;
sample.time_us = get_sys_time_usec(); //FIXME
sample.pos(0) = DL_EXTERNAL_POSE_enu_y(buf);
sample.pos(1) = DL_EXTERNAL_POSE_enu_x(buf);
sample.pos(2) = -DL_EXTERNAL_POSE_enu_z(buf);
sample.vel(0) = DL_EXTERNAL_POSE_enu_yd(buf);
sample.vel(1) = DL_EXTERNAL_POSE_enu_xd(buf);
sample.vel(2) = -DL_EXTERNAL_POSE_enu_zd(buf);
sample.quat(0) = DL_EXTERNAL_POSE_body_qi(buf);
sample.quat(1) = DL_EXTERNAL_POSE_body_qy(buf);
sample.quat(2) = DL_EXTERNAL_POSE_body_qx(buf);
sample.quat(3) = -DL_EXTERNAL_POSE_body_qz(buf);
sample.posVar.setAll(INS_EKF2_EVP_NOISE);
sample.velCov = matrix::eye<float, 3>() * INS_EKF2_EVV_NOISE;
sample.angVar = INS_EKF2_EVA_NOISE;
sample.vel_frame = velocity_frame_t::LOCAL_FRAME_FRD;

ekf.setExtVisionData(sample);
sample_ev.time_us = get_sys_time_usec(); //FIXME
sample_ev.pos(0) = DL_EXTERNAL_POSE_enu_y(buf);
sample_ev.pos(1) = DL_EXTERNAL_POSE_enu_x(buf);
sample_ev.pos(2) = -DL_EXTERNAL_POSE_enu_z(buf);
sample_ev.vel(0) = DL_EXTERNAL_POSE_enu_yd(buf);
sample_ev.vel(1) = DL_EXTERNAL_POSE_enu_xd(buf);
sample_ev.vel(2) = -DL_EXTERNAL_POSE_enu_zd(buf);
sample_ev.quat(0) = DL_EXTERNAL_POSE_body_qi(buf);
sample_ev.quat(1) = DL_EXTERNAL_POSE_body_qy(buf);
sample_ev.quat(2) = DL_EXTERNAL_POSE_body_qx(buf);
sample_ev.quat(3) = -DL_EXTERNAL_POSE_body_qz(buf);
sample_ev.posVar.setAll(INS_EKF2_EVP_NOISE);
sample_ev.velCov = matrix::eye<float, 3>() * INS_EKF2_EVV_NOISE;
sample_ev.angVar = INS_EKF2_EVA_NOISE;
sample_ev.vel_frame = velocity_frame_t::LOCAL_FRAME_FRD;

ekf.setExtVisionData(sample_ev);
}

void ins_ekf2_parse_EXTERNAL_POSE_SMALL(uint8_t __attribute__((unused)) *buf) {
Expand Down
96 changes: 69 additions & 27 deletions sw/airborne/modules/ins/ins_ext_pose.c
Expand Up @@ -43,21 +43,21 @@
#define DEBUG_PRINT(...) {}
#endif


/** Data for telemetry and LTP origin.
*/


struct InsExtPose {
/* Inputs */
struct FloatRates gyros_f;
struct FloatVect3 accels_f;
bool has_new_gyro;
bool has_new_acc;
bool has_new_gyro;
bool has_new_acc;

struct FloatVect3 ev_pos;
struct FloatVect3 ev_vel;
struct FloatEulers ev_att;
bool has_new_ext_pose;
struct FloatQuat ev_quat;
bool has_new_ext_pose;
float ev_time;

/* Origin */
struct LtpDef_i ltp_def;
Expand All @@ -67,7 +67,6 @@ struct InsExtPose {
struct NedCoor_i ltp_speed;
struct NedCoor_i ltp_accel;
};

struct InsExtPose ins_ext_pos;


Expand All @@ -86,6 +85,8 @@ static void ins_ext_pose_init_from_flightplan(void)
ltp_def_from_ecef_i(&ins_ext_pos.ltp_def, &ecef_nav0);
ins_ext_pos.ltp_def.hmsl = NAV_ALT0;
stateSetLocalOrigin_i(&ins_ext_pos.ltp_def);
/* update local ENU coordinates of global waypoints */
waypoints_localize_all();
}


Expand Down Expand Up @@ -119,6 +120,36 @@ static void send_ins_ref(struct transport_tx *trans, struct link_device *dev)
&ins_ext_pos.ltp_def.lla.lat, &ins_ext_pos.ltp_def.lla.lon, &ins_ext_pos.ltp_def.lla.alt,
&ins_ext_pos.ltp_def.hmsl, (float *)&fake_qfe);
}

static void send_external_pose_down(struct transport_tx *trans, struct link_device *dev)
{
pprz_msg_send_EXTERNAL_POSE_DOWN(trans, dev, AC_ID,
&ins_ext_pos.ev_time,
&ins_ext_pos.ev_pos.x,
&ins_ext_pos.ev_pos.y,
&ins_ext_pos.ev_pos.z,
&ins_ext_pos.ev_vel.x,
&ins_ext_pos.ev_vel.y,
&ins_ext_pos.ev_vel.z,
&ins_ext_pos.ev_quat.qi,
&ins_ext_pos.ev_quat.qx,
&ins_ext_pos.ev_quat.qy,
&ins_ext_pos.ev_quat.qz);
}
static void send_ahrs_bias(struct transport_tx *trans, struct link_device *dev)
{
float dummy0 = 0.0;
pprz_msg_send_AHRS_BIAS(trans, dev, AC_ID,
&ekf_X[9],
&ekf_X[10],
&ekf_X[11],
&ekf_X[12],
&ekf_X[13],
&ekf_X[14],
&dummy0,
&dummy0,
&dummy0);
}
#endif


Expand Down Expand Up @@ -163,11 +194,13 @@ static void accel_cb(uint8_t sender_id __attribute__((unused)),
void ins_ext_pose_msg_update(uint8_t *buf)
{
if (DL_EXTERNAL_POSE_ac_id(buf) != AC_ID) { return; } // not for this aircraft

float enu_x = DL_EXTERNAL_POSE_enu_x(buf);
float enu_y = DL_EXTERNAL_POSE_enu_y(buf);
float enu_z = DL_EXTERNAL_POSE_enu_z(buf);


float enu_x = DL_EXTERNAL_POSE_enu_x(buf);
float enu_y = DL_EXTERNAL_POSE_enu_y(buf);
float enu_z = DL_EXTERNAL_POSE_enu_z(buf);
float enu_xd = DL_EXTERNAL_POSE_enu_xd(buf);
float enu_yd = DL_EXTERNAL_POSE_enu_yd(buf);
float enu_zd = DL_EXTERNAL_POSE_enu_zd(buf);
float quat_i = DL_EXTERNAL_POSE_body_qi(buf);
float quat_x = DL_EXTERNAL_POSE_body_qx(buf);
float quat_y = DL_EXTERNAL_POSE_body_qy(buf);
Expand All @@ -178,20 +211,28 @@ void ins_ext_pose_msg_update(uint8_t *buf)
struct FloatQuat orient;
struct FloatEulers orient_eulers;

orient.qi = quat_i;
orient.qx = quat_y; //north
orient.qy = -quat_x; //east
orient.qz = -quat_z; //down
// Transformation of External Pose. Optitrack motive 2.X Yup
orient.qi = quat_i ;
orient.qx = quat_y ;
orient.qy = quat_x ;
orient.qz = -quat_z;

float_eulers_of_quat(&orient_eulers, &orient);
orient_eulers.theta = -orient_eulers.theta;

ins_ext_pos.ev_pos.x = enu_y;
ins_ext_pos.ev_pos.y = enu_x;
ins_ext_pos.ev_pos.z = -enu_z;
ins_ext_pos.ev_att.phi = orient_eulers.phi;
ins_ext_pos.ev_att.theta = orient_eulers.theta;
ins_ext_pos.ev_att.psi = orient_eulers.psi;

ins_ext_pos.ev_time = get_sys_time_usec();
ins_ext_pos.ev_pos.x = enu_y;
ins_ext_pos.ev_pos.y = enu_x;
ins_ext_pos.ev_pos.z = -enu_z;
ins_ext_pos.ev_vel.x = enu_yd;
ins_ext_pos.ev_vel.y = enu_xd;
ins_ext_pos.ev_vel.z = -enu_zd;
ins_ext_pos.ev_att.phi = orient_eulers.phi;
ins_ext_pos.ev_att.theta = orient_eulers.theta;
ins_ext_pos.ev_att.psi = orient_eulers.psi;
ins_ext_pos.ev_quat.qi = orient.qi;
ins_ext_pos.ev_quat.qx = orient.qx;
ins_ext_pos.ev_quat.qy = orient.qy;
ins_ext_pos.ev_quat.qz = orient.qz;

ins_ext_pos.has_new_ext_pose = true;

Expand Down Expand Up @@ -235,12 +276,13 @@ void ins_ext_pose_init(void)
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_INS, send_ins);
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_INS_Z, send_ins_z);
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_INS_REF, send_ins_ref);
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_EXTERNAL_POSE_DOWN, send_external_pose_down);
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_AHRS_BIAS, send_ahrs_bias);
#endif

// Get IMU through ABI
AbiBindMsgIMU_ACCEL(INS_EXT_POSE_IMU_ID, &accel_ev, accel_cb);
AbiBindMsgIMU_GYRO(INS_EXT_POSE_IMU_ID, &gyro_ev, gyro_cb);

// Get External Pose through datalink message: setup in xml

// Initialize EKF
Expand Down Expand Up @@ -315,9 +357,9 @@ static inline void ekf_init(void)
float Z0[EKF_NUM_OUTPUTS] = {0, 0, 0, 0, 0, 0};

float Pdiag[EKF_NUM_STATES] = {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.};
float Qdiag[EKF_NUM_INPUTS] = {0.5, 0.5, 0.5, 0.01, 0.01, 0.01};
float Qdiag[EKF_NUM_INPUTS] = {1.0, 1.0, 1.0, 0.0173, 4.878e-4, 3.547e-4};//{0.0325, 0.4494, 0.5087, 0.0173, 4.878e-4, 3.547e-4};

float Rdiag[EKF_NUM_OUTPUTS] = {0.001, 0.001, 0.001, 0.1, 0.1, 0.1};
float Rdiag[EKF_NUM_OUTPUTS] = {8.372e-6, 3.832e-6, 4.761e-6, 2.830e-4, 8.684e-6, 7.013e-6};

MAKE_MATRIX_PTR(ekf_P_, ekf_P, EKF_NUM_STATES);
MAKE_MATRIX_PTR(ekf_Q_, ekf_Q, EKF_NUM_INPUTS);
Expand Down
4 changes: 2 additions & 2 deletions sw/airborne/modules/ins/ins_ext_pose.h
Expand Up @@ -37,7 +37,8 @@ Section 5.3: Non-additive noise formulation and equations
#define EKF_NUM_OUTPUTS 6

#include "std.h"

#include "math/pprz_algebra_float.h"
#include "state.h"
#include <stdio.h>


Expand All @@ -52,5 +53,4 @@ extern void ins_ext_pose_msg_update(uint8_t *buf);
extern void ins_ext_pos_log_header(FILE *file);
extern void ins_ext_pos_log_data(FILE *file);


#endif
186 changes: 186 additions & 0 deletions sw/airborne/modules/lidar/vl53l5cx_platform.h
@@ -0,0 +1,186 @@
/*
* Copyright (C) 2024 Fabien-B <name.surname@gmail.com>
*
* 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.
*/


#ifndef _PLATFORM_H_
#define _PLATFORM_H_
#pragma once

#include <stdint.h>
#include <string.h>
#include "mcu_periph/i2c.h"

#define VL53L5CX_I2C_BUF_SIZE 512


enum VL53L5CX_ERRORS {
VL53L5CX_NO_ERROR = 0,
VL53L5CX_NOT_DETECTED = 1,
VL53L5CX_ULD_LOADING_FAILED = 2,
VL53L5CX_SET_RESOLUTION_FAILED = 3,
VL53L5CX_RUNTIME_FAILURE = 4,
};

/**
* @brief Structure VL53L5CX_Platform needs to be filled by the customer,
* depending on his platform. At least, it contains the VL53L5CX I2C address.
* Some additional fields can be added, as descriptors, or platform
* dependencies. Anything added into this structure is visible into the platform
* layer.
*/

typedef struct
{
/* To be filled with customer's platform. At least an I2C address/descriptor
* needs to be added */
/* Example for most standard platform : I2C address of sensor */
uint16_t address;
//I2CDriver* i2cp;
struct i2c_periph *i2cdev;
bool data_available;
int16_t distances_mm[64];

enum VL53L5CX_ERRORS error_code;
uint8_t buf[VL53L5CX_I2C_BUF_SIZE+2];
void* user_data;

} VL53L5CX_Platform;

/*
* @brief The macro below is used to define the number of target per zone sent
* through I2C. This value can be changed by user, in order to tune I2C
* transaction, and also the total memory size (a lower number of target per
* zone means a lower RAM). The value must be between 1 and 4.
*/

#define VL53L5CX_NB_TARGET_PER_ZONE 1U

/*
* @brief The macro below can be used to avoid data conversion into the driver.
* By default there is a conversion between firmware and user data. Using this macro
* allows to use the firmware format instead of user format. The firmware format allows
* an increased precision.
*/

// #define VL53L5CX_USE_RAW_FORMAT

/*
* @brief All macro below are used to configure the sensor output. User can
* define some macros if he wants to disable selected output, in order to reduce
* I2C access.
*/

// #define VL53L5CX_DISABLE_AMBIENT_PER_SPAD
// #define VL53L5CX_DISABLE_NB_SPADS_ENABLED
// #define VL53L5CX_DISABLE_NB_TARGET_DETECTED
// #define VL53L5CX_DISABLE_SIGNAL_PER_SPAD
// #define VL53L5CX_DISABLE_RANGE_SIGMA_MM
// #define VL53L5CX_DISABLE_DISTANCE_MM
// #define VL53L5CX_DISABLE_REFLECTANCE_PERCENT
// #define VL53L5CX_DISABLE_TARGET_STATUS
// #define VL53L5CX_DISABLE_MOTION_INDICATOR

/**
* @param (VL53L5CX_Platform*) p_platform : Pointer of VL53L5CX platform
* structure.
* @param (uint16_t) Address : I2C location of value to read.
* @param (uint8_t) *p_values : Pointer of value to read.
* @return (uint8_t) status : 0 if OK
*/

uint8_t RdByte(
VL53L5CX_Platform *p_platform,
uint16_t RegisterAdress,
uint8_t *p_value);

/**
* @brief Mandatory function used to write one single byte.
* @param (VL53L5CX_Platform*) p_platform : Pointer of VL53L5CX platform
* structure.
* @param (uint16_t) Address : I2C location of value to read.
* @param (uint8_t) value : Pointer of value to write.
* @return (uint8_t) status : 0 if OK
*/

uint8_t WrByte(
VL53L5CX_Platform *p_platform,
uint16_t RegisterAdress,
uint8_t value);

/**
* @brief Mandatory function used to read multiples bytes.
* @param (VL53L5CX_Platform*) p_platform : Pointer of VL53L5CX platform
* structure.
* @param (uint16_t) Address : I2C location of values to read.
* @param (uint8_t) *p_values : Buffer of bytes to read.
* @param (uint32_t) size : Size of *p_values buffer.
* @return (uint8_t) status : 0 if OK
*/

uint8_t RdMulti(
VL53L5CX_Platform *p_platform,
uint16_t RegisterAdress,
uint8_t *p_values,
uint32_t size);

/**
* @brief Mandatory function used to write multiples bytes.
* @param (VL53L5CX_Platform*) p_platform : Pointer of VL53L5CX platform
* structure.
* @param (uint16_t) Address : I2C location of values to write.
* @param (uint8_t) *p_values : Buffer of bytes to write.
* @param (uint32_t) size : Size of *p_values buffer.
* @return (uint8_t) status : 0 if OK
*/

uint8_t WrMulti(
VL53L5CX_Platform *p_platform,
uint16_t RegisterAdress,
uint8_t *p_values,
uint32_t size);

/**
* @brief Optional function, only used to perform an hardware reset of the
* sensor. This function is not used in the API, but it can be used by the host.
* This function is not mandatory to fill if user don't want to reset the
* sensor.
* @param (VL53L5CX_Platform*) p_platform : Pointer of VL53L5CX platform
* structure.
* @return (uint8_t) status : 0 if OK
*/

// uint8_t Reset_Sensor(
// VL53L5CX_Platform *p_platform);

/**
* @brief Mandatory function, used to swap a buffer. The buffer size is always a
* multiple of 4 (4, 8, 12, 16, ...).
* @param (uint8_t*) buffer : Buffer to swap, generally uint32_t
* @param (uint16_t) size : Buffer size to swap
*/

void SwapBuffer(
uint8_t *buffer,
uint16_t size);
/**
* @brief Mandatory function, used to wait during an amount of time. It must be
* filled as it's used into the API.
* @param (VL53L5CX_Platform*) p_platform : Pointer of VL53L5CX platform
* structure.
* @param (uint32_t) TimeMs : Time to wait in ms.
* @return (uint8_t) status : 0 if wait is finished.
*/

uint8_t WaitMs(
VL53L5CX_Platform *p_platform,
uint32_t TimeMs);

#endif // _PLATFORM_H_
33 changes: 24 additions & 9 deletions sw/airborne/modules/nav/nav_heli_spinup.c
Expand Up @@ -24,6 +24,7 @@
*/

#include "modules/nav/nav_heli_spinup.h"
#include "firmwares/rotorcraft/stabilization.h"
#include "navigation.h"
#include "paparazzi.h"

Expand All @@ -41,11 +42,18 @@ void nav_heli_spinup_setup(uint16_t duration, float throttle)
nav_heli_spinup.duration = (duration > 0) ? duration : 1;
nav_heli_spinup.throttle = throttle * MAX_PPRZ;

#ifdef COMMAND_ROLL
stabilization_cmd[COMMAND_ROLL] = 0;
#endif
#ifdef COMMAND_PITCH
stabilization_cmd[COMMAND_PITCH] = 0;
#endif
#ifdef COMMAND_YAW
stabilization_cmd[COMMAND_YAW] = 0;
#endif
nav.throttle = 0;
nav.cmd_roll = 0;
nav.cmd_pitch = 0;
nav.cmd_yaw = 0;
nav.horizontal_mode = NAV_HORIZONTAL_MODE_ATTITUDE;

nav.horizontal_mode = NAV_HORIZONTAL_MODE_NONE;
nav.vertical_mode = NAV_VERTICAL_MODE_MANUAL;
}

Expand All @@ -59,11 +67,18 @@ bool nav_heli_spinup_run(void)
return false;
}

nav.cmd_roll = 0;
nav.cmd_pitch = 0;
nav.cmd_yaw = 0;
nav.horizontal_mode = NAV_HORIZONTAL_MODE_MANUAL;
nav.vertical_mode = NAV_VERTICAL_MODE_MANUAL;
#ifdef COMMAND_ROLL
stabilization_cmd[COMMAND_ROLL] = 0;
#endif
#ifdef COMMAND_PITCH
stabilization_cmd[COMMAND_PITCH] = 0;
#endif
#ifdef COMMAND_YAW
stabilization_cmd[COMMAND_YAW] = 0;
#endif
nav.throttle = stage_time * nav_heli_spinup.throttle / nav_heli_spinup.duration;

nav.horizontal_mode = NAV_HORIZONTAL_MODE_NONE;
nav.vertical_mode = NAV_VERTICAL_MODE_MANUAL;
return true;
}