mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Clean up Java style (#5990)
Also make equivalent changes in C++ where applicable. Co-authored-by: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "frc/I2C.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
@@ -96,7 +97,7 @@ bool I2C::VerifySensor(int registerAddress, int count,
|
||||
uint8_t deviceData[4];
|
||||
for (int i = 0, curRegisterAddress = registerAddress; i < count;
|
||||
i += 4, curRegisterAddress += 4) {
|
||||
int toRead = count - i < 4 ? count - i : 4;
|
||||
int toRead = std::min(count - i, 4);
|
||||
// Read the chunk of data. Return false if the sensor does not respond.
|
||||
if (Read(curRegisterAddress, toRead, deviceData)) {
|
||||
return false;
|
||||
|
||||
@@ -23,15 +23,15 @@ using namespace frc;
|
||||
/** Converts volts to PSI per the REV Analog Pressure Sensor datasheet. */
|
||||
units::pounds_per_square_inch_t VoltsToPSI(units::volt_t sensorVoltage,
|
||||
units::volt_t supplyVoltage) {
|
||||
auto pressure = 250 * (sensorVoltage.value() / supplyVoltage.value()) - 25;
|
||||
return units::pounds_per_square_inch_t{pressure};
|
||||
return units::pounds_per_square_inch_t{
|
||||
250 * (sensorVoltage.value() / supplyVoltage.value()) - 25};
|
||||
}
|
||||
|
||||
/** Converts PSI to volts per the REV Analog Pressure Sensor datasheet. */
|
||||
units::volt_t PSIToVolts(units::pounds_per_square_inch_t pressure,
|
||||
units::volt_t supplyVoltage) {
|
||||
auto voltage = supplyVoltage.value() * (0.004 * pressure.value() + 0.1);
|
||||
return units::volt_t{voltage};
|
||||
return units::volt_t{supplyVoltage.value() *
|
||||
(0.004 * pressure.value() + 0.1)};
|
||||
}
|
||||
|
||||
wpi::mutex PneumaticHub::m_handleLock;
|
||||
|
||||
@@ -92,26 +92,22 @@ Pose2d DifferentialDrivetrainSim::GetPose() const {
|
||||
}
|
||||
|
||||
units::ampere_t DifferentialDrivetrainSim::GetLeftCurrentDraw() const {
|
||||
auto loadIleft =
|
||||
m_motor.Current(
|
||||
units::radians_per_second_t{m_x(State::kLeftVelocity) *
|
||||
m_currentGearing / m_wheelRadius.value()},
|
||||
units::volt_t{m_u(0)}) *
|
||||
wpi::sgn(m_u(0));
|
||||
|
||||
return loadIleft;
|
||||
return m_motor.Current(units::radians_per_second_t{m_x(State::kLeftVelocity) *
|
||||
m_currentGearing /
|
||||
m_wheelRadius.value()},
|
||||
units::volt_t{m_u(0)}) *
|
||||
wpi::sgn(m_u(0));
|
||||
}
|
||||
|
||||
units::ampere_t DifferentialDrivetrainSim::GetRightCurrentDraw() const {
|
||||
auto loadIRight =
|
||||
m_motor.Current(
|
||||
units::radians_per_second_t{m_x(State::kRightVelocity) *
|
||||
m_currentGearing / m_wheelRadius.value()},
|
||||
units::volt_t{m_u(1)}) *
|
||||
wpi::sgn(m_u(1));
|
||||
|
||||
return loadIRight;
|
||||
return m_motor.Current(
|
||||
units::radians_per_second_t{m_x(State::kRightVelocity) *
|
||||
m_currentGearing /
|
||||
m_wheelRadius.value()},
|
||||
units::volt_t{m_u(1)}) *
|
||||
wpi::sgn(m_u(1));
|
||||
}
|
||||
|
||||
units::ampere_t DifferentialDrivetrainSim::GetCurrentDraw() const {
|
||||
return GetLeftCurrentDraw() + GetRightCurrentDraw();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user