Skip to content

Commit e39f4a4

Browse files
committed
Merge commit '680e2a702cee4c0b1efd034b85638acfd8c730aa' into upstream
2 parents feb62a9 + 680e2a7 commit e39f4a4

File tree

10 files changed

+20
-24
lines changed

10 files changed

+20
-24
lines changed

commands2/src/cpp/frc2/command/MecanumControllerCommand.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ void MecanumControllerCommand::Initialize() {
257257
m_prevSpeeds = m_kinematics.ToWheelSpeeds(
258258
frc::ChassisSpeeds{initialXVelocity, initialYVelocity, 0_rad_per_s});
259259

260-
m_timer.Reset();
261-
m_timer.Start();
260+
m_timer.Restart();
262261
if (m_usePID) {
263262
m_frontLeftController->Reset();
264263
m_rearLeftController->Reset();

commands2/src/cpp/frc2/command/RamseteCommand.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ void RamseteCommand::Initialize() {
9292
m_prevSpeeds = m_kinematics.ToWheelSpeeds(
9393
frc::ChassisSpeeds{initialState.velocity, 0_mps,
9494
initialState.velocity * initialState.curvature});
95-
m_timer.Reset();
96-
m_timer.Start();
95+
m_timer.Restart();
9796
if (m_usePID) {
9897
m_leftController->Reset();
9998
m_rightController->Reset();

commands2/src/cpp/frc2/command/WaitCommand.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ WaitCommand::WaitCommand(units::second_t duration) : m_duration{duration} {
1515
}
1616

1717
void WaitCommand::Initialize() {
18-
m_timer.Reset();
19-
m_timer.Start();
18+
m_timer.Restart();
2019
}
2120

2221
void WaitCommand::End(bool interrupted) {

commands2/src/include/frc2/command/Commands.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
#include <functional>
88
#include <initializer_list>
9+
#include <memory>
910
#include <span>
1011
#include <string>
12+
#include <type_traits>
1113
#include <utility>
1214
#include <vector>
1315

@@ -156,13 +158,15 @@ namespace cmd {
156158
* @param selector the selector function
157159
* @param commands map of commands to select from
158160
*/
159-
template <typename Key>
160-
[[nodiscard]] CommandPtr Select(
161-
std::function<Key()> selector,
162-
std::vector<std::pair<Key, CommandPtr>> commands) {
163-
return SelectCommand(std::move(selector),
164-
CommandPtr::UnwrapVector(std::move(commands)))
165-
.ToPtr();
161+
template <typename Key, class... Types>
162+
[[nodiscard]] CommandPtr Select(std::function<Key()> selector,
163+
std::pair<Key, Types>&&... commands) {
164+
std::vector<std::pair<Key, std::unique_ptr<Command>>> vec;
165+
166+
((void)vec.emplace_back(commands.first, std::move(commands.second).Unwrap()),
167+
...);
168+
169+
return SelectCommand(std::move(selector), std::move(vec)).ToPtr();
166170
}
167171

168172
// Command Groups

commands2/src/include/frc2/command/SwerveControllerCommand.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ void SwerveControllerCommand<NumModules>::Initialize() {
150150
return m_trajectory.States().back().pose.Rotation();
151151
};
152152
}
153-
m_timer.Reset();
154-
m_timer.Start();
153+
m_timer.Restart();
155154
}
156155

157156
template <size_t NumModules>

commands2/src/include/frc2/command/TrapezoidProfileCommand.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ class TrapezoidProfileCommand
6363
this->AddRequirements(requirements);
6464
}
6565

66-
void Initialize() override {
67-
m_timer.Reset();
68-
m_timer.Start();
69-
}
66+
void Initialize() override { m_timer.Restart(); }
7067

7168
void Execute() override { m_output(m_profile.Calculate(m_timer.Get())); }
7269

commands2/src/include/frc2/command/button/CommandJoystick.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace frc2 {
1212
/**
13-
* A subclass of {@link Joystick} with {@link Trigger} factories for
13+
* A version of {@link Joystick} with {@link Trigger} factories for
1414
* command-based.
1515
*
1616
* @see Joystick

commands2/src/include/frc2/command/button/CommandPS4Controller.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace frc2 {
1212
/**
13-
* A subclass of {@link PS4Controller} with {@link Trigger} factories for
13+
* A version of {@link PS4Controller} with {@link Trigger} factories for
1414
* command-based.
1515
*
1616
* @see PS4Controller

commands2/src/include/frc2/command/button/CommandXboxController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace frc2 {
1212
/**
13-
* A subclass of {@link XboxController} with {@link Trigger} factories for
13+
* A version of {@link XboxController} with {@link Trigger} factories for
1414
* command-based.
1515
*
1616
* @see XboxController

commands2/src/include/frc2/command/button/Trigger.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ class Trigger {
194194
Trigger ToggleOnFalse(Command* command);
195195

196196
/**
197-
* Toggles a command when the condition changes from `true` to the low
198-
* state.
197+
* Toggles a command when the condition changes from `true` to `false`.
199198
*
200199
* <p>Takes a raw pointer, and so is non-owning; users are responsible for the
201200
* lifespan of the command.

0 commit comments

Comments
 (0)