Skip to content

Commit

Permalink
CR101
Browse files Browse the repository at this point in the history
  • Loading branch information
breadoven committed Aug 8, 2023
1 parent 02ed34d commit 8b471c0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
12 changes: 1 addition & 11 deletions docs/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -2654,7 +2654,7 @@ Speed in fully autonomous modes (RTH, WP) [cm/s]. Used for WP mode when no speci

### nav_cruise_yaw_rate

Max YAW rate when NAV CRUISE mode is enabled (set to 0 to disable) [dps]
Max YAW rate when NAV COURSE HOLD/CRUISE mode is enabled. Set to 0 to disable on fixed wing (Note: On multirotor setting to 0 will disable Course Hold/Cruise mode completely) [dps]

| Default | Min | Max |
| --- | --- | --- |
Expand Down Expand Up @@ -4312,16 +4312,6 @@ Temperature under which the IMU temperature OSD element will start blinking (dec

---

### osd_infocycle_interval_time

Info Cycle field item display time (milliseconds).

| Default | Min | Max |
| --- | --- | --- |
| 2000 | 500 | 5000 |

---

### osd_left_sidebar_scroll

_// TODO_
Expand Down
2 changes: 1 addition & 1 deletion src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2588,7 +2588,7 @@ groups:
type: bool
# CR101
- name: nav_cruise_yaw_rate
description: "Max YAW rate when NAV CRUISE mode is enabled (set to 0 to disable) [dps]"
description: "Max YAW rate when NAV COURSE HOLD/CRUISE mode is enabled. Set to 0 to disable on fixed wing (Note: On multirotor setting to 0 will disable Course Hold/Cruise mode completely) [dps]"
default_value: 20
field: general.cruise_yaw_rate
min: 0
Expand Down
19 changes: 11 additions & 8 deletions src/main/navigation/navigation.c
Original file line number Diff line number Diff line change
Expand Up @@ -1117,19 +1117,19 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_COURSE_HOLD_IN_PROGRESS
}
// CR101
int16_t cruiseYawRate = DEGREES_TO_CENTIDEGREES(navConfig()->general.cruise_yaw_rate);
int16_t headingAdjustCommand = 0;
const bool mcRollStickHeadingAdjustmentActive = STATE(MULTIROTOR) && ABS(rcCommand[ROLL]) > rcControlsConfig()->pos_hold_deadband;

// User demanding yaw (yaw on FW, yaw and roll on MR). We record the desired course and change the desired target in the meanwhile
if (posControl.flags.isAdjustingHeading || posControl.flags.isAdjustingPosition) {
headingAdjustCommand = rcCommand[YAW];
if (posControl.flags.isAdjustingPosition && rcCommand[ROLL] > headingAdjustCommand) {
headingAdjustCommand = rcCommand[ROLL];
// User demanding yaw -> yaw stick on FW, yaw and roll sticks on MR
// We record the desired course and change the desired target in the meanwhile
if (posControl.flags.isAdjustingHeading || mcRollStickHeadingAdjustmentActive) {
int16_t headingAdjustCommand = rcCommand[YAW];
if (mcRollStickHeadingAdjustmentActive && ABS(rcCommand[ROLL]) > ABS(headingAdjustCommand)) {
headingAdjustCommand = -rcCommand[ROLL];
}
// if (posControl.flags.isAdjustingHeading) {

timeMs_t timeDifference = currentTimeMs - posControl.cruise.lastCourseAdjustmentTime;
if (timeDifference > 100) timeDifference = 0; // if adjustment was called long time ago, reset the time difference.
float rateTarget = scaleRangef((float)headingAdjustCommand, -500.0f, 500.0f, -cruiseYawRate, cruiseYawRate); // CR101
// float rateTarget = scaleRangef((float)rcCommand[YAW], -500.0f, 500.0f, -DEGREES_TO_CENTIDEGREES(navConfig()->general.cruise_yaw_rate), DEGREES_TO_CENTIDEGREES(navConfig()->general.cruise_yaw_rate));
float centidegsPerIteration = rateTarget * MS2S(timeDifference);
posControl.cruise.course = wrap_36000(posControl.cruise.course - centidegsPerIteration);
posControl.cruise.lastCourseAdjustmentTime = currentTimeMs;
Expand Down Expand Up @@ -1160,6 +1160,9 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_COURSE_HOLD_ADJUSTING(n

static navigationFSMEvent_t navOnEnteringState_NAV_STATE_CRUISE_INITIALIZE(navigationFSMState_t previousState)
{
if (STATE(MULTIROTOR) && !navConfig()->general.cruise_yaw_rate) { // course hole not possible on MR without yaw control
return NAV_FSM_EVENT_ERROR;
}
// if (!STATE(FIXED_WING_LEGACY)) { return NAV_FSM_EVENT_ERROR; } // only on FW for now // CR101

navOnEnteringState_NAV_STATE_ALTHOLD_INITIALIZE(previousState);
Expand Down

0 comments on commit 8b471c0

Please sign in to comment.