From 03c6576b7235b0d3e634172d4017402826b066b5 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Sat, 11 Jan 2025 00:28:31 +0300 Subject: [PATCH] Move controlsTime variable to rc.ino --- flix/failsafe.ino | 2 ++ flix/flix.ino | 1 - flix/mavlink.ino | 2 ++ flix/rc.ino | 1 + gazebo/flix.h | 1 - 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/flix/failsafe.ino b/flix/failsafe.ino index 7ddfa65..eab6ee5 100644 --- a/flix/failsafe.ino +++ b/flix/failsafe.ino @@ -6,6 +6,8 @@ #define RC_LOSS_TIMEOUT 0.2 #define DESCEND_TIME 3.0 // time to descend from full throttle to zero +extern float controlsTime; + void failsafe() { if (t - controlsTime > RC_LOSS_TIMEOUT) { descend(); diff --git a/flix/flix.ino b/flix/flix.ino index 846eaea..2b2332c 100644 --- a/flix/flix.ino +++ b/flix/flix.ino @@ -22,7 +22,6 @@ float t = NAN; // current step time, s float dt; // time delta from previous step, s int16_t channels[RC_CHANNELS]; // raw rc channels float controls[RC_CHANNELS]; // normalized controls in range [-1..1] ([0..1] for throttle) -float controlsTime; // time of the last controls update Vector gyro; // gyroscope data Vector acc; // accelerometer data, m/s/s Vector rates; // filtered angular rates, rad/s diff --git a/flix/mavlink.ino b/flix/mavlink.ino index 3bf73a1..3304f25 100644 --- a/flix/mavlink.ino +++ b/flix/mavlink.ino @@ -13,6 +13,8 @@ #define MAVLINK_CONTROL_SCALE 0.7f #define MAVLINK_CONTROL_YAW_DEAD_ZONE 0.1f +extern float controlsTime; + void processMavlink() { sendMavlink(); receiveMavlink(); diff --git a/flix/rc.ino b/flix/rc.ino index 34fd3d4..8cf8e5c 100644 --- a/flix/rc.ino +++ b/flix/rc.ino @@ -9,6 +9,7 @@ // NOTE: use 'cr' command to calibrate the RC and put the values here int channelNeutral[] = {995, 883, 200, 972, 512, 512, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int channelMax[] = {1651, 1540, 1713, 1630, 1472, 1472, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +float controlsTime; // time of the last controls update SBUS RC(Serial2); // NOTE: Use RC(Serial2, 16, 17) if you use the old UART2 pins diff --git a/gazebo/flix.h b/gazebo/flix.h index a0d865f..3f2f994 100644 --- a/gazebo/flix.h +++ b/gazebo/flix.h @@ -18,7 +18,6 @@ float dt; float motors[4]; int16_t channels[16]; // raw rc channels float controls[RC_CHANNELS]; -float controlsTime; Vector acc; Vector gyro; Vector rates;