Port changes from commit 52819e4

This commit is contained in:
Oleg Kalachev
2025-07-15 01:22:18 +03:00
parent 4d1f9de872
commit 0c87d4d634
11 changed files with 98 additions and 76 deletions

View File

@@ -18,6 +18,9 @@ public:
SBUSData data() {
SBUSData data;
joystickGet(data.ch);
for (int i = 0; i < 16; i++) {
data.ch[i] = map(data.ch[i], -32768, 32767, 1000, 2000); // convert to pulse width style
}
return data;
};
};

View File

@@ -15,8 +15,7 @@
float t = NAN;
float dt;
float motors[4];
int16_t channels[16]; // raw rc channels
float controls[16];
float controlRoll, controlPitch, controlYaw, controlThrottle, controlArmed, controlMode;
Vector acc;
Vector gyro;
Vector rates;
@@ -36,7 +35,7 @@ void sendMotors();
bool motorsActive();
void doCommand(const String& command);
void normalizeRC();
void printRCCal();
void printRCCalibration();
void processMavlink();
void sendMavlink();
void sendMessage(const void *msg);

View File

@@ -8,15 +8,16 @@
#include <iostream>
// simulation calibration overrides, NOTE: use `cr` command and replace with the actual values
const int channelNeutralOverride[] = {-258, -258, -27349, 0, -27349, 0};
const int channelMaxOverride[] = {27090, 27090, 27090, 27090, -5676, 1};
const int channelZeroOverride[] = {1500, 0, 1000, 1500, 1500, 1000};
const int channelMaxOverride[] = {2000, 2000, 2000, 2000, 2000, 2000};
#define RC_CHANNEL_ROLL 0
#define RC_CHANNEL_PITCH 1
#define RC_CHANNEL_THROTTLE 2
#define RC_CHANNEL_YAW 3
#define RC_CHANNEL_ARMED 5
#define RC_CHANNEL_MODE 4
// channels mapping overrides
const int rollChannelOverride = 3;
const int pitchChannelOverride = 4;
const int throttleChannelOverride = 5;
const int yawChannelOverride = 0;
const int armedChannelOverride = 2;
const int modeChannelOverride = 1;
SDL_Joystick *joystick;
@@ -37,12 +38,20 @@ bool joystickInit() {
warnShown = true;
}
// apply calibration overrides
extern int channelNeutral[16];
// apply overrides
extern int channelZero[16];
extern int channelMax[16];
memcpy(channelNeutral, channelNeutralOverride, sizeof(channelNeutralOverride));
memcpy(channelZero, channelZeroOverride, sizeof(channelZeroOverride));
memcpy(channelMax, channelMaxOverride, sizeof(channelMaxOverride));
extern int rollChannel, pitchChannel, throttleChannel, yawChannel, armedChannel, modeChannel;
rollChannel = rollChannelOverride;
pitchChannel = pitchChannelOverride;
throttleChannel = throttleChannelOverride;
yawChannel = yawChannelOverride;
armedChannel = armedChannelOverride;
modeChannel = modeChannelOverride;
return joystickInitialized;
}

View File

@@ -70,8 +70,8 @@ public:
// read rc
readRC();
controls[RC_CHANNEL_MODE] = 1; // 0 acro, 1 stab
controls[RC_CHANNEL_ARMED] = 1; // armed
controlMode = 1; // 0 acro, 1 stab
controlArmed = 1; // armed
estimate();