mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
Reduce scope of for loop variables to for loop initializer (#517)
This commit is contained in:
committed by
Fred Silberberg
parent
dbe821baee
commit
a5cd24e7ea
@@ -134,11 +134,12 @@ int16_t DriverStation::GetStickButtons(int stick) {
|
||||
"stick must be between 0 and 5");
|
||||
return false;
|
||||
}
|
||||
int16_t btns = 0, btnid;
|
||||
int16_t btns = 0;
|
||||
|
||||
std::unique_lock<std::recursive_mutex> lock(m_joystickMutex);
|
||||
gazebo::msgs::FRCJoystickPtr joy = joysticks[stick];
|
||||
for (btnid = 0; btnid < joy->buttons().size() && btnid < 12; btnid++) {
|
||||
for (int16_t btnid = 0; btnid < joy->buttons().size() && btnid < 12;
|
||||
btnid++) {
|
||||
if (joysticks[stick]->buttons(btnid)) {
|
||||
btns |= (1 << btnid);
|
||||
}
|
||||
|
||||
@@ -633,13 +633,12 @@ double RobotDrive::Limit(double num) {
|
||||
*/
|
||||
void RobotDrive::Normalize(double* wheelSpeeds) {
|
||||
double maxMagnitude = std::fabs(wheelSpeeds[0]);
|
||||
int i;
|
||||
for (i = 1; i < kMaxNumberOfMotors; i++) {
|
||||
for (int i = 1; i < kMaxNumberOfMotors; i++) {
|
||||
double temp = std::fabs(wheelSpeeds[i]);
|
||||
if (maxMagnitude < temp) maxMagnitude = temp;
|
||||
}
|
||||
if (maxMagnitude > 1.0) {
|
||||
for (i = 0; i < kMaxNumberOfMotors; i++) {
|
||||
for (int i = 0; i < kMaxNumberOfMotors; i++) {
|
||||
wheelSpeeds[i] = wheelSpeeds[i] / maxMagnitude;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user