Skip to content

Commit

Permalink
Sub: Introduced AUTO_YAW_RATE mode and its features.
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshv24 authored and Williangalvani committed Jul 27, 2023
1 parent 617fb98 commit d8b171e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ArduSub/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ enum autopilot_yaw_mode {
AUTO_YAW_LOOK_AT_HEADING = 3, // point towards a particular angle (not pilot input accepted)
AUTO_YAW_LOOK_AHEAD = 4, // point in the direction the vehicle is moving
AUTO_YAW_RESETTOARMEDYAW = 5, // point towards heading at time motors were armed
AUTO_YAW_CORRECT_XTRACK = 6 // steer the sub in order to correct for crosstrack error during line following
AUTO_YAW_CORRECT_XTRACK = 6, // steer the sub in order to correct for crosstrack error during line following
AUTO_YAW_RATE = 7 // steer the sub with the desired yaw rate
};

// Acro Trainer types
Expand Down
1 change: 1 addition & 0 deletions ArduSub/mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ class ModeGuided : public Mode
float get_auto_heading();
void guided_limit_clear();
void set_auto_yaw_mode(autopilot_yaw_mode yaw_mode);
void set_yaw_rate(float turn_rate_dps);

protected:

Expand Down
11 changes: 11 additions & 0 deletions ArduSub/mode_auto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,17 @@ void ModeAuto::set_auto_yaw_look_at_heading(float angle_deg, float turn_rate_dps
// TO-DO: restore support for clockwise and counter clockwise rotation held in cmd.content.yaw.direction. 1 = clockwise, -1 = counterclockwise
}


// sets the desired yaw rate
void ModeGuided::set_yaw_rate(float turn_rate_dps)
{
// set sub to desired yaw rate
sub.yaw_look_at_heading_slew = MIN(turn_rate_dps, AUTO_YAW_SLEW_RATE); // deg / sec

// set yaw mode
set_auto_yaw_mode(AUTO_YAW_RATE);
}

// set_auto_yaw_roi - sets the yaw to look at roi for auto mode
void ModeAuto::set_auto_yaw_roi(const Location &roi_location)
{
Expand Down
4 changes: 4 additions & 0 deletions ArduSub/mode_guided.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,10 @@ void ModeGuided::set_auto_yaw_mode(autopilot_yaw_mode yaw_mode)
case AUTO_YAW_RESETTOARMEDYAW:
// initial_armed_bearing will be set during arming so no init required
break;

case AUTO_YAW_RATE:
// set target yaw rate to yaw_look_at_heading_slew
break;
}
}

Expand Down

0 comments on commit d8b171e

Please sign in to comment.