Skip to content

Commit

Permalink
[wpilib] Fix Mecanum and SwerveControllerCommand when desired rotatio…
Browse files Browse the repository at this point in the history
…n passed (#3808)
  • Loading branch information
sciencewhiz authored Dec 20, 2021
1 parent 1ad3b1b commit 9f8f330
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,11 @@ MecanumControllerCommand::MecanumControllerCommand(
}

void MecanumControllerCommand::Initialize() {
m_desiredRotation = [&] {
return m_trajectory.States().back().pose.Rotation();
};
if (m_desiredRotation == nullptr) {
m_desiredRotation = [&] {
return m_trajectory.States().back().pose.Rotation();
};
}
m_prevTime = 0_s;
auto initialState = m_trajectory.Sample(0_s);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ SwerveControllerCommand<NumModules>::SwerveControllerCommand(

template <size_t NumModules>
void SwerveControllerCommand<NumModules>::Initialize() {
m_desiredRotation = [&] {
return m_trajectory.States().back().pose.Rotation();
};
if (m_desiredRotation == nullptr) {
m_desiredRotation = [&] {
return m_trajectory.States().back().pose.Rotation();
};
}
m_timer.Reset();
m_timer.Start();
}
Expand Down

0 comments on commit 9f8f330

Please sign in to comment.