mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
Fixes warnings thrown by cpplint.py (#154)
* Fixed cpplint.py [runtime/int] warnings * Fixed cpplint.py [readability/casting] warnings * Fixed cpplint.py [readability/namespace] warnings * Fixed cpplint.py [readability/braces] warnings * Fixed cpplint.py [whitespace/braces] warnings * Fixed cpplint.py [runtime/explicit] warnings * Fixed cpplint.py [runtime/printf] warnings * Fixed cpplint.py [readability/inheritance] warnings * Fixed cpplint.py [whitespace/tab] warnings * Fixed cpplint.py [build/storage_class] warnings * Fixed cpplint.py [readability/multiline_comment] warnings * Fixed cpplint.py [whitespace/semicolon] warnings * Fixed cpplint.py [readability/check] warnings * Fixed cpplint.py [runtime/arrays] warnings * Ran format.py
This commit is contained in:
committed by
Peter Johnson
parent
e44a6e227a
commit
0cb288ffba
@@ -36,7 +36,8 @@ class AnalogPotentiometer : public Potentiometer, public LiveWindowSendable {
|
||||
* @param offset The offset to add to the scaled value for controlling the
|
||||
* zero value
|
||||
*/
|
||||
AnalogPotentiometer(int channel, double scale = 1.0, double offset = 0.0);
|
||||
explicit AnalogPotentiometer(int channel, double scale = 1.0,
|
||||
double offset = 0.0);
|
||||
|
||||
AnalogPotentiometer(AnalogInput* input, double scale = 1.0,
|
||||
double offset = 0.0);
|
||||
@@ -58,27 +59,27 @@ class AnalogPotentiometer : public Potentiometer, public LiveWindowSendable {
|
||||
*
|
||||
* @return The current reading.
|
||||
*/
|
||||
virtual double PIDGet() override;
|
||||
double PIDGet() override;
|
||||
|
||||
/*
|
||||
* Live Window code, only does anything if live window is activated.
|
||||
*/
|
||||
virtual std::string GetSmartDashboardType() const override;
|
||||
virtual void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
virtual void UpdateTable() override;
|
||||
virtual std::shared_ptr<ITable> GetTable() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void UpdateTable() override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
|
||||
/**
|
||||
* AnalogPotentiometers don't have to do anything special when entering the
|
||||
* LiveWindow.
|
||||
*/
|
||||
virtual void StartLiveWindowMode() override {}
|
||||
void StartLiveWindowMode() override {}
|
||||
|
||||
/**
|
||||
* AnalogPotentiometers don't have to do anything special when exiting the
|
||||
* LiveWindow.
|
||||
*/
|
||||
virtual void StopLiveWindowMode() override {}
|
||||
void StopLiveWindowMode() override {}
|
||||
|
||||
private:
|
||||
double m_scale, m_offset;
|
||||
|
||||
@@ -80,7 +80,7 @@ class Counter : public SensorBase,
|
||||
void UpdateTable() override;
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
virtual std::string GetSmartDashboardType() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
|
||||
float GetStickAxis(uint32_t stick, uint32_t axis);
|
||||
bool GetStickButton(uint32_t stick, uint32_t button);
|
||||
short GetStickButtons(uint32_t stick);
|
||||
int16_t GetStickButtons(uint32_t stick);
|
||||
|
||||
float GetAnalogIn(uint32_t channel);
|
||||
bool GetDigitalIn(uint32_t channel);
|
||||
|
||||
@@ -22,5 +22,5 @@ class Jaguar : public SafePWM, public SpeedController {
|
||||
virtual float Get() const;
|
||||
virtual void Disable();
|
||||
|
||||
virtual void PIDWrite(float output) override;
|
||||
void PIDWrite(float output) override;
|
||||
};
|
||||
|
||||
@@ -50,19 +50,19 @@ class Joystick : public GenericHID, public ErrorBase {
|
||||
uint32_t GetAxisChannel(AxisType axis);
|
||||
void SetAxisChannel(AxisType axis, uint32_t channel);
|
||||
|
||||
virtual float GetX(JoystickHand hand = kRightHand) const override;
|
||||
virtual float GetY(JoystickHand hand = kRightHand) const override;
|
||||
virtual float GetZ() const override;
|
||||
virtual float GetTwist() const override;
|
||||
virtual float GetThrottle() const override;
|
||||
float GetX(JoystickHand hand = kRightHand) const override;
|
||||
float GetY(JoystickHand hand = kRightHand) const override;
|
||||
float GetZ() const override;
|
||||
float GetTwist() const override;
|
||||
float GetThrottle() const override;
|
||||
virtual float GetAxis(AxisType axis) const;
|
||||
float GetRawAxis(uint32_t axis) const override;
|
||||
|
||||
virtual bool GetTrigger(JoystickHand hand = kRightHand) const override;
|
||||
virtual bool GetTop(JoystickHand hand = kRightHand) const override;
|
||||
virtual bool GetBumper(JoystickHand hand = kRightHand) const override;
|
||||
virtual bool GetRawButton(uint32_t button) const override;
|
||||
virtual int GetPOV(uint32_t pov = 1) const override;
|
||||
bool GetTrigger(JoystickHand hand = kRightHand) const override;
|
||||
bool GetTop(JoystickHand hand = kRightHand) const override;
|
||||
bool GetBumper(JoystickHand hand = kRightHand) const override;
|
||||
bool GetRawButton(uint32_t button) const override;
|
||||
int GetPOV(uint32_t pov = 1) const override;
|
||||
bool GetButton(ButtonType button) const;
|
||||
static Joystick* GetStickForPort(uint32_t port);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class MotorSafety;
|
||||
|
||||
class MotorSafetyHelper : public ErrorBase {
|
||||
public:
|
||||
MotorSafetyHelper(MotorSafety* safeObject);
|
||||
explicit MotorSafetyHelper(MotorSafety* safeObject);
|
||||
~MotorSafetyHelper();
|
||||
void Feed();
|
||||
void SetExpiration(float expirationTime);
|
||||
|
||||
@@ -43,7 +43,7 @@ class PWM : public SensorBase,
|
||||
|
||||
explicit PWM(uint32_t channel);
|
||||
virtual ~PWM();
|
||||
virtual void SetRaw(unsigned short value);
|
||||
virtual void SetRaw(uint16_t value);
|
||||
void SetPeriodMultiplier(PeriodMultiplier mult);
|
||||
void EnableDeadbandElimination(bool eliminateDeadband);
|
||||
void SetBounds(int32_t max, int32_t deadbandMax, int32_t center,
|
||||
|
||||
@@ -39,7 +39,7 @@ class Relay : public MotorSafety,
|
||||
enum Value { kOff, kOn, kForward, kReverse };
|
||||
enum Direction { kBothDirections, kForwardOnly, kReverseOnly };
|
||||
|
||||
Relay(uint32_t channel, Direction direction = kBothDirections);
|
||||
explicit Relay(uint32_t channel, Direction direction = kBothDirections);
|
||||
virtual ~Relay();
|
||||
|
||||
void Set(Value value);
|
||||
|
||||
@@ -22,5 +22,5 @@ class Talon : public SafePWM, public SpeedController {
|
||||
virtual float Get() const;
|
||||
virtual void Disable();
|
||||
|
||||
virtual void PIDWrite(float output) override;
|
||||
void PIDWrite(float output) override;
|
||||
};
|
||||
|
||||
@@ -22,5 +22,5 @@ class Victor : public SafePWM, public SpeedController {
|
||||
virtual float Get() const;
|
||||
virtual void Disable();
|
||||
|
||||
virtual void PIDWrite(float output) override;
|
||||
void PIDWrite(float output) override;
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ class SimContinuousOutput {
|
||||
float speed;
|
||||
|
||||
public:
|
||||
SimContinuousOutput(std::string topic);
|
||||
explicit SimContinuousOutput(std::string topic);
|
||||
|
||||
/**
|
||||
* Set the output value.
|
||||
|
||||
@@ -14,7 +14,7 @@ using namespace gazebo;
|
||||
|
||||
class SimDigitalInput {
|
||||
public:
|
||||
SimDigitalInput(std::string topic);
|
||||
explicit SimDigitalInput(std::string topic);
|
||||
|
||||
/**
|
||||
* @return The value of the potentiometer.
|
||||
|
||||
@@ -15,7 +15,7 @@ using namespace gazebo;
|
||||
|
||||
class SimEncoder {
|
||||
public:
|
||||
SimEncoder(std::string topic);
|
||||
explicit SimEncoder(std::string topic);
|
||||
|
||||
void Reset();
|
||||
void Start();
|
||||
|
||||
@@ -14,7 +14,7 @@ using namespace gazebo;
|
||||
|
||||
class SimFloatInput {
|
||||
public:
|
||||
SimFloatInput(std::string topic);
|
||||
explicit SimFloatInput(std::string topic);
|
||||
|
||||
/**
|
||||
* @return The value of the potentiometer.
|
||||
|
||||
@@ -14,7 +14,7 @@ using namespace gazebo;
|
||||
|
||||
class SimGyro {
|
||||
public:
|
||||
SimGyro(std::string topic);
|
||||
explicit SimGyro(std::string topic);
|
||||
|
||||
void Reset();
|
||||
double GetAngle();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "AnalogGyro.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
#include "Timer.h"
|
||||
@@ -32,9 +32,9 @@ const float AnalogGyro::kDefaultVoltsPerDegreePerSecond = 0.007;
|
||||
void AnalogGyro::InitAnalogGyro(int channel) {
|
||||
SetPIDSourceType(PIDSourceType::kDisplacement);
|
||||
|
||||
char buffer[50];
|
||||
int n = std::sprintf(buffer, "analog/%d", channel);
|
||||
impl = new SimGyro(buffer);
|
||||
std::stringstream ss;
|
||||
ss << "analog/" << channel;
|
||||
impl = new SimGyro(ss.str());
|
||||
|
||||
LiveWindow::GetInstance()->AddSensor("AnalogGyro", channel, this);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "AnalogInput.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
#include "WPIErrors.h"
|
||||
@@ -17,11 +17,10 @@
|
||||
*
|
||||
* @param channel The channel number to represent.
|
||||
*/
|
||||
AnalogInput::AnalogInput(uint32_t channel) {
|
||||
m_channel = channel;
|
||||
char buffer[50];
|
||||
int n = std::sprintf(buffer, "analog/%d", channel);
|
||||
m_impl = new SimFloatInput(buffer);
|
||||
AnalogInput::AnalogInput(uint32_t channel) : m_channel(channel) {
|
||||
std::stringstream ss;
|
||||
ss << "analog/" << channel;
|
||||
m_impl = new SimFloatInput(ss.str());
|
||||
|
||||
LiveWindow::GetInstance()->AddSensor("AnalogInput", channel, this);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "DigitalInput.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
|
||||
#include "WPIErrors.h"
|
||||
|
||||
@@ -17,11 +17,10 @@
|
||||
*
|
||||
* @param channel The digital channel (1..14).
|
||||
*/
|
||||
DigitalInput::DigitalInput(uint32_t channel) {
|
||||
char buf[64];
|
||||
m_channel = channel;
|
||||
int n = std::sprintf(buf, "dio/%d", channel);
|
||||
m_impl = new SimDigitalInput(buf);
|
||||
DigitalInput::DigitalInput(uint32_t channel) : m_channel(channel) {
|
||||
std::stringstream ss;
|
||||
ss << "dio/" << channel;
|
||||
m_impl = new SimDigitalInput(ss.str());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,10 +35,10 @@ DoubleSolenoid::DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel,
|
||||
forwardChannel = channel;
|
||||
m_reversed = true;
|
||||
}
|
||||
char buffer[50];
|
||||
int n = std::sprintf(buffer, "pneumatic/%d/%d/%d/%d", moduleNumber,
|
||||
forwardChannel, moduleNumber, reverseChannel);
|
||||
m_impl = new SimContinuousOutput(buffer);
|
||||
std::stringstream ss;
|
||||
ss << "pneumatic/" << moduleNumber << "/" << forwardChannel << "/"
|
||||
<< moduleNumber << "/" << reverseChannel;
|
||||
m_impl = new SimContinuousOutput(ss.str());
|
||||
|
||||
LiveWindow::GetInstance()->AddActuator("DoubleSolenoid", moduleNumber,
|
||||
forwardChannel, this);
|
||||
|
||||
@@ -128,13 +128,13 @@ bool DriverStation::GetStickButton(uint32_t stick, uint32_t button) {
|
||||
* @param stick The joystick to read.
|
||||
* @return The state of the buttons on the joystick.
|
||||
*/
|
||||
short DriverStation::GetStickButtons(uint32_t stick) {
|
||||
int16_t DriverStation::GetStickButtons(uint32_t stick) {
|
||||
if (stick < 0 || stick >= 6) {
|
||||
wpi_setWPIErrorWithContext(ParameterOutOfRange,
|
||||
"stick must be between 0 and 5");
|
||||
return false;
|
||||
}
|
||||
short btns = 0, btnid;
|
||||
int16_t btns = 0, btnid;
|
||||
|
||||
std::unique_lock<std::recursive_mutex> lock(m_joystickMutex);
|
||||
msgs::FRCJoystickPtr joy = joysticks[stick];
|
||||
@@ -147,7 +147,7 @@ short DriverStation::GetStickButtons(uint32_t stick) {
|
||||
}
|
||||
|
||||
// 5V divided by 10 bits
|
||||
#define kDSAnalogInScaling ((float)(5.0 / 1023.0))
|
||||
#define kDSAnalogInScaling (static_cast<float>(5.0 / 1023.0))
|
||||
|
||||
/**
|
||||
* Get an analog voltage from the Driver Station.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "Encoder.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
#include "Resource.h"
|
||||
@@ -51,9 +51,9 @@ void Encoder::InitEncoder(int32_t channelA, int32_t channelB,
|
||||
} else {
|
||||
m_reverseDirection = reverseDirection;
|
||||
}
|
||||
char buffer[50];
|
||||
int n = std::sprintf(buffer, "dio/%d/%d", channelA, channelB);
|
||||
impl = new SimEncoder(buffer);
|
||||
std::stringstream ss;
|
||||
ss << "dio/" << channelA << "/" << channelB;
|
||||
impl = new SimEncoder(ss.str());
|
||||
impl->Start();
|
||||
}
|
||||
|
||||
|
||||
@@ -82,8 +82,9 @@ void Notifier::UpdateAlarm() {}
|
||||
*/
|
||||
void Notifier::ProcessQueue(uint32_t mask, void* params) {
|
||||
Notifier* current;
|
||||
while (true) // keep processing past events until no more
|
||||
{
|
||||
|
||||
// keep processing events until no more
|
||||
while (true) {
|
||||
{
|
||||
std::lock_guard<priority_recursive_mutex> sync(queueMutex);
|
||||
double currentTime = GetClock();
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "PWM.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "Utility.h"
|
||||
#include "WPIErrors.h"
|
||||
|
||||
@@ -26,16 +28,16 @@ const int32_t PWM::kPwmDisabled = 0;
|
||||
* port
|
||||
*/
|
||||
PWM::PWM(uint32_t channel) {
|
||||
char buf[64];
|
||||
std::stringstream ss;
|
||||
|
||||
if (!CheckPWMChannel(channel)) {
|
||||
std::snprintf(buf, 64, "PWM Channel %d", channel);
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf);
|
||||
ss << "PWM Channel " << channel;
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, ss.str());
|
||||
return;
|
||||
}
|
||||
|
||||
std::sprintf(buf, "pwm/%d", channel);
|
||||
impl = new SimContinuousOutput(buf);
|
||||
ss << "pwm/" << channel;
|
||||
impl = new SimContinuousOutput(ss.str());
|
||||
m_channel = channel;
|
||||
m_eliminateDeadband = false;
|
||||
|
||||
@@ -189,7 +191,7 @@ float PWM::GetSpeed() const {
|
||||
*
|
||||
* @param value Raw PWM value.
|
||||
*/
|
||||
void PWM::SetRaw(unsigned short value) {
|
||||
void PWM::SetRaw(uint16_t value) {
|
||||
wpi_assert(value == kPwmDisabled);
|
||||
impl->Set(0);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "Relay.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
#include "MotorSafetyHelper.h"
|
||||
#include "WPIErrors.h"
|
||||
@@ -22,21 +24,21 @@
|
||||
*/
|
||||
Relay::Relay(uint32_t channel, Relay::Direction direction)
|
||||
: m_channel(channel), m_direction(direction) {
|
||||
char buf[64];
|
||||
std::stringstream ss;
|
||||
if (!SensorBase::CheckRelayChannel(m_channel)) {
|
||||
std::snprintf(buf, 64, "Relay Channel %d", m_channel);
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf);
|
||||
ss << "Relay Channel " << m_channel;
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, ss.str());
|
||||
return;
|
||||
}
|
||||
|
||||
m_safetyHelper = std::make_unique<MotorSafetyHelper>(this);
|
||||
m_safetyHelper->SetSafetyEnabled(false);
|
||||
|
||||
std::sprintf(buf, "relay/%d", m_channel);
|
||||
impl = new SimContinuousOutput(buf); // TODO: Allow two different relays
|
||||
// (targetting the different halves of a
|
||||
// relay) to be combined to control one
|
||||
// motor.
|
||||
ss << "relay/" << m_channel;
|
||||
impl = new SimContinuousOutput(ss.str()); // TODO: Allow two different relays
|
||||
// (targetting the different halves
|
||||
// of a relay) to be combined to
|
||||
// control one motor.
|
||||
LiveWindow::GetInstance()->AddActuator("Relay", 1, m_channel, this);
|
||||
go_pos = go_neg = false;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "Solenoid.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
#include "WPIErrors.h"
|
||||
@@ -27,9 +27,9 @@ Solenoid::Solenoid(uint32_t channel) : Solenoid(1, channel) {}
|
||||
* @param channel The channel on the solenoid module to control (1..8).
|
||||
*/
|
||||
Solenoid::Solenoid(uint8_t moduleNumber, uint32_t channel) {
|
||||
char buffer[50];
|
||||
int n = std::sprintf(buffer, "pneumatic/%d/%d", moduleNumber, channel);
|
||||
m_impl = new SimContinuousOutput(buffer);
|
||||
std::stringstream ss;
|
||||
ss << "pneumatic/" << moduleNumber << "/" << channel;
|
||||
m_impl = new SimContinuousOutput(ss.str());
|
||||
|
||||
LiveWindow::GetInstance()->AddActuator("Solenoid", moduleNumber, channel,
|
||||
this);
|
||||
|
||||
@@ -24,7 +24,7 @@ void time_callback(const msgs::ConstFloat64Ptr& msg) {
|
||||
time_wait.notify_all();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace wpilib
|
||||
|
||||
/**
|
||||
* Pause the task for a specified time.
|
||||
|
||||
@@ -40,8 +40,8 @@ void wpi_suspendOnAssertEnabled(bool enabled) {
|
||||
static void wpi_handleTracing() {
|
||||
// if (stackTraceEnabled)
|
||||
// {
|
||||
// std::printf("\n-----------<Stack Trace>----------------\n");
|
||||
// printCurrentStackTrace();
|
||||
// std::printf("\n-----------<Stack Trace>----------------\n");
|
||||
// printCurrentStackTrace();
|
||||
// }
|
||||
std::printf("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user