[wpilib] Fix Mecanum and SwerveControllerCommand when desired rotation passed (#3808)

This commit is contained in:
sciencewhiz
2021-12-19 20:08:28 -08:00
committed by GitHub
parent 1ad3b1b333
commit 9f8f330e96
2 changed files with 10 additions and 6 deletions

View File

@@ -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);

View File

@@ -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();
}