Skip to content

Commit

Permalink
Move controlsTime variable to rc.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
okalachev committed Jan 10, 2025
1 parent 59a8a80 commit 03c6576
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions flix/failsafe.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion flix/flix.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions flix/mavlink.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions flix/rc.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion gazebo/flix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 03c6576

Please sign in to comment.