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:
Tyler Veness
2016-07-10 17:47:44 -07:00
committed by Peter Johnson
parent e44a6e227a
commit 0cb288ffba
141 changed files with 670 additions and 626 deletions

View File

@@ -24,7 +24,7 @@ void HAL_SetDigitalPWMDutyCycle(HAL_DigitalPWMHandle pwmGenerator,
void HAL_SetDigitalPWMOutputChannel(HAL_DigitalPWMHandle pwmGenerator,
uint32_t pin, int32_t* status);
void HAL_SetDIO(HAL_DigitalHandle dio_port_handle, short value,
void HAL_SetDIO(HAL_DigitalHandle dio_port_handle, int16_t value,
int32_t* status);
bool HAL_GetDIO(HAL_DigitalHandle dio_port_handle, int32_t* status);
bool HAL_GetDIODirection(HAL_DigitalHandle dio_port_handle, int32_t* status);

View File

@@ -162,9 +162,11 @@ void HAL_CalibrateAnalogGyro(HAL_GyroHandle handle, int32_t* status) {
HAL_GetAccumulatorOutput(gyro->handle, &value, &count, status);
if (*status != 0) return;
gyro->center = (uint32_t)((float)value / (float)count + .5);
gyro->center = static_cast<uint32_t>(
static_cast<float>(value) / static_cast<float>(count) + .5);
gyro->offset = ((float)value / (float)count) - (float)gyro->center;
gyro->offset = static_cast<float>(value) / static_cast<float>(count) -
static_cast<float>(gyro->center);
HAL_SetAccumulatorCenter(gyro->handle, gyro->center, status);
if (*status != 0) return;
HAL_ResetAnalogGyro(handle, status);
@@ -194,14 +196,16 @@ float HAL_GetAnalogGyroAngle(HAL_GyroHandle handle, int32_t* status) {
uint32_t count = 0;
HAL_GetAccumulatorOutput(gyro->handle, &rawValue, &count, status);
int64_t value = rawValue - (int64_t)((float)count * gyro->offset);
int64_t value =
rawValue - static_cast<int64_t>(static_cast<float>(count) * gyro->offset);
double scaledValue =
value * 1e-9 * (double)HAL_GetAnalogLSBWeight(gyro->handle, status) *
(double)(1 << HAL_GetAnalogAverageBits(gyro->handle, status)) /
value * 1e-9 *
static_cast<double>(HAL_GetAnalogLSBWeight(gyro->handle, status)) *
static_cast<double>(1 << HAL_GetAnalogAverageBits(gyro->handle, status)) /
(HAL_GetAnalogSampleRate(status) * gyro->voltsPerDegreePerSecond);
return (float)scaledValue;
return static_cast<float>(scaledValue);
}
double HAL_GetAnalogGyroRate(HAL_GyroHandle handle, int32_t* status) {
@@ -212,7 +216,7 @@ double HAL_GetAnalogGyroRate(HAL_GyroHandle handle, int32_t* status) {
}
return (HAL_GetAnalogAverageValue(gyro->handle, status) -
((double)gyro->center + gyro->offset)) *
(static_cast<double>(gyro->center) + gyro->offset)) *
1e-9 * HAL_GetAnalogLSBWeight(gyro->handle, status) /
((1 << HAL_GetAnalogOversampleBits(gyro->handle, status)) *
gyro->voltsPerDegreePerSecond);

View File

@@ -51,8 +51,9 @@ HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(HAL_PortHandle port_handle,
analog_port->pin = static_cast<uint8_t>(pin);
if (HAL_IsAccumulatorChannel(handle, status)) {
analog_port->accumulator = tAccumulator::create(pin, status);
} else
} else {
analog_port->accumulator = nullptr;
}
// Set default configuration
analogInputSystem->writeScanList(pin, pin, status);
@@ -102,7 +103,8 @@ void HAL_SetAnalogSampleRate(double samplesPerSecond, int32_t* status) {
analogSampleRateSet = true;
// Compute the convert rate
uint32_t ticksPerSample = (uint32_t)((float)kTimebase / samplesPerSecond);
uint32_t ticksPerSample =
static_cast<uint32_t>(static_cast<float>(kTimebase) / samplesPerSecond);
uint32_t ticksPerConversion =
ticksPerSample / getAnalogNumChannelsToActivate(status);
// ticksPerConversion must be at least 80
@@ -134,7 +136,7 @@ float HAL_GetAnalogSampleRate(int32_t* status) {
uint32_t ticksPerConversion = analogInputSystem->readLoopTiming(status);
uint32_t ticksPerSample =
ticksPerConversion * getAnalogNumActiveChannels(status);
return (float)kTimebase / (float)ticksPerSample;
return static_cast<float>(kTimebase) / static_cast<float>(ticksPerSample);
}
/**
@@ -317,7 +319,7 @@ float HAL_GetAnalogAverageVoltage(HAL_AnalogInputHandle analog_port_handle,
uint32_t oversampleBits =
HAL_GetAnalogOversampleBits(analog_port_handle, status);
float voltage =
((LSBWeight * 1.0e-9 * value) / (float)(1 << oversampleBits)) -
LSBWeight * 1.0e-9 * value / static_cast<float>(1 << oversampleBits) -
offset * 1.0e-9;
return voltage;
}

View File

@@ -78,4 +78,4 @@ uint32_t getAnalogNumChannelsToActivate(int32_t* status) {
void setAnalogNumChannelsToActivate(uint32_t channels) {
analogNumChannelsToActivate = channels;
}
}
} // namespace hal

View File

@@ -16,9 +16,9 @@
#include "handles/IndexedHandleResource.h"
namespace hal {
constexpr long kTimebase = 40000000; ///< 40 MHz clock
constexpr long kDefaultOversampleBits = 0;
constexpr long kDefaultAverageBits = 7;
constexpr int32_t kTimebase = 40000000; ///< 40 MHz clock
constexpr int32_t kDefaultOversampleBits = 0;
constexpr int32_t kDefaultAverageBits = 7;
constexpr float kDefaultSampleRate = 50000.0;
static const uint32_t kAccumulatorChannels[] = {0, 1};
@@ -41,4 +41,4 @@ void setAnalogNumChannelsToActivate(uint32_t channels);
void initializeAnalog(int32_t* status);
extern bool analogSystemInitialized;
}
} // namespace hal

View File

@@ -362,7 +362,8 @@ double HAL_GetCounterPeriod(HAL_CounterHandle counter_handle, int32_t* status) {
} else {
// output.Period is a fixed point number that counts by 2 (24 bits, 25
// integer bits)
period = (double)(output.Period << 1) / (double)output.Count;
period = static_cast<double>(output.Period << 1) /
static_cast<double>(output.Count);
}
return period * 2.5e-8; // result * timebase (currently 40ns)
}

View File

@@ -70,7 +70,7 @@ HAL_DigitalHandle HAL_InitializeDIOPort(HAL_PortHandle port_handle,
uint32_t bitToSet = 1 << remapMXPChannel(port->pin);
// Disable special functions on this pin
short specialFunctions =
int16_t specialFunctions =
digitalSystem->readEnableMXPSpecialFunction(status);
digitalSystem->writeEnableMXPSpecialFunction(specialFunctions & ~bitToSet,
status);
@@ -207,7 +207,7 @@ void HAL_SetDigitalPWMOutputChannel(HAL_DigitalPWMHandle pwmGenerator,
* @param value The state to set the digital channel (if it is configured as an
* output)
*/
void HAL_SetDIO(HAL_DigitalHandle dio_port_handle, short value,
void HAL_SetDIO(HAL_DigitalHandle dio_port_handle, int16_t value,
int32_t* status) {
auto port = digitalPinHandles.Get(dio_port_handle, HAL_HandleEnum::DIO);
if (port == nullptr) {
@@ -235,7 +235,7 @@ void HAL_SetDIO(HAL_DigitalHandle dio_port_handle, short value,
}
uint32_t bitToSet = 1 << remapMXPChannel(port->pin);
short specialFunctions =
int16_t specialFunctions =
digitalSystem->readEnableMXPSpecialFunction(status);
digitalSystem->writeEnableMXPSpecialFunction(specialFunctions & ~bitToSet,
status);
@@ -268,7 +268,7 @@ bool HAL_GetDIO(HAL_DigitalHandle dio_port_handle, int32_t* status) {
} else {
// Disable special functions
uint32_t bitToSet = 1 << remapMXPChannel(port->pin);
short specialFunctions =
int16_t specialFunctions =
digitalSystem->readEnableMXPSpecialFunction(status);
digitalSystem->writeEnableMXPSpecialFunction(specialFunctions & ~bitToSet,
status);

View File

@@ -134,4 +134,4 @@ bool remapDigitalSource(HAL_Handle digitalSourceHandle,
return false;
}
}
}
} // namespace hal

View File

@@ -82,4 +82,4 @@ bool remapDigitalSource(HAL_Handle digitalSourceHandle,
uint8_t& module, bool& analogTrigger);
uint32_t remapMXPPWMChannel(uint32_t pin);
uint32_t remapMXPChannel(uint32_t pin);
}
} // namespace hal

View File

@@ -73,4 +73,4 @@ class Encoder {
int32_t m_encodingScale;
};
}
} // namespace hal

View File

@@ -148,7 +148,8 @@ double HAL_GetFPGAEncoderPeriod(HAL_FPGAEncoderHandle fpga_encoder_handle,
} else {
// output.Period is a fixed point number that counts by 2 (24 bits, 25
// integer bits)
value = (double)(output.Period << 1) / (double)output.Count;
value = static_cast<double>(output.Period << 1) /
static_cast<double>(output.Count);
}
double measuredPeriod = value * 2.5e-8;
return measuredPeriod / DECODING_SCALING_FACTOR;

View File

@@ -342,10 +342,10 @@ int HAL_Initialize(int mode) {
if (mode == 0) {
std::cout << "FRC pid " << pid
<< " did not die within 110ms. Aborting" << std::endl;
return 0; // just fail
} else if (mode == 1) // kill -9 it
return 0; // just fail
} else if (mode == 1) { // kill -9 it
kill(pid, SIGKILL);
else {
} else {
std::cout << "WARNING: FRC pid " << pid
<< " did not die within 110ms." << std::endl;
}

View File

@@ -94,9 +94,10 @@ int32_t HAL_TransactionI2C(uint8_t port, uint8_t deviceAddress,
{
std::lock_guard<priority_recursive_mutex> sync(lock);
return i2clib_writeread(handle, deviceAddress, (const char*)dataToSend,
(int32_t)sendSize, (char*)dataReceived,
(int32_t)receiveSize);
return i2clib_writeread(
handle, deviceAddress, reinterpret_cast<const char*>(dataToSend),
static_cast<int32_t>(sendSize), reinterpret_cast<char*>(dataReceived),
static_cast<int32_t>(receiveSize));
}
}
@@ -153,7 +154,8 @@ int32_t HAL_ReadI2C(uint8_t port, uint8_t deviceAddress, uint8_t* buffer,
port == 0 ? digitalI2COnBoardMutex : digitalI2CMXPMutex;
{
std::lock_guard<priority_recursive_mutex> sync(lock);
return i2clib_read(handle, deviceAddress, (char*)buffer, (int32_t)count);
return i2clib_read(handle, deviceAddress, reinterpret_cast<char*>(buffer),
static_cast<int32_t>(count));
}
}

View File

@@ -20,8 +20,8 @@
using namespace hal;
namespace {
struct Interrupt // FIXME: why is this internal?
{
// FIXME: why is this internal?
struct Interrupt {
tInterrupt* anInterrupt;
tInterruptManager* manager;
};

View File

@@ -75,7 +75,8 @@ HAL_DigitalHandle HAL_InitializePWMPort(HAL_PortHandle port_handle,
port->pin = origPin;
uint32_t bitToSet = 1 << remapMXPPWMChannel(port->pin);
short specialFunctions = digitalSystem->readEnableMXPSpecialFunction(status);
int16_t specialFunctions =
digitalSystem->readEnableMXPSpecialFunction(status);
digitalSystem->writeEnableMXPSpecialFunction(specialFunctions | bitToSet,
status);
@@ -90,7 +91,7 @@ void HAL_FreePWMPort(HAL_DigitalHandle pwm_port_handle, int32_t* status) {
if (port->pin > tPWM::kNumHdrRegisters - 1) {
uint32_t bitToUnset = 1 << remapMXPPWMChannel(port->pin);
short specialFunctions =
int16_t specialFunctions =
digitalSystem->readEnableMXPSpecialFunction(status);
digitalSystem->writeEnableMXPSpecialFunction(specialFunctions & ~bitToUnset,
status);
@@ -244,11 +245,13 @@ void HAL_SetPWMSpeed(HAL_DigitalHandle pwm_port_handle, float speed,
if (speed == 0.0) {
rawValue = GetCenterPwm(dPort);
} else if (speed > 0.0) {
rawValue = (int32_t)(speed * ((float)GetPositiveScaleFactor(dPort)) +
((float)GetMinPositivePwm(dPort)) + 0.5);
rawValue = static_cast<int32_t>(
speed * static_cast<float>(GetPositiveScaleFactor(dPort)) +
static_cast<float>(GetMinPositivePwm(dPort)) + 0.5);
} else {
rawValue = (int32_t)(speed * ((float)GetNegativeScaleFactor(dPort)) +
((float)GetMaxNegativePwm(dPort)) + 0.5);
rawValue = static_cast<int32_t>(
speed * static_cast<float>(GetNegativeScaleFactor(dPort)) +
static_cast<float>(GetMaxNegativePwm(dPort)) + 0.5);
}
if (!((rawValue >= GetMinNegativePwm(dPort)) &&
@@ -291,8 +294,9 @@ void HAL_SetPWMPosition(HAL_DigitalHandle pwm_port_handle, float pos,
// note, need to perform the multiplication below as floating point before
// converting to int
uint16_t rawValue = (int32_t)((pos * (float)GetFullRangeScaleFactor(dPort)) +
GetMinNegativePwm(dPort));
uint16_t rawValue = static_cast<int32_t>(
(pos * static_cast<float>(GetFullRangeScaleFactor(dPort))) +
GetMinNegativePwm(dPort));
if (rawValue == kPwmDisabled) {
*status = HAL_PWM_SCALE_ERROR;
@@ -354,11 +358,11 @@ float HAL_GetPWMSpeed(HAL_DigitalHandle pwm_port_handle, int32_t* status) {
} else if (value < GetMinNegativePwm(dPort)) {
return -1.0;
} else if (value > GetMinPositivePwm(dPort)) {
return (float)(value - GetMinPositivePwm(dPort)) /
(float)GetPositiveScaleFactor(dPort);
return static_cast<float>(value - GetMinPositivePwm(dPort)) /
static_cast<float>(GetPositiveScaleFactor(dPort));
} else if (value < GetMaxNegativePwm(dPort)) {
return (float)(value - GetMaxNegativePwm(dPort)) /
(float)GetNegativeScaleFactor(dPort);
return static_cast<float>(value - GetMaxNegativePwm(dPort)) /
static_cast<float>(GetNegativeScaleFactor(dPort));
} else {
return 0.0;
}
@@ -390,8 +394,8 @@ float HAL_GetPWMPosition(HAL_DigitalHandle pwm_port_handle, int32_t* status) {
} else if (value > GetMaxPositivePwm(dPort)) {
return 1.0;
} else {
return (float)(value - GetMinNegativePwm(dPort)) /
(float)GetFullRangeScaleFactor(dPort);
return static_cast<float>(value - GetMinNegativePwm(dPort)) /
static_cast<float>(GetFullRangeScaleFactor(dPort));
}
}

View File

@@ -32,4 +32,4 @@ constexpr int32_t kNumSolenoidPins = 8;
constexpr int32_t kNumPDPModules = 63;
constexpr int32_t kNumPDPChannels = 16;
constexpr int32_t kNumCanTalons = 63;
}
} // namespace hal

View File

@@ -64,7 +64,8 @@ bool HAL_GetUserActive6V(int32_t* status) {
*/
int HAL_GetUserCurrentFaults6V(int32_t* status) {
initializePower(status);
return (int)power->readFaultCounts_OverCurrentFaultCount6V(status);
return static_cast<int>(
power->readFaultCounts_OverCurrentFaultCount6V(status));
}
/**
@@ -96,7 +97,8 @@ bool HAL_GetUserActive5V(int32_t* status) {
*/
int HAL_GetUserCurrentFaults5V(int32_t* status) {
initializePower(status);
return (int)power->readFaultCounts_OverCurrentFaultCount5V(status);
return static_cast<int>(
power->readFaultCounts_OverCurrentFaultCount5V(status));
}
unsigned char HAL_GetUserStatus5V(int32_t* status) {
@@ -133,7 +135,8 @@ bool HAL_GetUserActive3V3(int32_t* status) {
*/
int HAL_GetUserCurrentFaults3V3(int32_t* status) {
initializePower(status);
return (int)power->readFaultCounts_OverCurrentFaultCount3V3(status);
return static_cast<int>(
power->readFaultCounts_OverCurrentFaultCount3V3(status));
}
} // extern "C"

View File

@@ -152,8 +152,9 @@ void HAL_InitializeSPI(uint8_t port, int32_t* status) {
int32_t HAL_TransactionSPI(uint8_t port, uint8_t* dataToSend,
uint8_t* dataReceived, uint8_t size) {
std::lock_guard<priority_recursive_mutex> sync(spiGetSemaphore(port));
return spilib_writeread(HAL_GetSPIHandle(port), (const char*)dataToSend,
(char*)dataReceived, (int32_t)size);
return spilib_writeread(
HAL_GetSPIHandle(port), reinterpret_cast<const char*>(dataToSend),
reinterpret_cast<char*>(dataReceived), static_cast<int32_t>(size));
}
/**
@@ -168,8 +169,9 @@ int32_t HAL_TransactionSPI(uint8_t port, uint8_t* dataToSend,
*/
int32_t HAL_WriteSPI(uint8_t port, uint8_t* dataToSend, uint8_t sendSize) {
std::lock_guard<priority_recursive_mutex> sync(spiGetSemaphore(port));
return spilib_write(HAL_GetSPIHandle(port), (const char*)dataToSend,
(int32_t)sendSize);
return spilib_write(HAL_GetSPIHandle(port),
reinterpret_cast<const char*>(dataToSend),
static_cast<int32_t>(sendSize));
}
/**
@@ -187,7 +189,8 @@ int32_t HAL_WriteSPI(uint8_t port, uint8_t* dataToSend, uint8_t sendSize) {
*/
int32_t HAL_ReadSPI(uint8_t port, uint8_t* buffer, uint8_t count) {
std::lock_guard<priority_recursive_mutex> sync(spiGetSemaphore(port));
return spilib_read(HAL_GetSPIHandle(port), (char*)buffer, (int32_t)count);
return spilib_read(HAL_GetSPIHandle(port), reinterpret_cast<char*>(buffer),
static_cast<int32_t>(count));
}
/**
@@ -325,13 +328,14 @@ void HAL_SetSPIHandle(uint8_t port, int32_t handle) {
}
static void spiAccumulatorProcess(uint64_t currentTime, void* param) {
SPIAccumulator* accum = (SPIAccumulator*)param;
SPIAccumulator* accum = static_cast<SPIAccumulator*>(param);
// perform SPI transaction
uint8_t resp_b[4];
std::lock_guard<priority_recursive_mutex> sync(spiGetSemaphore(accum->port));
spilib_writeread(HAL_GetSPIHandle(accum->port), (const char*)accum->cmd,
(char*)resp_b, (int32_t)accum->xfer_size);
spilib_writeread(
HAL_GetSPIHandle(accum->port), reinterpret_cast<const char*>(accum->cmd),
reinterpret_cast<char*>(resp_b), static_cast<int32_t>(accum->xfer_size));
// convert from bytes
uint32_t resp = 0;
@@ -350,7 +354,7 @@ static void spiAccumulatorProcess(uint64_t currentTime, void* param) {
// process response
if ((resp & accum->valid_mask) == accum->valid_value) {
// valid sensor data; extract data field
int32_t data = (int32_t)(resp >> accum->data_shift);
int32_t data = static_cast<int32_t>(resp >> accum->data_shift);
data &= accum->data_max - 1;
// 2s complement conversion if signed MSB is set
if (accum->is_signed && (data & accum->data_msb_mask) != 0)
@@ -553,7 +557,7 @@ double HAL_GetSPIAccumulatorAverage(uint8_t port, int32_t* status) {
uint32_t count;
HAL_GetAccumulatorOutput(port, &value, &count, status);
if (count == 0) return 0.0;
return ((double)value) / count;
return static_cast<double>(value) / count;
}
/**

View File

@@ -18,7 +18,7 @@ void HAL_InitializeSerialPort(uint8_t port, int32_t* status) {
char const* portName;
if (m_resourceManagerHandle == 0)
viOpenDefaultRM((ViSession*)&m_resourceManagerHandle);
viOpenDefaultRM(reinterpret_cast<ViSession*>(&m_resourceManagerHandle));
if (port == 0)
portName = "ASRL1::INSTR";
@@ -27,8 +27,9 @@ void HAL_InitializeSerialPort(uint8_t port, int32_t* status) {
else
portName = "ASRL3::INSTR";
*status = viOpen(m_resourceManagerHandle, const_cast<char*>(portName),
VI_NULL, VI_NULL, (ViSession*)&m_portHandle[port]);
*status =
viOpen(m_resourceManagerHandle, const_cast<char*>(portName), VI_NULL,
VI_NULL, reinterpret_cast<ViSession*>(&m_portHandle[port]));
if (*status > 0) *status = 0;
}

View File

@@ -104,4 +104,4 @@ void DigitalHandleResource<THandle, TStruct, size>::Free(
std::lock_guard<priority_mutex> sync(m_handleMutexes[index]);
m_structures[index].reset();
}
}
} // namespace hal

View File

@@ -35,4 +35,4 @@ HAL_Handle createHandle(int16_t index, HAL_HandleEnum handleType) {
handle += index;
return handle;
}
}
} // namespace hal

View File

@@ -86,4 +86,4 @@ static inline int16_t getPortHandleModule(HAL_PortHandle handle) {
HAL_PortHandle createPortHandle(uint8_t pin, uint8_t module);
HAL_Handle createHandle(int16_t index, HAL_HandleEnum handleType);
}
} // namespace hal

View File

@@ -112,4 +112,4 @@ void IndexedHandleResource<THandle, TStruct, size, enumValue>::Free(
std::lock_guard<priority_mutex> sync(m_handleMutexes[index]);
m_structures[index].reset();
}
}
} // namespace hal

View File

@@ -114,4 +114,4 @@ void LimitedClassedHandleResource<THandle, TStruct, size, enumValue>::Free(
std::lock_guard<priority_mutex> lock(m_handleMutexes[index]);
m_structures[index].reset();
}
}
} // namespace hal

View File

@@ -110,4 +110,4 @@ void LimitedHandleResource<THandle, TStruct, size, enumValue>::Free(
std::lock_guard<priority_mutex> lock(m_handleMutexes[index]);
m_structures[index].reset();
}
}
} // namespace hal

View File

@@ -84,4 +84,4 @@ void UnlimitedHandleResource<THandle, TStruct, enumValue>::Free(
if (index < 0 || index >= static_cast<int16_t>(m_structures.size())) return;
m_structures[index].reset();
}
}
} // namespace hal

View File

@@ -39,7 +39,8 @@ int HAL_GetJoystickAxes(uint8_t joystickNum, HAL_JoystickAxes* axes) {
HAL_JoystickAxesInt axesInt;
int retVal = FRC_NetworkCommunication_getJoystickAxes(
joystickNum, (JoystickAxes_t*)&axesInt, HAL_kMaxJoystickAxes);
joystickNum, reinterpret_cast<JoystickAxes_t*>(&axesInt),
HAL_kMaxJoystickAxes);
// copy int values to float values
axes->count = axesInt.count;
@@ -59,7 +60,8 @@ int HAL_GetJoystickAxes(uint8_t joystickNum, HAL_JoystickAxes* axes) {
int HAL_GetJoystickPOVs(uint8_t joystickNum, HAL_JoystickPOVs* povs) {
return FRC_NetworkCommunication_getJoystickPOVs(
joystickNum, (JoystickPOV_t*)povs, HAL_kMaxJoystickPOVs);
joystickNum, reinterpret_cast<JoystickPOV_t*>(povs),
HAL_kMaxJoystickPOVs);
}
int HAL_GetJoystickButtons(uint8_t joystickNum, HAL_JoystickButtons* buttons) {
@@ -87,8 +89,9 @@ int HAL_GetJoystickDescriptor(uint8_t joystickNum,
desc->buttonCount = 0;
desc->povCount = 0;
int retval = FRC_NetworkCommunication_getJoystickDesc(
joystickNum, &desc->isXbox, &desc->type, (char*)(&desc->name),
&desc->axisCount, (uint8_t*)&desc->axisTypes, &desc->buttonCount,
joystickNum, &desc->isXbox, &desc->type,
reinterpret_cast<char*>(&desc->name), &desc->axisCount,
reinterpret_cast<uint8_t*>(&desc->axisTypes), &desc->buttonCount,
&desc->povCount);
/* check the return, if there is an error and the RIOimage predates FRC2017,
* then axisCount needs to be cleared */
@@ -120,13 +123,14 @@ int HAL_GetJoystickType(uint8_t joystickNum) {
char* HAL_GetJoystickName(uint8_t joystickNum) {
HAL_JoystickDescriptor joystickDesc;
if (HAL_GetJoystickDescriptor(joystickNum, &joystickDesc) < 0) {
char* name = (char*)std::malloc(1);
char* name = static_cast<char*>(std::malloc(1));
name[0] = '\0';
return name;
} else {
size_t len = std::strlen(joystickDesc.name);
char* name = (char*)std::malloc(len + 1);
std::strcpy(name, joystickDesc.name);
char* name = static_cast<char*>(std::malloc(len + 1));
std::strncpy(name, joystickDesc.name, len);
name[len] = '\0';
return name;
}
}

View File

@@ -21,7 +21,7 @@ using namespace gazebo;
class ExternalLimitSwitch : public Switch {
public:
ExternalLimitSwitch(sdf::ElementPtr sdf);
explicit ExternalLimitSwitch(sdf::ElementPtr sdf);
/// \brief Returns true when the switch is triggered.
virtual bool Get();

View File

@@ -59,20 +59,20 @@ class ADXL345_I2C : public Accelerometer, public LiveWindowSendable {
ADXL345_I2C& operator=(const ADXL345_I2C&) = delete;
// Accelerometer interface
virtual void SetRange(Range range) override;
virtual double GetX() override;
virtual double GetY() override;
virtual double GetZ() override;
void SetRange(Range range) override;
double GetX() override;
double GetY() override;
double GetZ() override;
virtual double GetAcceleration(Axes axis);
virtual AllAxes GetAccelerations();
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;
virtual void StartLiveWindowMode() override {}
virtual void StopLiveWindowMode() override {}
std::string GetSmartDashboardType() const override;
void InitTable(std::shared_ptr<ITable> subtable) override;
void UpdateTable() override;
std::shared_ptr<ITable> GetTable() const override;
void StartLiveWindowMode() override {}
void StopLiveWindowMode() override {}
protected:
I2C m_i2c;

View File

@@ -54,27 +54,27 @@ class ADXL345_SPI : public Accelerometer, public LiveWindowSendable {
};
public:
ADXL345_SPI(SPI::Port port, Range range = kRange_2G);
explicit ADXL345_SPI(SPI::Port port, Range range = kRange_2G);
virtual ~ADXL345_SPI() = default;
ADXL345_SPI(const ADXL345_SPI&) = delete;
ADXL345_SPI& operator=(const ADXL345_SPI&) = delete;
// Accelerometer interface
virtual void SetRange(Range range) override;
virtual double GetX() override;
virtual double GetY() override;
virtual double GetZ() override;
void SetRange(Range range) override;
double GetX() override;
double GetY() override;
double GetZ() override;
virtual double GetAcceleration(Axes axis);
virtual AllAxes GetAccelerations();
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;
virtual void StartLiveWindowMode() override {}
virtual void StopLiveWindowMode() override {}
std::string GetSmartDashboardType() const override;
void InitTable(std::shared_ptr<ITable> subtable) override;
void UpdateTable() override;
std::shared_ptr<ITable> GetTable() const override;
void StartLiveWindowMode() override {}
void StopLiveWindowMode() override {}
protected:
SPI m_spi;

View File

@@ -32,28 +32,28 @@ class ADXL362 : public Accelerometer, public LiveWindowSendable {
};
public:
ADXL362(Range range = kRange_2G);
ADXL362(SPI::Port port, Range range = kRange_2G);
explicit ADXL362(Range range = kRange_2G);
explicit ADXL362(SPI::Port port, Range range = kRange_2G);
virtual ~ADXL362() = default;
ADXL362(const ADXL362&) = delete;
ADXL362& operator=(const ADXL362&) = delete;
// Accelerometer interface
virtual void SetRange(Range range) override;
virtual double GetX() override;
virtual double GetY() override;
virtual double GetZ() override;
void SetRange(Range range) override;
double GetX() override;
double GetY() override;
double GetZ() override;
virtual double GetAcceleration(Axes axis);
virtual AllAxes GetAccelerations();
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;
virtual void StartLiveWindowMode() override {}
virtual void StopLiveWindowMode() override {}
std::string GetSmartDashboardType() const override;
void InitTable(std::shared_ptr<ITable> subtable) override;
void UpdateTable() override;
std::shared_ptr<ITable> GetTable() const override;
void StartLiveWindowMode() override {}
void StopLiveWindowMode() override {}
private:
SPI m_spi;

View File

@@ -53,34 +53,34 @@ class AnalogPotentiometer : public Potentiometer, public LiveWindowSendable {
*
* @return The current position of the potentiometer.
*/
virtual double Get() const override;
double Get() const override;
/**
* Implement the PIDSource interface.
*
* @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:
std::shared_ptr<AnalogInput> m_analog_input;

View File

@@ -49,10 +49,10 @@ class AnalogTriggerOutput : public DigitalSource {
bool Get() const;
// DigitalSource interface
virtual HAL_Handle GetPortHandleForRouting() const override;
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
virtual bool IsAnalogTrigger() const override;
virtual uint32_t GetChannel() const override;
HAL_Handle GetPortHandleForRouting() const override;
AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
bool IsAnalogTrigger() const override;
uint32_t GetChannel() const override;
protected:
AnalogTriggerOutput(const AnalogTrigger& trigger,

View File

@@ -12,4 +12,4 @@ enum class AnalogTriggerType {
kState = 1,
kRisingPulse = 2,
kFallingPulse = 3
};
};

View File

@@ -22,21 +22,21 @@ class BuiltInAccelerometer : public Accelerometer,
public SensorBase,
public LiveWindowSendable {
public:
BuiltInAccelerometer(Range range = kRange_8G);
explicit BuiltInAccelerometer(Range range = kRange_8G);
virtual ~BuiltInAccelerometer() = default;
// Accelerometer interface
virtual void SetRange(Range range) override;
virtual double GetX() override;
virtual double GetY() override;
virtual double GetZ() override;
void SetRange(Range range) override;
double GetX() override;
double GetY() override;
double GetZ() override;
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;
virtual void StartLiveWindowMode() override {}
virtual void StopLiveWindowMode() override {}
std::string GetSmartDashboardType() const override;
void InitTable(std::shared_ptr<ITable> subtable) override;
void UpdateTable() override;
std::shared_ptr<ITable> GetTable() const override;
void StartLiveWindowMode() override {}
void StopLiveWindowMode() override {}
private:
std::shared_ptr<ITable> m_table;

View File

@@ -59,7 +59,7 @@ class CANJaguar : public MotorSafety,
uint8_t GetHardwareVersion() const;
// PIDOutput interface
virtual void PIDWrite(float output) override;
void PIDWrite(float output) override;
// Control mode methods
void EnableControl(double encoderInitialPosition = 0.0);
@@ -94,39 +94,39 @@ class CANJaguar : public MotorSafety,
void Set(float value, uint8_t syncGroup);
// CANSpeedController interface
virtual float Get() const override;
virtual void Set(float value) override;
virtual void Disable() override;
virtual void SetP(double p) override;
virtual void SetI(double i) override;
virtual void SetD(double d) override;
virtual void SetPID(double p, double i, double d) override;
virtual double GetP() const override;
virtual double GetI() const override;
virtual double GetD() const override;
virtual bool IsModePID(CANSpeedController::ControlMode mode) const override;
virtual float GetBusVoltage() const override;
virtual float GetOutputVoltage() const override;
virtual float GetOutputCurrent() const override;
virtual float GetTemperature() const override;
virtual double GetPosition() const override;
virtual double GetSpeed() const override;
virtual bool GetForwardLimitOK() const override;
virtual bool GetReverseLimitOK() const override;
virtual uint16_t GetFaults() const override;
virtual void SetVoltageRampRate(double rampRate) override;
virtual uint32_t GetFirmwareVersion() const override;
virtual void ConfigNeutralMode(NeutralMode mode) override;
virtual void ConfigEncoderCodesPerRev(uint16_t codesPerRev) override;
virtual void ConfigPotentiometerTurns(uint16_t turns) override;
virtual void ConfigSoftPositionLimits(double forwardLimitPosition,
double reverseLimitPosition) override;
virtual void DisableSoftPositionLimits() override;
virtual void ConfigLimitMode(LimitMode mode) override;
virtual void ConfigForwardLimit(double forwardLimitPosition) override;
virtual void ConfigReverseLimit(double reverseLimitPosition) override;
virtual void ConfigMaxOutputVoltage(double voltage) override;
virtual void ConfigFaultTime(float faultTime) override;
float Get() const override;
void Set(float value) override;
void Disable() override;
void SetP(double p) override;
void SetI(double i) override;
void SetD(double d) override;
void SetPID(double p, double i, double d) override;
double GetP() const override;
double GetI() const override;
double GetD() const override;
bool IsModePID(CANSpeedController::ControlMode mode) const override;
float GetBusVoltage() const override;
float GetOutputVoltage() const override;
float GetOutputCurrent() const override;
float GetTemperature() const override;
double GetPosition() const override;
double GetSpeed() const override;
bool GetForwardLimitOK() const override;
bool GetReverseLimitOK() const override;
uint16_t GetFaults() const override;
void SetVoltageRampRate(double rampRate) override;
uint32_t GetFirmwareVersion() const override;
void ConfigNeutralMode(NeutralMode mode) override;
void ConfigEncoderCodesPerRev(uint16_t codesPerRev) override;
void ConfigPotentiometerTurns(uint16_t turns) override;
void ConfigSoftPositionLimits(double forwardLimitPosition,
double reverseLimitPosition) override;
void DisableSoftPositionLimits() override;
void ConfigLimitMode(LimitMode mode) override;
void ConfigForwardLimit(double forwardLimitPosition) override;
void ConfigReverseLimit(double reverseLimitPosition) override;
void ConfigMaxOutputVoltage(double voltage) override;
void ConfigFaultTime(float faultTime) override;
virtual void SetControlMode(ControlMode mode);
virtual ControlMode GetControlMode() const;
@@ -142,8 +142,8 @@ class CANJaguar : public MotorSafety,
uint8_t GetDeviceID() const;
// SpeedController overrides
virtual void SetInverted(bool isInverted) override;
virtual bool GetInverted() const override;
void SetInverted(bool isInverted) override;
bool GetInverted() const override;
protected:
// Control mode helpers

View File

@@ -226,47 +226,47 @@ class CANTalon : public MotorSafety,
virtual ~CANTalon();
// PIDOutput interface
virtual void PIDWrite(float output) override;
void PIDWrite(float output) override;
// PIDSource interface
virtual double PIDGet() override;
double PIDGet() override;
// MotorSafety interface
virtual void SetExpiration(float timeout) override;
virtual float GetExpiration() const override;
virtual bool IsAlive() const override;
virtual void StopMotor() override;
virtual void SetSafetyEnabled(bool enabled) override;
virtual bool IsSafetyEnabled() const override;
virtual void GetDescription(std::ostringstream& desc) const override;
void SetExpiration(float timeout) override;
float GetExpiration() const override;
bool IsAlive() const override;
void StopMotor() override;
void SetSafetyEnabled(bool enabled) override;
bool IsSafetyEnabled() const override;
void GetDescription(std::ostringstream& desc) const override;
// CANSpeedController interface
virtual float Get() const override;
virtual void Set(float value) override;
virtual void Reset() override;
virtual void SetSetpoint(float value) override;
virtual void Disable() override;
float Get() const override;
void Set(float value) override;
void Reset() override;
void SetSetpoint(float value) override;
void Disable() override;
virtual void EnableControl();
virtual void Enable() override;
virtual void SetP(double p) override;
virtual void SetI(double i) override;
virtual void SetD(double d) override;
void Enable() override;
void SetP(double p) override;
void SetI(double i) override;
void SetD(double d) override;
void SetF(double f);
void SetIzone(unsigned iz);
virtual void SetPID(double p, double i, double d) override;
void SetPID(double p, double i, double d) override;
virtual void SetPID(double p, double i, double d, double f);
virtual double GetP() const override;
virtual double GetI() const override;
virtual double GetD() const override;
double GetP() const override;
double GetI() const override;
double GetD() const override;
virtual double GetF() const;
virtual bool IsModePID(CANSpeedController::ControlMode mode) const override;
virtual float GetBusVoltage() const override;
virtual float GetOutputVoltage() const override;
virtual float GetOutputCurrent() const override;
virtual float GetTemperature() const override;
bool IsModePID(CANSpeedController::ControlMode mode) const override;
float GetBusVoltage() const override;
float GetOutputVoltage() const override;
float GetOutputCurrent() const override;
float GetTemperature() const override;
void SetPosition(double pos);
virtual double GetPosition() const override;
virtual double GetSpeed() const override;
double GetPosition() const override;
double GetSpeed() const override;
virtual int GetClosedLoopError() const;
virtual void SetAllowableClosedLoopErr(uint32_t allowableCloseLoopError);
virtual int GetAnalogIn() const;
@@ -290,23 +290,23 @@ class CANTalon : public MotorSafety,
virtual int GetPulseWidthRiseToRiseUs() const;
virtual FeedbackDeviceStatus IsSensorPresent(
FeedbackDevice feedbackDevice) const;
virtual bool GetForwardLimitOK() const override;
virtual bool GetReverseLimitOK() const override;
virtual uint16_t GetFaults() const override;
bool GetForwardLimitOK() const override;
bool GetReverseLimitOK() const override;
uint16_t GetFaults() const override;
uint16_t GetStickyFaults() const;
void ClearStickyFaults();
virtual void SetVoltageRampRate(double rampRate) override;
void SetVoltageRampRate(double rampRate) override;
virtual void SetVoltageCompensationRampRate(double rampRate);
virtual uint32_t GetFirmwareVersion() const override;
virtual void ConfigNeutralMode(NeutralMode mode) override;
virtual void ConfigEncoderCodesPerRev(uint16_t codesPerRev) override;
virtual void ConfigPotentiometerTurns(uint16_t turns) override;
virtual void ConfigSoftPositionLimits(double forwardLimitPosition,
double reverseLimitPosition) override;
virtual void DisableSoftPositionLimits() override;
virtual void ConfigLimitMode(LimitMode mode) override;
virtual void ConfigForwardLimit(double forwardLimitPosition) override;
virtual void ConfigReverseLimit(double reverseLimitPosition) override;
uint32_t GetFirmwareVersion() const override;
void ConfigNeutralMode(NeutralMode mode) override;
void ConfigEncoderCodesPerRev(uint16_t codesPerRev) override;
void ConfigPotentiometerTurns(uint16_t turns) override;
void ConfigSoftPositionLimits(double forwardLimitPosition,
double reverseLimitPosition) override;
void DisableSoftPositionLimits() override;
void ConfigLimitMode(LimitMode mode) override;
void ConfigForwardLimit(double forwardLimitPosition) override;
void ConfigReverseLimit(double reverseLimitPosition) override;
void ConfigLimitSwitchOverrides(bool bForwardLimitSwitchEn,
bool bReverseLimitSwitchEn);
void ConfigForwardSoftLimitEnable(bool bForwardSoftLimitEn);
@@ -333,7 +333,7 @@ class CANTalon : public MotorSafety,
* @param normallyOpen true for normally open. false for normally closed.
*/
void ConfigRevLimitSwitchNormallyOpen(bool normallyOpen);
virtual void ConfigMaxOutputVoltage(double voltage) override;
void ConfigMaxOutputVoltage(double voltage) override;
void ConfigPeakOutputVoltage(double forwardVoltage, double reverseVoltage);
void ConfigNominalOutputVoltage(double forwardVoltage, double reverseVoltage);
/**
@@ -349,7 +349,7 @@ class CANTalon : public MotorSafety,
void ConfigSetParameter(uint32_t paramEnum, double value);
bool GetParameter(uint32_t paramEnum, double& dvalue) const;
virtual void ConfigFaultTime(float faultTime) override;
void ConfigFaultTime(float faultTime) override;
virtual void SetControlMode(ControlMode mode);
void SetFeedbackDevice(FeedbackDevice device);
void SetStatusFrameRateMs(StatusFrameRate stateFrame, int periodMs);
@@ -449,8 +449,8 @@ class CANTalon : public MotorSafety,
std::shared_ptr<ITable> GetTable() const override;
// SpeedController overrides
virtual void SetInverted(bool isInverted) override;
virtual bool GetInverted() const override;
void SetInverted(bool isInverted) override;
bool GetInverted() const override;
private:
// Values for various modes as is sent in the CAN packets for the Talon.

View File

@@ -94,7 +94,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;

View File

@@ -32,9 +32,9 @@ class DigitalInput : public DigitalSource, public LiveWindowSendable {
uint32_t GetChannel() const override;
// Digital Source Interface
virtual HAL_Handle GetPortHandleForRouting() const override;
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
virtual bool IsAnalogTrigger() const override;
HAL_Handle GetPortHandleForRouting() const override;
AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
bool IsAnalogTrigger() const override;
void UpdateTable();
void StartLiveWindowMode();

View File

@@ -36,12 +36,12 @@ class DigitalOutput : public DigitalSource,
void UpdateDutyCycle(float dutyCycle);
// Digital Source Interface
virtual HAL_Handle GetPortHandleForRouting() const override;
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
virtual bool IsAnalogTrigger() const override;
HAL_Handle GetPortHandleForRouting() const override;
AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
bool IsAnalogTrigger() const override;
virtual void ValueChanged(ITable* source, llvm::StringRef key,
std::shared_ptr<nt::Value> value, bool isNew);
void ValueChanged(ITable* source, llvm::StringRef key,
std::shared_ptr<nt::Value> value, bool isNew) override;
void UpdateTable();
void StartLiveWindowMode();
void StopLiveWindowMode();

View File

@@ -21,12 +21,12 @@ class GearTooth : public Counter {
public:
/// 55 uSec for threshold
static constexpr double kGearToothThreshold = 55e-6;
GearTooth(uint32_t channel, bool directionSensitive = false);
GearTooth(DigitalSource* source, bool directionSensitive = false);
GearTooth(std::shared_ptr<DigitalSource> source,
bool directionSensitive = false);
explicit GearTooth(uint32_t channel, bool directionSensitive = false);
explicit GearTooth(DigitalSource* source, bool directionSensitive = false);
explicit GearTooth(std::shared_ptr<DigitalSource> source,
bool directionSensitive = false);
virtual ~GearTooth() = default;
void EnableDirectionSensing(bool directionSensitive);
virtual std::string GetSmartDashboardType() const override;
std::string GetSmartDashboardType() const override;
};

View File

@@ -72,19 +72,19 @@ class Joystick : public GenericHID, public ErrorBase {
uint32_t GetAxisChannel(AxisType axis) const;
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 = 0) 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 = 0) const override;
bool GetButton(ButtonType button) const;
static Joystick* GetStickForPort(uint32_t port);

View File

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

View File

@@ -43,8 +43,8 @@ class PWM : public SensorBase,
explicit PWM(uint32_t channel);
virtual ~PWM();
virtual void SetRaw(unsigned short value);
virtual unsigned short GetRaw() const;
virtual void SetRaw(uint16_t value);
virtual uint16_t GetRaw() const;
virtual void SetPosition(float pos);
virtual float GetPosition() const;
virtual void SetSpeed(float speed);

View File

@@ -16,15 +16,15 @@
class PWMSpeedController : public SafePWM, public SpeedController {
public:
virtual ~PWMSpeedController() = default;
virtual void Set(float value) override;
virtual float Get() const override;
virtual void Disable() override;
virtual void StopMotor() override;
void Set(float value) override;
float Get() const override;
void Disable() override;
void StopMotor() override;
virtual void PIDWrite(float output) override;
void PIDWrite(float output) override;
virtual void SetInverted(bool isInverted) override;
virtual bool GetInverted() const override;
void SetInverted(bool isInverted) override;
bool GetInverted() const override;
protected:
explicit PWMSpeedController(uint32_t channel);

View File

@@ -19,7 +19,7 @@
class PowerDistributionPanel : public SensorBase, public LiveWindowSendable {
public:
PowerDistributionPanel();
PowerDistributionPanel(uint8_t module);
explicit PowerDistributionPanel(uint8_t module);
double GetVoltage() const;
double GetTemperature() const;

View File

@@ -37,7 +37,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);

View File

@@ -22,7 +22,7 @@ class DigitalInput;
class SPI : public SensorBase {
public:
enum Port { kOnboardCS0, kOnboardCS1, kOnboardCS2, kOnboardCS3, kMXP };
SPI(Port SPIport);
explicit SPI(Port SPIport);
virtual ~SPI();
SPI(const SPI&) = delete;

View File

@@ -27,8 +27,8 @@ class SolenoidBase : public SensorBase {
protected:
explicit SolenoidBase(uint8_t pcmID);
const static int m_maxModules = 63;
const static int m_maxPorts = 8;
static const int m_maxModules = 63;
static const int m_maxPorts = 8;
// static void* m_ports[m_maxModules][m_maxPorts];
uint8_t m_moduleNumber; ///< Slot number where the module is plugged into
/// the chassis.

View File

@@ -13,7 +13,7 @@
class ColorImage : public ImageBase {
public:
ColorImage(ImageType type);
explicit ColorImage(ImageType type);
virtual ~ColorImage() = default;
BinaryImage* ThresholdRGB(int redLow, int redHigh, int greenLow,
int greenHigh, int blueLow, int blueHigh);

View File

@@ -15,6 +15,6 @@
class HSLImage : public ColorImage {
public:
HSLImage();
HSLImage(const char* fileName);
explicit HSLImage(const char* fileName);
virtual ~HSLImage() = default;
};

View File

@@ -14,7 +14,7 @@
class ImageBase : public ErrorBase {
public:
ImageBase(ImageType type);
explicit ImageBase(ImageType type);
virtual ~ImageBase();
virtual void Write(const char* fileName);
int GetHeight();

View File

@@ -15,6 +15,6 @@
class RGBImage : public ColorImage {
public:
RGBImage();
RGBImage(const char* fileName);
explicit RGBImage(const char* fileName);
virtual ~RGBImage() = default;
};

View File

@@ -53,8 +53,8 @@ double ADXL345_I2C::GetZ() { return GetAcceleration(kAxis_Z); }
*/
double ADXL345_I2C::GetAcceleration(ADXL345_I2C::Axes axis) {
int16_t rawAccel = 0;
m_i2c.Read(kDataRegister + (uint8_t)axis, sizeof(rawAccel),
(uint8_t*)&rawAccel);
m_i2c.Read(kDataRegister + static_cast<uint8_t>(axis), sizeof(rawAccel),
reinterpret_cast<uint8_t*>(&rawAccel));
return rawAccel * kGsPerLSB;
}
@@ -67,7 +67,8 @@ double ADXL345_I2C::GetAcceleration(ADXL345_I2C::Axes axis) {
ADXL345_I2C::AllAxes ADXL345_I2C::GetAccelerations() {
AllAxes data = AllAxes();
int16_t rawData[3];
m_i2c.Read(kDataRegister, sizeof(rawData), (uint8_t*)rawData);
m_i2c.Read(kDataRegister, sizeof(rawData),
reinterpret_cast<uint8_t*>(rawData));
data.XAxis = rawData[0] * kGsPerLSB;
data.YAxis = rawData[1] * kGsPerLSB;

View File

@@ -133,8 +133,8 @@ void ADXRS450_Gyro::Reset() { m_spi.ResetAccumulator(); }
* integration of the returned rate from the gyro.
*/
float ADXRS450_Gyro::GetAngle() const {
return (float)(m_spi.GetAccumulatorValue() * kDegreePerSecondPerLSB *
kSamplePeriod);
return static_cast<float>(m_spi.GetAccumulatorValue() *
kDegreePerSecondPerLSB * kSamplePeriod);
}
/**
@@ -145,5 +145,6 @@ float ADXRS450_Gyro::GetAngle() const {
* @return the current rate in degrees per second
*/
double ADXRS450_Gyro::GetRate() const {
return (double)m_spi.GetAccumulatorLastValue() * kDegreePerSecondPerLSB;
return static_cast<double>(m_spi.GetAccumulatorLastValue()) *
kDegreePerSecondPerLSB;
}

View File

@@ -343,58 +343,58 @@ void CANJaguar::PIDWrite(float output) {
}
uint8_t CANJaguar::packPercentage(uint8_t* buffer, double value) {
int16_t intValue = (int16_t)(value * 32767.0);
*((int16_t*)buffer) = swap16(intValue);
int16_t intValue = static_cast<int16_t>(value * 32767.0);
*reinterpret_cast<int16_t*>(buffer) = swap16(intValue);
return sizeof(int16_t);
}
uint8_t CANJaguar::packFXP8_8(uint8_t* buffer, double value) {
int16_t intValue = (int16_t)(value * 256.0);
*((int16_t*)buffer) = swap16(intValue);
int16_t intValue = static_cast<int16_t>(value * 256.0);
*reinterpret_cast<int16_t*>(buffer) = swap16(intValue);
return sizeof(int16_t);
}
uint8_t CANJaguar::packFXP16_16(uint8_t* buffer, double value) {
int32_t intValue = (int32_t)(value * 65536.0);
*((int32_t*)buffer) = swap32(intValue);
int32_t intValue = static_cast<int32_t>(value * 65536.0);
*reinterpret_cast<int32_t*>(buffer) = swap32(intValue);
return sizeof(int32_t);
}
uint8_t CANJaguar::packint16_t(uint8_t* buffer, int16_t value) {
*((int16_t*)buffer) = swap16(value);
*reinterpret_cast<int16_t*>(buffer) = swap16(value);
return sizeof(int16_t);
}
uint8_t CANJaguar::packint32_t(uint8_t* buffer, int32_t value) {
*((int32_t*)buffer) = swap32(value);
*reinterpret_cast<int32_t*>(buffer) = swap32(value);
return sizeof(int32_t);
}
double CANJaguar::unpackPercentage(uint8_t* buffer) const {
int16_t value = *((int16_t*)buffer);
int16_t value = *reinterpret_cast<int16_t*>(buffer);
value = swap16(value);
return value / 32767.0;
}
double CANJaguar::unpackFXP8_8(uint8_t* buffer) const {
int16_t value = *((int16_t*)buffer);
int16_t value = *reinterpret_cast<int16_t*>(buffer);
value = swap16(value);
return value / 256.0;
}
double CANJaguar::unpackFXP16_16(uint8_t* buffer) const {
int32_t value = *((int32_t*)buffer);
int32_t value = *reinterpret_cast<int32_t*>(buffer);
value = swap32(value);
return value / 65536.0;
}
int16_t CANJaguar::unpackint16_t(uint8_t* buffer) const {
int16_t value = *((int16_t*)buffer);
int16_t value = *reinterpret_cast<int16_t*>(buffer);
return swap16(value);
}
int32_t CANJaguar::unpackint32_t(uint8_t* buffer) const {
int32_t value = *((int32_t*)buffer);
int32_t value = *reinterpret_cast<int32_t*>(buffer);
return swap32(value);
}
@@ -552,7 +552,7 @@ void CANJaguar::verify() {
// If the Jaguar lost power, everything should be considered unverified.
if (getMessage(LM_API_STATUS_POWER, CAN_MSGID_FULL_M, dataBuffer,
&dataSize)) {
bool powerCycled = (bool)dataBuffer[0];
bool powerCycled = static_cast<bool>(dataBuffer[0]);
if (powerCycled) {
// Clear the power cycled bit
@@ -667,13 +667,13 @@ void CANJaguar::verify() {
if (!m_pVerified) {
uint32_t message = 0;
if (m_controlMode == kSpeed)
if (m_controlMode == kSpeed) {
message = LM_API_SPD_PC;
else if (m_controlMode == kPosition)
} else if (m_controlMode == kPosition) {
message = LM_API_POS_PC;
else if (m_controlMode == kCurrent)
} else if (m_controlMode == kCurrent) {
message = LM_API_ICTRL_PC;
else {
} else {
wpi_setWPIErrorWithContext(
IncompatibleMode,
"PID constants only apply in Speed, Position, and Current mode");
@@ -697,13 +697,13 @@ void CANJaguar::verify() {
if (!m_iVerified) {
uint32_t message = 0;
if (m_controlMode == kSpeed)
if (m_controlMode == kSpeed) {
message = LM_API_SPD_IC;
else if (m_controlMode == kPosition)
} else if (m_controlMode == kPosition) {
message = LM_API_POS_IC;
else if (m_controlMode == kCurrent)
} else if (m_controlMode == kCurrent) {
message = LM_API_ICTRL_IC;
else {
} else {
wpi_setWPIErrorWithContext(
IncompatibleMode,
"PID constants only apply in Speed, Position, and Current mode");
@@ -727,13 +727,13 @@ void CANJaguar::verify() {
if (!m_dVerified) {
uint32_t message = 0;
if (m_controlMode == kSpeed)
if (m_controlMode == kSpeed) {
message = LM_API_SPD_DC;
else if (m_controlMode == kPosition)
} else if (m_controlMode == kPosition) {
message = LM_API_POS_DC;
else if (m_controlMode == kCurrent)
} else if (m_controlMode == kCurrent) {
message = LM_API_ICTRL_DC;
else {
} else {
wpi_setWPIErrorWithContext(
IncompatibleMode,
"PID constants only apply in Speed, Position, and Current mode");
@@ -807,9 +807,9 @@ void CANJaguar::verify() {
&dataSize)) {
LimitMode mode = (LimitMode)dataBuffer[0];
if (mode == m_limitMode)
if (mode == m_limitMode) {
m_limitModeVerified = true;
else {
} else {
// It's wrong - set it again
ConfigLimitMode(m_limitMode);
}
@@ -824,9 +824,9 @@ void CANJaguar::verify() {
&dataSize)) {
double limit = unpackFXP16_16(dataBuffer);
if (FXP16_EQ(limit, m_forwardLimit))
if (FXP16_EQ(limit, m_forwardLimit)) {
m_forwardLimitVerified = true;
else {
} else {
// It's wrong - set it again
ConfigForwardLimit(m_forwardLimit);
}
@@ -841,9 +841,9 @@ void CANJaguar::verify() {
&dataSize)) {
double limit = unpackFXP16_16(dataBuffer);
if (FXP16_EQ(limit, m_reverseLimit))
if (FXP16_EQ(limit, m_reverseLimit)) {
m_reverseLimitVerified = true;
else {
} else {
// It's wrong - set it again
ConfigReverseLimit(m_reverseLimit);
}
@@ -861,9 +861,9 @@ void CANJaguar::verify() {
// The returned max output voltage is sometimes slightly higher or
// lower than what was sent. This should not trigger resending
// the message.
if (std::abs(voltage - m_maxOutputVoltage) < 0.1)
if (std::abs(voltage - m_maxOutputVoltage) < 0.1) {
m_maxOutputVoltageVerified = true;
else {
} else {
// It's wrong - set it again
ConfigMaxOutputVoltage(m_maxOutputVoltage);
}
@@ -879,9 +879,9 @@ void CANJaguar::verify() {
&dataSize)) {
double rate = unpackPercentage(dataBuffer);
if (FXP16_EQ(rate, m_voltageRampRate))
if (FXP16_EQ(rate, m_voltageRampRate)) {
m_voltageRampRateVerified = true;
else {
} else {
// It's wrong - set it again
SetVoltageRampRate(m_voltageRampRate);
}
@@ -894,9 +894,9 @@ void CANJaguar::verify() {
&dataSize)) {
double rate = unpackFXP8_8(dataBuffer);
if (FXP8_EQ(rate, m_voltageRampRate))
if (FXP8_EQ(rate, m_voltageRampRate)) {
m_voltageRampRateVerified = true;
else {
} else {
// It's wrong - set it again
SetVoltageRampRate(m_voltageRampRate);
}
@@ -912,9 +912,9 @@ void CANJaguar::verify() {
&dataSize)) {
uint16_t faultTime = unpackint16_t(dataBuffer);
if ((uint16_t)(m_faultTime * 1000.0) == faultTime)
if ((uint16_t)(m_faultTime * 1000.0) == faultTime) {
m_faultTimeVerified = true;
else {
} else {
// It's wrong - set it again
ConfigFaultTime(m_faultTime);
}

View File

@@ -119,7 +119,7 @@ float CANTalon::Get() const {
case kFollower:
default:
m_impl->GetAppliedThrottle(value);
return (float)value / 1023.0;
return static_cast<float>(value) / 1023.0;
}
}
@@ -156,11 +156,11 @@ void CANTalon::Set(float value) {
status = CTR_OKAY;
} break;
case CANSpeedController::kFollower: {
status = m_impl->SetDemand((int)value);
status = m_impl->SetDemand(static_cast<int>(value));
} break;
case CANSpeedController::kVoltage: {
// Voltage is an 8.8 fixed point number.
int volts = int((m_isInverted ? -value : value) * 256);
int volts = static_cast<int>((m_isInverted ? -value : value) * 256);
status = m_impl->SetDemand(volts);
} break;
case CANSpeedController::kSpeed:
@@ -177,7 +177,7 @@ void CANTalon::Set(float value) {
status = m_impl->SetDemand(milliamperes);
} break;
case CANSpeedController::kMotionProfile: {
status = m_impl->SetDemand((int)value);
status = m_impl->SetDemand(static_cast<int>(value));
} break;
default:
wpi_setWPIErrorWithContext(
@@ -216,7 +216,7 @@ void CANTalon::Reset() {
* for more information).
*/
void CANTalon::Disable() {
m_impl->SetModeSelect((int)CANTalon::kDisabled);
m_impl->SetModeSelect(static_cast<int>(CANTalon::kDisabled));
m_controlEnabled = false;
}
@@ -358,7 +358,8 @@ void CANTalon::SetFeedbackDevice(FeedbackDevice feedbackDevice) {
*/
m_feedbackDevice = feedbackDevice;
/* pass feedback to actual CAN frame */
CTR_Code status = m_impl->SetFeedbackDeviceSelect((int)feedbackDevice);
CTR_Code status =
m_impl->SetFeedbackDeviceSelect(static_cast<int>(feedbackDevice));
if (status != CTR_OKAY) {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
}
@@ -368,7 +369,8 @@ void CANTalon::SetFeedbackDevice(FeedbackDevice feedbackDevice) {
* Select the feedback device to use in closed-loop
*/
void CANTalon::SetStatusFrameRateMs(StatusFrameRate stateFrame, int periodMs) {
CTR_Code status = m_impl->SetStatusFrameRate((int)stateFrame, periodMs);
CTR_Code status =
m_impl->SetStatusFrameRate(static_cast<int>(stateFrame), periodMs);
if (status != CTR_OKAY) {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
}
@@ -518,7 +520,7 @@ float CANTalon::GetBusVoltage() const {
float CANTalon::GetOutputVoltage() const {
int throttle11;
CTR_Code status = m_impl->GetAppliedThrottle(throttle11);
float voltage = GetBusVoltage() * (float(throttle11) / 1023.0);
float voltage = GetBusVoltage() * (static_cast<float>(throttle11) / 1023.0);
if (status != CTR_OKAY) {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
}
@@ -1086,7 +1088,8 @@ void CANTalon::SetVoltageRampRate(double rampRate) {
Talon's throttle ramp is in dThrot/d10ms. 1023 is full fwd, -1023 is
full rev. */
double rampRatedThrotPer10ms = (rampRate * 1023.0 / 12.0) / 100;
CTR_Code status = m_impl->SetRampThrottle((int)rampRatedThrotPer10ms);
CTR_Code status =
m_impl->SetRampThrottle(static_cast<int>(rampRatedThrotPer10ms));
if (status != CTR_OKAY) {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
}
@@ -1180,8 +1183,8 @@ void CANTalon::ConfigNeutralMode(NeutralMode mode) {
CTR_Code status = CTR_OKAY;
switch (mode) {
default:
case kNeutralMode_Jumper: /* use default setting in flash based on
webdash/BrakeCal button selection */
case kNeutralMode_Jumper:
// use default setting in flash based on webdash/BrakeCal button selection
status = m_impl->SetOverrideBrakeType(
CanTalonSRX::kBrakeOverride_UseDefaultsFromFlash);
break;
@@ -1347,8 +1350,9 @@ void CANTalon::ConfigLimitMode(LimitMode mode) {
}
break;
case kLimitMode_SrxDisableSwitchInputs: /** disable both limit switches and
soft limits */
case kLimitMode_SrxDisableSwitchInputs:
// disable both limit switches and soft limits
/* turn on both limits. SRX has individual enables and polarity for each
* limit switch.*/
status = m_impl->SetForwardSoftEnable(false);
@@ -1586,7 +1590,7 @@ void CANTalon::ApplyControlMode(CANSpeedController::ControlMode mode) {
break;
}
// Keep the talon disabled until Set() is called.
CTR_Code status = m_impl->SetModeSelect((int)kDisabled);
CTR_Code status = m_impl->SetModeSelect(static_cast<int>(kDisabled));
if (status != CTR_OKAY) {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
}
@@ -1647,14 +1651,13 @@ double CANTalon::GetNativeUnitsPerRotationScalar(
CTR_Code status = CTR_OKAY;
double retval = 0;
switch (devToLookup) {
case QuadEncoder: { /* When caller wants to lookup Quadrature, the QEI may
* be in 1x if the selected feedback is edge counter.
* Additionally if the quadrature source is the CTRE Mag
* encoder, then the CPR is known.
* This is nice in that the calling app does not require
* knowing the CPR at all.
* So do both checks here.
*/
case QuadEncoder: {
/* When caller wants to lookup Quadrature, the QEI may be in 1x if the
* selected feedback is edge counter. Additionally if the quadrature
* source is the CTRE Mag encoder, then the CPR is known. This is nice in
* that the calling app does not require knowing the CPR at all. So do
* both checks here.
*/
int32_t qeiPulsePerCount = 4; /* default to 4x */
switch (m_feedbackDevice) {
case CtreMagEncoder_Relative:
@@ -1669,8 +1672,8 @@ double CANTalon::GetNativeUnitsPerRotationScalar(
qeiPulsePerCount = 1;
break;
case QuadEncoder: /* Talon's QEI is 4x */
default: /* pulse width and everything else, assume its regular quad
use. */
default:
// pulse width and everything else, assume its regular quad use.
break;
}
if (scalingAvail) {
@@ -1710,7 +1713,8 @@ double CANTalon::GetNativeUnitsPerRotationScalar(
* bottom of this func.
*/
} else {
retval = (double)kNativeAdcUnitsPerRotation / m_numPotTurns;
retval =
static_cast<double>(kNativeAdcUnitsPerRotation) / m_numPotTurns;
scalingAvail = true;
}
break;
@@ -1746,11 +1750,11 @@ double CANTalon::GetNativeUnitsPerRotationScalar(
int32_t CANTalon::ScaleRotationsToNativeUnits(FeedbackDevice devToLookup,
double fullRotations) const {
/* first assume we don't have config info, prep the default return */
int32_t retval = (int32_t)fullRotations;
int32_t retval = static_cast<int32_t>(fullRotations);
/* retrieve scaling info */
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
/* apply scalar if its available */
if (scalar > 0) retval = (int32_t)(fullRotations * scalar);
if (scalar > 0) retval = static_cast<int32_t>(fullRotations * scalar);
return retval;
}
@@ -1768,11 +1772,13 @@ int32_t CANTalon::ScaleRotationsToNativeUnits(FeedbackDevice devToLookup,
int32_t CANTalon::ScaleVelocityToNativeUnits(FeedbackDevice devToLookup,
double rpm) const {
/* first assume we don't have config info, prep the default return */
int32_t retval = (int32_t)rpm;
int32_t retval = static_cast<int32_t>(rpm);
/* retrieve scaling info */
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
/* apply scalar if its available */
if (scalar > 0) retval = (int32_t)(rpm * kMinutesPer100msUnit * scalar);
if (scalar > 0) {
retval = static_cast<int32_t>(rpm * kMinutesPer100msUnit * scalar);
}
return retval;
}
@@ -1789,11 +1795,11 @@ int32_t CANTalon::ScaleVelocityToNativeUnits(FeedbackDevice devToLookup,
double CANTalon::ScaleNativeUnitsToRotations(FeedbackDevice devToLookup,
int32_t nativePos) const {
/* first assume we don't have config info, prep the default return */
double retval = (double)nativePos;
double retval = static_cast<double>(nativePos);
/* retrieve scaling info */
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
/* apply scalar if its available */
if (scalar > 0) retval = ((double)nativePos) / scalar;
if (scalar > 0) retval = static_cast<double>(nativePos) / scalar;
return retval;
}
@@ -1810,12 +1816,12 @@ double CANTalon::ScaleNativeUnitsToRotations(FeedbackDevice devToLookup,
double CANTalon::ScaleNativeUnitsToRpm(FeedbackDevice devToLookup,
int32_t nativeVel) const {
/* first assume we don't have config info, prep the default return */
double retval = (double)nativeVel;
double retval = static_cast<double>(nativeVel);
/* retrieve scaling info */
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
/* apply scalar if its available */
if (scalar > 0)
retval = (double)(nativeVel) / (scalar * kMinutesPer100msUnit);
retval = static_cast<double>(nativeVel) / (scalar * kMinutesPer100msUnit);
return retval;
}

View File

@@ -41,9 +41,9 @@ CameraServer::CameraServer()
void CameraServer::FreeImageData(
std::tuple<uint8_t*, unsigned int, unsigned int, bool> imageData) {
if (std::get<3>(imageData))
if (std::get<3>(imageData)) {
imaqDispose(std::get<0>(imageData));
else if (std::get<0>(imageData) != nullptr) {
} else if (std::get<0>(imageData) != nullptr) {
std::lock_guard<priority_recursive_mutex> lock(m_imageMutex);
m_dataPool.push_back(std::get<0>(imageData));
}
@@ -59,9 +59,9 @@ void CameraServer::SetImageData(uint8_t* data, unsigned int size,
void CameraServer::SetImage(Image const* image) {
unsigned int dataSize = 0;
uint8_t* data =
(uint8_t*)imaqFlatten(image, IMAQ_FLATTEN_IMAGE, IMAQ_COMPRESSION_JPEG,
10 * m_quality, &dataSize);
uint8_t* data = reinterpret_cast<uint8_t*>(
imaqFlatten(image, IMAQ_FLATTEN_IMAGE, IMAQ_COMPRESSION_JPEG,
10 * m_quality, &dataSize));
// If we're using a HW camera, then find the start of the data
bool hwClient;

View File

@@ -210,7 +210,7 @@ int DriverStation::GetJoystickType(uint32_t stick) const {
return -1;
}
std::lock_guard<priority_mutex> lock(m_joystickDataMutex);
return (int)m_joystickDescriptor[stick].type;
return static_cast<int>(m_joystickDescriptor[stick].type);
}
/**
@@ -225,7 +225,7 @@ bool DriverStation::GetJoystickIsXbox(uint32_t stick) const {
return false;
}
std::lock_guard<priority_mutex> lock(m_joystickDataMutex);
return (bool)m_joystickDescriptor[stick].isXbox;
return static_cast<bool>(m_joystickDescriptor[stick].isXbox);
}
/**

View File

@@ -214,7 +214,6 @@ void Encoder::Reset() {
int32_t status = 0;
HAL_ResetEncoder(m_encoder, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
;
}
/**

View File

@@ -582,9 +582,9 @@ std::string PIDController::GetSmartDashboardType() const {
return "PIDController";
}
void PIDController::InitTable(std::shared_ptr<ITable> table) {
void PIDController::InitTable(std::shared_ptr<ITable> subtable) {
if (m_table != nullptr) m_table->RemoveTableListener(this);
m_table = table;
m_table = subtable;
if (m_table != nullptr) {
m_table->PutNumber(kP, GetP());
m_table->PutNumber(kI, GetI());

View File

@@ -231,7 +231,7 @@ float PWM::GetSpeed() const {
*
* @param value Raw PWM value.
*/
void PWM::SetRaw(unsigned short value) {
void PWM::SetRaw(uint16_t value) {
if (StatusIsFatal()) return;
int32_t status = 0;
@@ -246,11 +246,11 @@ void PWM::SetRaw(unsigned short value) {
*
* @return Raw PWM control value.
*/
unsigned short PWM::GetRaw() const {
uint16_t PWM::GetRaw() const {
if (StatusIsFatal()) return 0;
int32_t status = 0;
unsigned short value = HAL_GetPWMRaw(m_handle, &status);
uint16_t value = HAL_GetPWMRaw(m_handle, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return value;

View File

@@ -49,8 +49,9 @@ void SPI::SetClockRate(double hz) { HAL_SetSPISpeed(m_port, hz); }
*/
void SPI::SetMSBFirst() {
m_msbFirst = true;
HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
(int)m_clk_idle_high);
HAL_SetSPIOpts(m_port, static_cast<int>(m_msbFirst),
static_cast<int>(m_sampleOnTrailing),
static_cast<int>(m_clk_idle_high));
}
/**
@@ -59,8 +60,9 @@ void SPI::SetMSBFirst() {
*/
void SPI::SetLSBFirst() {
m_msbFirst = false;
HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
(int)m_clk_idle_high);
HAL_SetSPIOpts(m_port, static_cast<int>(m_msbFirst),
static_cast<int>(m_sampleOnTrailing),
static_cast<int>(m_clk_idle_high));
}
/**
@@ -69,8 +71,9 @@ void SPI::SetLSBFirst() {
*/
void SPI::SetSampleDataOnFalling() {
m_sampleOnTrailing = true;
HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
(int)m_clk_idle_high);
HAL_SetSPIOpts(m_port, static_cast<int>(m_msbFirst),
static_cast<int>(m_sampleOnTrailing),
static_cast<int>(m_clk_idle_high));
}
/**
@@ -79,8 +82,9 @@ void SPI::SetSampleDataOnFalling() {
*/
void SPI::SetSampleDataOnRising() {
m_sampleOnTrailing = false;
HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
(int)m_clk_idle_high);
HAL_SetSPIOpts(m_port, static_cast<int>(m_msbFirst),
static_cast<int>(m_sampleOnTrailing),
static_cast<int>(m_clk_idle_high));
}
/**
@@ -89,8 +93,9 @@ void SPI::SetSampleDataOnRising() {
*/
void SPI::SetClockActiveLow() {
m_clk_idle_high = true;
HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
(int)m_clk_idle_high);
HAL_SetSPIOpts(m_port, static_cast<int>(m_msbFirst),
static_cast<int>(m_sampleOnTrailing),
static_cast<int>(m_clk_idle_high));
}
/**
@@ -99,8 +104,9 @@ void SPI::SetClockActiveLow() {
*/
void SPI::SetClockActiveHigh() {
m_clk_idle_high = false;
HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
(int)m_clk_idle_high);
HAL_SetSPIOpts(m_port, static_cast<int>(m_msbFirst),
static_cast<int>(m_sampleOnTrailing),
static_cast<int>(m_clk_idle_high));
}
/**
@@ -153,8 +159,9 @@ int32_t SPI::Read(bool initiate, uint8_t* dataReceived, uint8_t size) {
auto dataToSend = new uint8_t[size];
std::memset(dataToSend, 0, size);
retVal = HAL_TransactionSPI(m_port, dataToSend, dataReceived, size);
} else
} else {
retVal = HAL_ReadSPI(m_port, dataReceived, size);
}
return retVal;
}
@@ -192,9 +199,9 @@ void SPI::InitAccumulator(double period, uint32_t cmd, uint8_t xfer_size,
uint8_t data_shift, uint8_t data_size, bool is_signed,
bool big_endian) {
int32_t status = 0;
HAL_InitSPIAccumulator(m_port, (uint32_t)(period * 1e6), cmd, xfer_size,
valid_mask, valid_value, data_shift, data_size,
is_signed, big_endian, &status);
HAL_InitSPIAccumulator(m_port, static_cast<uint32_t>(period * 1e6), cmd,
xfer_size, valid_mask, valid_value, data_shift,
data_size, is_signed, big_endian, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
}

View File

@@ -83,7 +83,8 @@ void Servo::SetAngle(float degrees) {
degrees = kMaxServoAngle;
}
SetPosition(((float)(degrees - kMinServoAngle)) / GetServoAngleRange());
SetPosition(static_cast<float>(degrees - kMinServoAngle) /
GetServoAngleRange());
}
/**
@@ -95,7 +96,8 @@ void Servo::SetAngle(float degrees) {
* @return The angle in degrees to which the servo is set.
*/
float Servo::GetAngle() const {
return (float)GetPosition() * GetServoAngleRange() + kMinServoAngle;
return static_cast<float>(GetPosition()) * GetServoAngleRange() +
kMinServoAngle;
}
void Servo::ValueChanged(ITable* source, llvm::StringRef key,

View File

@@ -34,7 +34,7 @@
* the SOS flag explanation.
*/
unsigned int USBCamera::GetJpegSize(void* buffer, unsigned int buffSize) {
uint8_t* data = (uint8_t*)buffer;
uint8_t* data = static_cast<uint8_t*>(buffer);
if (!wpi_assert(data[0] == 0xff && data[1] == 0xd8)) return 0;
unsigned int pos = 2;
while (pos < buffSize) {
@@ -201,7 +201,8 @@ void USBCamera::UpdateSettings() {
IMAQdxValueTypeF64, &minv);
SAFE_IMAQ_CALL(IMAQdxGetAttributeMaximum, m_id, ATTR_EX_VALUE,
IMAQdxValueTypeF64, &maxv);
double val = minv + ((maxv - minv) * ((double)m_exposureValue / 100.0));
double val =
minv + (maxv - minv) * (static_cast<double>(m_exposureValue) / 100.0);
SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_EX_VALUE,
IMAQdxValueTypeF64, val);
}
@@ -215,7 +216,8 @@ void USBCamera::UpdateSettings() {
IMAQdxValueTypeF64, &minv);
SAFE_IMAQ_CALL(IMAQdxGetAttributeMaximum, m_id, ATTR_BR_VALUE,
IMAQdxValueTypeF64, &maxv);
double val = minv + ((maxv - minv) * ((double)m_brightness / 100.0));
double val =
minv + (maxv - minv) * (static_cast<double>(m_brightness) / 100.0);
SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_BR_VALUE, IMAQdxValueTypeF64,
val);

View File

@@ -133,9 +133,8 @@ int AxisCamera::CopyJPEG(char** destImage, unsigned int& destImageSize,
if (m_imageData.size() == 0) return 0; // if no source image
if (destImageBufferSize <
m_imageData.size()) // if current destination buffer too small
{
// if current destination buffer too small
if (destImageBufferSize < m_imageData.size()) {
if (*destImage != nullptr) delete[] * destImage;
destImageBufferSize = m_imageData.size() + kImageBufferAllocationIncrement;
*destImage = new char[destImageBufferSize];
@@ -148,7 +147,7 @@ int AxisCamera::CopyJPEG(char** destImage, unsigned int& destImageSize,
std::copy(m_imageData.begin(), m_imageData.end(), *destImage);
destImageSize = m_imageData.size();
;
return 1;
}

View File

@@ -45,8 +45,7 @@ void SetDebugFlag(DebugOutputType flag) { dprintfFlag = flag; }
*
* @param tempString The format string.
*/
void dprintf(const char* tempString, ...) /* Variable argument list */
{
void dprintf(const char* tempString, ...) {
va_list args; /* Input argument list */
int line_number; /* Line number passed in argument */
int type;
@@ -166,7 +165,7 @@ void dprintf(const char* tempString, ...) /* Variable argument list */
* @return The normalized position from -1 to +1
*/
double RangeToNormalized(double position, int range) {
return (((position * 2.0) / (double)range) - 1.0);
return position * 2.0 / static_cast<double>(range) - 1.0;
}
/**
@@ -179,11 +178,11 @@ double RangeToNormalized(double position, int range) {
*/
float NormalizeToRange(float normalizedValue, float minRange, float maxRange) {
float range = maxRange - minRange;
float temp = (float)((normalizedValue / 2.0) + 0.5) * range;
float temp = static_cast<float>(normalizedValue / 2.0 + 0.5) * range;
return (temp + minRange);
}
float NormalizeToRange(float normalizedValue) {
return (float)((normalizedValue / 2.0) + 0.5);
return static_cast<float>(normalizedValue / 2.0 + 0.5);
}
/**
@@ -274,7 +273,8 @@ void panInit(double period) {
void panForTarget(Servo* panServo) { panForTarget(panServo, 0.0); }
void panForTarget(Servo* panServo, double sinStart) {
float normalizedSinPosition = (float)SinPosition(nullptr, sinStart);
float normalizedSinPosition =
static_cast<float>(SinPosition(nullptr, sinStart));
float newServoPosition = NormalizeToRange(normalizedSinPosition);
panServo->Set(newServoPosition);
// ShowActivity ("pan x: normalized %f newServoPosition = %f" ,
@@ -295,8 +295,8 @@ void panForTarget(Servo* panServo, double sinStart) {
**/
int processFile(char* inputFile, char* outputString, int lineNumber) {
FILE* infile;
const int stringSize = 80; // max size of one line in file
char inputStr[stringSize];
const int kStringSize = 80; // max size of one line in file
char inputStr[kStringSize];
inputStr[0] = '\0';
int lineCount = 0;
@@ -308,16 +308,16 @@ int processFile(char* inputFile, char* outputString, int lineNumber) {
}
while (!std::feof(infile)) {
if (std::fgets(inputStr, stringSize, infile) != nullptr) {
if (std::fgets(inputStr, kStringSize, infile) != nullptr) {
// Skip empty lines
if (emptyString(inputStr)) continue;
// Skip comment lines
if (inputStr[0] == '#' || inputStr[0] == '!') continue;
lineCount++;
if (lineNumber == 0)
if (lineNumber == 0) {
continue;
else {
} else {
if (lineCount == lineNumber) break;
}
}

View File

@@ -157,7 +157,7 @@ bool BinaryImage::ParticleMeasurement(int particleNumber,
double resultDouble;
bool success =
ParticleMeasurement(particleNumber, whatToMeasure, &resultDouble);
*result = (int)resultDouble;
*result = static_cast<int>(resultDouble);
return success;
}
@@ -184,7 +184,7 @@ bool BinaryImage::ParticleMeasurement(int particleNumber,
// Normalizes to [-1,1]
double BinaryImage::NormalizeFromRange(double position, int range) {
return (position * 2.0 / (double)range) - 1.0;
return position * 2.0 / static_cast<double>(range) - 1.0;
}
/**

View File

@@ -57,8 +57,7 @@ int frcDispose(void* object) { return imaqDispose(object); }
* @return On success: 1. On failure: 0. To get extended error information, call
* GetLastError().
*/
int frcDispose(const char* functionName, ...) /* Variable argument list */
{
int frcDispose(const char* functionName, ...) {
va_list disposalPtrList; /* Input argument list */
void* disposalPtr; /* For iteration */
int success, returnValue = 1;
@@ -281,7 +280,9 @@ ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses,
ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses,
ColorMode mode, Image* mask) {
return imaqColorHistogram2((Image*)image, numClasses, mode, nullptr, mask);
return imaqColorHistogram2(
const_cast<Image*>(reinterpret_cast<const Image*>(image)), numClasses,
mode, nullptr, mask);
}
/**
@@ -451,14 +452,14 @@ int frcParticleAnalysis(Image* image, int particleNumber,
if (!success) {
return success;
}
par->center_mass_x = (int)returnDouble; // pixel
par->center_mass_x = static_cast<int>(returnDouble); // pixel
success = imaqMeasureParticle(image, particleNumber, 0,
IMAQ_MT_CENTER_OF_MASS_Y, &returnDouble);
if (!success) {
return success;
}
par->center_mass_y = (int)returnDouble; // pixel
par->center_mass_y = static_cast<int>(returnDouble); // pixel
/* particle size statistics */
success = imaqMeasureParticle(image, particleNumber, 0, IMAQ_MT_AREA,
@@ -473,28 +474,28 @@ int frcParticleAnalysis(Image* image, int particleNumber,
if (!success) {
return success;
}
par->boundingRect.top = (int)returnDouble;
par->boundingRect.top = static_cast<int>(returnDouble);
success = imaqMeasureParticle(image, particleNumber, 0,
IMAQ_MT_BOUNDING_RECT_LEFT, &returnDouble);
if (!success) {
return success;
}
par->boundingRect.left = (int)returnDouble;
par->boundingRect.left = static_cast<int>(returnDouble);
success = imaqMeasureParticle(image, particleNumber, 0,
IMAQ_MT_BOUNDING_RECT_HEIGHT, &returnDouble);
if (!success) {
return success;
}
par->boundingRect.height = (int)returnDouble;
par->boundingRect.height = static_cast<int>(returnDouble);
success = imaqMeasureParticle(image, particleNumber, 0,
IMAQ_MT_BOUNDING_RECT_WIDTH, &returnDouble);
if (!success) {
return success;
}
par->boundingRect.width = (int)returnDouble;
par->boundingRect.width = static_cast<int>(returnDouble);
/* particle quality statistics */
success = imaqMeasureParticle(image, particleNumber, 0,

View File

@@ -12,7 +12,7 @@
class InternalButton : public Button {
public:
InternalButton() = default;
InternalButton(bool inverted);
explicit InternalButton(bool inverted);
virtual ~InternalButton() = default;
void SetInverted(bool inverted);

View File

@@ -39,9 +39,9 @@ class Trigger : public Sendable {
void CancelWhenActive(Command* command);
void ToggleWhenActive(Command* command);
virtual void InitTable(std::shared_ptr<ITable> table);
virtual std::shared_ptr<ITable> GetTable() const;
virtual std::string GetSmartDashboardType() const;
void InitTable(std::shared_ptr<ITable> subtable) override;
std::shared_ptr<ITable> GetTable() const override;
std::string GetSmartDashboardType() const override;
protected:
std::shared_ptr<ITable> m_table;

View File

@@ -18,7 +18,7 @@
template <class T>
class CircularBuffer {
public:
CircularBuffer(size_t size);
explicit CircularBuffer(size_t size);
void PushFront(T value);
void PushBack(T value);

View File

@@ -52,8 +52,8 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
public:
Command();
Command(const std::string& name);
Command(double timeout);
explicit Command(const std::string& name);
explicit Command(double timeout);
Command(const std::string& name, double timeout);
virtual ~Command();
double TimeSinceInitialized() const;
@@ -167,12 +167,12 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
static int m_commandCounter;
public:
virtual std::string GetName() const;
virtual void InitTable(std::shared_ptr<ITable> table);
virtual std::shared_ptr<ITable> GetTable() const;
virtual std::string GetSmartDashboardType() const;
virtual void ValueChanged(ITable* source, llvm::StringRef key,
std::shared_ptr<nt::Value> value, bool isNew);
std::string GetName() const override;
void InitTable(std::shared_ptr<ITable> subtable) override;
std::shared_ptr<ITable> GetTable() const override;
std::string GetSmartDashboardType() const override;
void ValueChanged(ITable* source, llvm::StringRef key,
std::shared_ptr<nt::Value> value, bool isNew) override;
protected:
std::shared_ptr<ITable> m_table;

View File

@@ -35,7 +35,7 @@
class CommandGroup : public Command {
public:
CommandGroup() = default;
CommandGroup(const std::string& name);
explicit CommandGroup(const std::string& name);
virtual ~CommandGroup() = default;
void AddSequential(Command* command);

View File

@@ -51,6 +51,6 @@ class PIDCommand : public Command, public PIDOutput, public PIDSource {
std::shared_ptr<PIDController> m_controller;
public:
virtual void InitTable(std::shared_ptr<ITable> table);
virtual std::string GetSmartDashboardType() const;
void InitTable(std::shared_ptr<ITable> subtable) override;
std::string GetSmartDashboardType() const override;
};

View File

@@ -66,6 +66,6 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
std::shared_ptr<PIDController> m_controller;
public:
virtual void InitTable(std::shared_ptr<ITable> table);
virtual std::string GetSmartDashboardType() const;
void InitTable(std::shared_ptr<ITable> subtable) override;
std::string GetSmartDashboardType() const override;
};

View File

@@ -12,7 +12,7 @@
class PrintCommand : public Command {
public:
PrintCommand(const std::string& message);
explicit PrintCommand(const std::string& message);
virtual ~PrintCommand() = default;
protected:

View File

@@ -11,7 +11,7 @@
class StartCommand : public Command {
public:
StartCommand(Command* commandToStart);
explicit StartCommand(Command* commandToStart);
virtual ~StartCommand() = default;
protected:

View File

@@ -18,7 +18,7 @@ class Subsystem : public ErrorBase, public NamedSendable {
friend class Scheduler;
public:
Subsystem(const std::string& name);
explicit Subsystem(const std::string& name);
virtual ~Subsystem() = default;
void SetDefaultCommand(Command* command);
@@ -37,10 +37,10 @@ class Subsystem : public ErrorBase, public NamedSendable {
bool m_initializedDefaultCommand = false;
public:
virtual std::string GetName() const;
virtual void InitTable(std::shared_ptr<ITable> table);
virtual std::shared_ptr<ITable> GetTable() const;
virtual std::string GetSmartDashboardType() const;
std::string GetName() const override;
void InitTable(std::shared_ptr<ITable> subtable) override;
std::shared_ptr<ITable> GetTable() const override;
std::string GetSmartDashboardType() const override;
protected:
std::shared_ptr<ITable> m_table;

View File

@@ -11,7 +11,7 @@
class WaitCommand : public Command {
public:
WaitCommand(double timeout);
explicit WaitCommand(double timeout);
WaitCommand(const std::string& name, double timeout);
virtual ~WaitCommand() = default;

View File

@@ -11,7 +11,7 @@
class WaitForChildren : public Command {
public:
WaitForChildren(double timeout);
explicit WaitForChildren(double timeout);
WaitForChildren(const std::string& name, double timeout);
virtual ~WaitForChildren() = default;

View File

@@ -11,7 +11,7 @@
class WaitUntilCommand : public Command {
public:
WaitUntilCommand(double time);
explicit WaitUntilCommand(double time);
WaitUntilCommand(const std::string& name, double time);
virtual ~WaitUntilCommand() = default;

View File

@@ -15,13 +15,13 @@
*/
class Filter : public PIDSource {
public:
Filter(std::shared_ptr<PIDSource> source);
explicit Filter(std::shared_ptr<PIDSource> source);
virtual ~Filter() = default;
// PIDSource interface
virtual void SetPIDSourceType(PIDSourceType pidSource) override;
void SetPIDSourceType(PIDSourceType pidSource) override;
PIDSourceType GetPIDSourceType() const;
virtual double PIDGet() override = 0;
double PIDGet() override = 0;
/**
* Returns the current filter estimate without also inserting new data as

View File

@@ -50,15 +50,15 @@ class PIDController : public LiveWindowSendable,
virtual void SetContinuous(bool continuous = true);
virtual void SetInputRange(float minimumInput, float maximumInput);
virtual void SetOutputRange(float minimumOutput, float maximumOutput);
virtual void SetPID(double p, double i, double d) override;
void SetPID(double p, double i, double d) override;
virtual void SetPID(double p, double i, double d, double f);
virtual double GetP() const override;
virtual double GetI() const override;
virtual double GetD() const override;
double GetP() const override;
double GetI() const override;
double GetD() const override;
virtual double GetF() const;
virtual void SetSetpoint(float setpoint) override;
virtual double GetSetpoint() const override;
void SetSetpoint(float setpoint) override;
double GetSetpoint() const override;
double GetDeltaSetpoint() const;
virtual float GetError() const;
@@ -73,13 +73,13 @@ class PIDController : public LiveWindowSendable,
virtual void SetToleranceBuffer(unsigned buf = 1);
virtual bool OnTarget() const;
virtual void Enable() override;
virtual void Disable() override;
virtual bool IsEnabled() const override;
void Enable() override;
void Disable() override;
bool IsEnabled() const override;
virtual void Reset() override;
void Reset() override;
virtual void InitTable(std::shared_ptr<ITable> table) override;
void InitTable(std::shared_ptr<ITable> subtable) override;
protected:
PIDSource* m_pidInput;
@@ -141,12 +141,11 @@ class PIDController : public LiveWindowSendable,
void Initialize(float p, float i, float d, float f, PIDSource* source,
PIDOutput* output, float period = 0.05);
virtual std::shared_ptr<ITable> GetTable() const override;
virtual std::string GetSmartDashboardType() const override;
virtual void ValueChanged(ITable* source, llvm::StringRef key,
std::shared_ptr<nt::Value> value,
bool isNew) override;
virtual void UpdateTable() override;
virtual void StartLiveWindowMode() override;
virtual void StopLiveWindowMode() override;
std::shared_ptr<ITable> GetTable() const override;
std::string GetSmartDashboardType() const override;
void ValueChanged(ITable* source, llvm::StringRef key,
std::shared_ptr<nt::Value> value, bool isNew) override;
void UpdateTable() override;
void StartLiveWindowMode() override;
void StopLiveWindowMode() override;
};

View File

@@ -34,9 +34,9 @@ class SendableChooser : public Sendable {
void AddDefault(const std::string& name, void* object);
void* GetSelected();
virtual void InitTable(std::shared_ptr<ITable> subtable);
virtual std::shared_ptr<ITable> GetTable() const;
virtual std::string GetSmartDashboardType() const;
void InitTable(std::shared_ptr<ITable> subtable) override;
std::shared_ptr<ITable> GetTable() const override;
std::string GetSmartDashboardType() const override;
private:
std::string m_defaultChoice;

View File

@@ -23,5 +23,5 @@ class Potentiometer : public PIDSource {
*/
virtual double Get() const = 0;
virtual void SetPIDSourceType(PIDSourceType pidSource) override;
void SetPIDSourceType(PIDSourceType pidSource) override;
};

View File

@@ -14,15 +14,13 @@
#include "Buttons/ToggleButtonScheduler.h"
bool Trigger::Grab() {
if (Get())
if (Get()) {
return true;
else if (m_table != nullptr) {
// if (m_table->isConnected())//TODO is connected on button?
} else if (m_table != nullptr) {
return m_table->GetBoolean("pressed", false);
/*else
return false;*/
} else
} else {
return false;
}
}
void Trigger::WhenActive(Command* command) {
@@ -52,8 +50,8 @@ void Trigger::ToggleWhenActive(Command* command) {
std::string Trigger::GetSmartDashboardType() const { return "Button"; }
void Trigger::InitTable(std::shared_ptr<ITable> table) {
m_table = table;
void Trigger::InitTable(std::shared_ptr<ITable> subtable) {
m_table = subtable;
if (m_table != nullptr) {
m_table->PutBoolean("pressed", Get());
}

View File

@@ -392,9 +392,9 @@ std::string Command::GetName() const { return m_name; }
std::string Command::GetSmartDashboardType() const { return "Command"; }
void Command::InitTable(std::shared_ptr<ITable> table) {
void Command::InitTable(std::shared_ptr<ITable> subtable) {
if (m_table != nullptr) m_table->RemoveTableListener(this);
m_table = table;
m_table = subtable;
if (m_table != nullptr) {
m_table->PutString(kName, GetName());
m_table->PutBoolean(kRunning, IsRunning());

View File

@@ -66,7 +66,8 @@ double PIDCommand::GetSetpoint() const { return m_controller->GetSetpoint(); }
double PIDCommand::GetPosition() { return ReturnPIDInput(); }
std::string PIDCommand::GetSmartDashboardType() const { return "PIDCommand"; }
void PIDCommand::InitTable(std::shared_ptr<ITable> table) {
m_controller->InitTable(table);
Command::InitTable(table);
void PIDCommand::InitTable(std::shared_ptr<ITable> subtable) {
m_controller->InitTable(subtable);
Command::InitTable(subtable);
}

View File

@@ -239,7 +239,8 @@ void PIDSubsystem::PIDWrite(float output) { UsePIDOutput(output); }
double PIDSubsystem::PIDGet() { return ReturnPIDInput(); }
std::string PIDSubsystem::GetSmartDashboardType() const { return "PIDCommand"; }
void PIDSubsystem::InitTable(std::shared_ptr<ITable> table) {
m_controller->InitTable(table);
Subsystem::InitTable(table);
void PIDSubsystem::InitTable(std::shared_ptr<ITable> subtable) {
m_controller->InitTable(subtable);
Subsystem::InitTable(subtable);
}

View File

@@ -225,7 +225,7 @@ void Scheduler::UpdateTable() {
toCancel = new_toCancel->GetDoubleArray();
else
toCancel.resize(0);
// m_table->RetrieveValue("Ids", *ids);
// m_table->RetrieveValue("Ids", *ids);
// cancel commands that have had the cancel buttons pressed
// on the SmartDashboad

View File

@@ -129,8 +129,8 @@ std::string Subsystem::GetName() const { return m_name; }
std::string Subsystem::GetSmartDashboardType() const { return "Subsystem"; }
void Subsystem::InitTable(std::shared_ptr<ITable> table) {
m_table = table;
void Subsystem::InitTable(std::shared_ptr<ITable> subtable) {
m_table = subtable;
if (m_table != nullptr) {
if (m_defaultCommand != nullptr) {
m_table->PutBoolean("hasDefault", true);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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,

View File

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

Some files were not shown because too many files have changed in this diff Show More