Skip to content

Commit

Permalink
move HLcmd rate limit out of stabilizer.c
Browse files Browse the repository at this point in the history
  • Loading branch information
jpreiss committed Dec 14, 2021
1 parent 4109e90 commit 65f3a41
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/modules/interface/crtp_commander_high_level.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void crtpCommanderHighLevelInit(void);

// Retrieves the current setpoint. Returns false if the high-level commander is
// disabled, i.e. it does not have an "opinion" on what the setpoint should be.
bool crtpCommanderHighLevelGetSetpoint(setpoint_t* setpoint, const state_t *state);
bool crtpCommanderHighLevelGetSetpoint(setpoint_t* setpoint, const state_t *state, uint32_t tick);

// When flying sequences of high-level commands, the high-level commander uses
// its own history of commands to determine the initial conditions of the next
Expand Down
6 changes: 5 additions & 1 deletion src/modules/src/crtp_commander_high_level.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,12 @@ int crtpCommanderHighLevelDisable()
return 0;
}

bool crtpCommanderHighLevelGetSetpoint(setpoint_t* setpoint, const state_t *state)
bool crtpCommanderHighLevelGetSetpoint(setpoint_t* setpoint, const state_t *state, uint32_t tick)
{
if (!RATE_DO_EXECUTE(RATE_HL_COMMANDER, tick)) {
return false;
}

xSemaphoreTake(lockTraj, portMAX_DELAY);
float t = usecTimestamp() / 1e6;
struct traj_eval ev = plan_current_goal(&planner, t);
Expand Down
6 changes: 2 additions & 4 deletions src/modules/src/stabilizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,8 @@ static void stabilizerTask(void* param)
stateEstimator(&state, tick);
compressState();

if (RATE_DO_EXECUTE(RATE_HL_COMMANDER, tick)) {
if (crtpCommanderHighLevelGetSetpoint(&tempSetpoint, &state)) {
commanderSetSetpoint(&tempSetpoint, COMMANDER_PRIORITY_HIGHLEVEL);
}
if (crtpCommanderHighLevelGetSetpoint(&tempSetpoint, &state, tick)) {
commanderSetSetpoint(&tempSetpoint, COMMANDER_PRIORITY_HIGHLEVEL);
}

commanderGetSetpoint(&setpoint, &state);
Expand Down

0 comments on commit 65f3a41

Please sign in to comment.