Skip to content

OSD support of Kalman settings #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 3.3_kalman_test
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions src/main/cms/cms_menu_imu.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,75 @@ CMS_Menu cmsx_menuCopyProfile = {

#endif

static uint8_t gyroConfig_gyro_kalman_enable;
static uint16_t gyroConfig_gyro_kalman_q;
static uint16_t gyroConfig_gyro_kalman_r;
static uint16_t gyroConfig_gyro_kalman_p;

static long cmsx_kalmanOnEnter(void)
{
gyroConfig_gyro_kalman_enable = gyroConfig()->gyro_kalman_enable;
gyroConfig_gyro_kalman_q = gyroConfig()->gyro_kalman_q;
gyroConfig_gyro_kalman_r = gyroConfig()->gyro_kalman_r;
gyroConfig_gyro_kalman_p = gyroConfig()->gyro_kalman_p;

return cmsx_RateProfileOnEnter();
}

static long cmsx_kalmanWriteback(const OSD_Entry *self)
{
gyroConfigMutable()->gyro_kalman_enable = gyroConfig_gyro_kalman_enable;
gyroConfigMutable()->gyro_kalman_q = gyroConfig_gyro_kalman_q;
gyroConfigMutable()->gyro_kalman_r = gyroConfig_gyro_kalman_r;
gyroConfigMutable()->gyro_kalman_p = gyroConfig_gyro_kalman_p;

return cmsx_RateProfileWriteback(self);
}

static OSD_Entry cmsx_menuKalmanEntries[] =
{
{ "-- KALMAN --", OME_Label, NULL, rateProfileIndexString, 0},
{ "ENABLED", OME_Bool, NULL, &gyroConfig_gyro_kalman_enable, 0 },

{ "KALMAN Q", OME_UINT16, NULL, &(OSD_UINT16_t) { &gyroConfig_gyro_kalman_q, 0, 16000, 10 }, 0 },
{ "KALMAN R", OME_UINT16, NULL, &(OSD_UINT16_t) { &gyroConfig_gyro_kalman_r, 0, 16000, 10 }, 0 },
Copy link

@apocolipse apocolipse Jan 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step should be 1 for gyroConfig_gyro_kalman_r, probably fine to have the others at 10

{ "KALMAN P", OME_UINT16, NULL, &(OSD_UINT16_t) { &gyroConfig_gyro_kalman_p, 0, 16000, 10 }, 0 },

{ "RF RATE ENABLED", OME_Bool, NULL, &rateProfile.rfRatesEnabled, 0 },

{ "RF RATE ROLL", OME_UINT16, NULL, &(OSD_UINT16_t) { &rateProfile.rfRate[FD_ROLL], 200, 1500, 10 }, 0 },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step for Rate should be 5, all can probably be 5 but rate should be 1 or 5 not 10.

{ "RF ACRO ROLL", OME_UINT8, NULL, &(OSD_UINT8_t) { &rateProfile.rfAcro[FD_ROLL], 0, 255, 1 }, 0 },
{ "RF EXPO ROLL", OME_UINT8, NULL, &(OSD_UINT8_t) { &rateProfile.rfExpo[FD_ROLL], 0, 100, 1 }, 0 },

{ "RF RATE PITCH", OME_UINT16, NULL, &(OSD_UINT16_t) { &rateProfile.rfRate[FD_PITCH], 200, 1500, 10 }, 0 },
{ "RF ACRO PITCH", OME_UINT8, NULL, &(OSD_UINT8_t) { &rateProfile.rfAcro[FD_PITCH], 0, 255, 1 }, 0 },
{ "RF EXPO PITCH", OME_UINT8, NULL, &(OSD_UINT8_t) { &rateProfile.rfExpo[FD_PITCH], 0, 100, 1 }, 0 },

{ "RF RATE YAW", OME_UINT16, NULL, &(OSD_UINT16_t) { &rateProfile.rfRate[FD_YAW], 200, 1500, 10 }, 0 },
{ "RF ACRO YAW", OME_UINT8, NULL, &(OSD_UINT8_t) { &rateProfile.rfAcro[FD_YAW], 0, 255, 1 }, 0 },
{ "RF EXPO YAW", OME_UINT8, NULL, &(OSD_UINT8_t) { &rateProfile.rfExpo[FD_YAW], 0, 100, 1 }, 0 },

{"BACK", OME_Back, NULL, NULL, 0},
{ NULL, OME_END, NULL, NULL, 0 }
};

static CMS_Menu cmsx_menuKalman = {
#ifdef CMS_MENU_DEBUG
.GUARD_text = "XKALMAN",
.GUARD_type = OME_MENU,
#endif
.onEnter = cmsx_kalmanOnEnter,
.onExit = cmsx_kalmanWriteback,
.entries = cmsx_menuKalmanEntries
};

static OSD_Entry cmsx_menuImuEntries[] =
{
{ "-- IMU --", OME_Label, NULL, NULL, 0},

{"PID PROF", OME_UINT8, cmsx_profileIndexOnChange, &(OSD_UINT8_t){ &tmpPidProfileIndex, 1, MAX_PROFILE_COUNT, 1}, 0},
{"PID", OME_Submenu, cmsMenuChange, &cmsx_menuPid, 0},
{"KALMAN", OME_Submenu, cmsMenuChange, &cmsx_menuKalman, 0},
{"MISC PP", OME_Submenu, cmsMenuChange, &cmsx_menuProfileOther, 0},
{"FILT PP", OME_Submenu, cmsMenuChange, &cmsx_menuFilterPerProfile, 0},

Expand Down