Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
ewpratten committed Nov 15, 2018
1 parent 281118c commit 2878366
Show file tree
Hide file tree
Showing 13 changed files with 735 additions and 442 deletions.
25 changes: 6 additions & 19 deletions .clang-format
@@ -1,26 +1,13 @@
---
---
BasedOnStyle: Chromium
AlignEscapedNewlinesLeft: 'true'
AlignAfterOpenBracket: Align
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: 'true'
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AllowShortIfStatementsOnASingleLine: 'true'
AlwaysBreakBeforeMultilineStrings: 'false'
AlwaysBreakTemplateDeclarations: 'false'
BinPackParameters: 'true'
BreakBeforeBinaryOperators: 'false'
BreakBeforeBraces: Stroustrup
BreakBeforeTernaryOperators: 'false'
BreakConstructorInitializersBeforeComma: 'false'
ColumnLimit: '160'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
Cpp11BracedListStyle: 'false'
DerivePointerAlignment: 'true'
ColumnLimit: '100'
Language: Cpp
SpacesInParentheses: 'true'
Standard: Auto
UseTab: Always
SortIncludes: 'true'
SpaceBeforeParens: Never

...
53 changes: 26 additions & 27 deletions src/main/cpp/CommandBase.cpp
Expand Up @@ -5,40 +5,39 @@

// static variables in C++ have to be declared here
// (not in the .hpp file)
DriveTrain *CommandBase::pDriveTrain = NULL;
Generic *CommandBase::pGeneric = NULL;
OI *CommandBase::pOI = NULL;
DriveTrain* CommandBase::pDriveTrain = NULL;
Generic* CommandBase::pGeneric = NULL;
OI* CommandBase::pOI = NULL;

CommandBase::CommandBase() : Command()
{
LOG( "[CommandBase] Constructed" );
CommandBase::CommandBase() :
Command() {
LOG("[CommandBase] Constructed");

// Note: These aren't "this" because they are static,
// so there is only one instance of these variables in
// the CommandBase class. "this" pointers refer to
// regular variables that are created (and are unique)
// to the 'instance' of the object.
// Note: These aren't "this" because they are static,
// so there is only one instance of these variables in
// the CommandBase class. "this" pointers refer to
// regular variables that are created (and are unique)
// to the 'instance' of the object.

if ( CommandBase::pOI == nullptr ) {
CommandBase::pOI = new OI();
}
if (CommandBase::pOI == nullptr) {
CommandBase::pOI = new OI();
}

if ( CommandBase::pDriveTrain == nullptr ) {
CommandBase::pDriveTrain = new DriveTrain();
}
if (CommandBase::pDriveTrain == nullptr) {
CommandBase::pDriveTrain = new DriveTrain();
}

if ( CommandBase::pGeneric == nullptr ) {
CommandBase::pGeneric = new Generic();
}
if (CommandBase::pGeneric == nullptr) {
CommandBase::pGeneric = new Generic();
}

return;
return;
}

CommandBase::~CommandBase()
{
delete this->pDriveTrain;
delete this->pGeneric;
delete this->pOI;
CommandBase::~CommandBase() {
delete this->pDriveTrain;
delete this->pGeneric;
delete this->pOI;

return;
return;
}
5 changes: 4 additions & 1 deletion src/main/cpp/Commands/Autonomous/CommandGroups/Auto.cpp
@@ -1,4 +1,7 @@
#include <Commands/Autonomous/CommandGroups/Auto.hpp>
#include <Utilities/Log.hpp>

JustDriveForward::JustDriveForward() { LOG( "[Auto] Constructed" ); }
JustDriveForward::JustDriveForward() {
LOG("[Auto] Constructed");

}
153 changes: 78 additions & 75 deletions src/main/cpp/Commands/DriveWithJoystick.cpp
@@ -1,88 +1,91 @@
// Include Required Files
#include <math.h> // STD math lib
#include <Commands/DriveWithJoystick.hpp> // Header File
#include <Utilities/Log.hpp> // LOG tool. Used for printing to the RIOlog console
#include "../RobotCFG.hpp" // Robot-wide configuration file

DriveWithJoystick::DriveWithJoystick()
{
LOG( "[DriveWithJoystick] Constructed" );

if ( CommandBase::pDriveTrain != nullptr ) {
Requires( CommandBase::pDriveTrain );
}
else {
LOG( "[DriveWithJoystick] driveTrain is null!" );
}

return;
#include <Commands/DriveWithJoystick.hpp> // Header File
#include <math.h> // STD math lib
#include <Utilities/Log.hpp> // LOG tool. Used for printing to the RIOlog console
#include "../RobotCFG.hpp" // Robot-wide configuration file



DriveWithJoystick::DriveWithJoystick() {
LOG("[DriveWithJoystick] Constructed");

if (CommandBase::pDriveTrain != nullptr) {
Requires(CommandBase::pDriveTrain);
} else {
LOG("[DriveWithJoystick] driveTrain is null!");
}

return;
}

DriveWithJoystick::~DriveWithJoystick()
{
LOG( "[DriveWithJoystick] Destroyed" );
DriveWithJoystick::~DriveWithJoystick() {
LOG("[DriveWithJoystick] Destroyed");

return;
return;
}

void DriveWithJoystick::Initialize()
{
LOG( "[DriveWithJoystick] Initialized" );
// Store pointer to SmartDashboard in table
table = NetworkTable::GetTable( "SmartDashboard" );
this->isReverse = false;
void DriveWithJoystick::Initialize() {
LOG("[DriveWithJoystick] Initialized");
// Store pointer to SmartDashboard in table
table = NetworkTable::GetTable("SmartDashboard");
this->isReverse = false;

return;
return;
}

void DriveWithJoystick::Execute()
{
// Pointer to Xbox Controller
frc::XboxController *pJoyDrive = CommandBase::pOI->GetJoystickDrive();

// Trigger Reverse Mode if X Button Tapped
if ( pJoyDrive->GetXButtonReleased() ) {
this->isReverse = !this->isReverse;
}

// The Y-axis goes from -1 (forward) to 1 (backwards) but we want to
// set motor from 1 (forward) to -1 (reverse) so multiply by -1
double xSpeed = pJoyDrive->GetY( XboxController::kLeftHand ) * -1; // Speed = Joustick Y Axis
double zRotation = pJoyDrive->GetX( XboxController::kLeftHand ); // Rotation = Joystick X Axis

// Set Slow and Reverse Modes
double dSlow = ( pJoyDrive->GetBumper( XboxController::kRightHand ) ) ? 0.5 : 1;
double dReverse = ( this->isReverse ) ? -1 : 1;

// Joystick Deadzone
if ( fabs( xSpeed ) <= XBOX_DEADZONE_LEFT_JOY ) {
xSpeed = 0.0;
}

if ( fabs( zRotation ) <= XBOX_DEADZONE_LEFT_JOY ) {
zRotation = 0.0;
}

// Calculate final speed and rotation
xSpeed = ( xSpeed * dSlow * dReverse );
zRotation = ( zRotation * dSlow );

// If the vision mode is enabled, get info from table and store in vars
if ( Vision && pJoyDrive->GetBButton() ) {
double Speed, Rotation;
std::tie( Speed, Rotation ) = GetMotorSpeeds( table ); // Get Movement Data
xSpeed = Speed;
zRotation = Rotation;
}

// Call DriveTrain
CommandBase::pDriveTrain->ArcadeDrive( xSpeed, zRotation );

return;
void DriveWithJoystick::Execute() {
// Pointer to Xbox Controller
frc::XboxController* pJoyDrive = CommandBase::pOI->GetJoystickDrive();

// Trigger Reverse Mode if X Button Tapped
if (pJoyDrive->GetXButtonReleased()) {
this->isReverse = !this->isReverse;
}

// The Y-axis goes from -1 (forward) to 1 (backwards) but we want to
// set motor from 1 (forward) to -1 (reverse) so multiply by -1
double xSpeed = pJoyDrive->GetY(XboxController::kLeftHand) * -1; // Speed = Joustick Y Axis
double zRotation = pJoyDrive->GetX(XboxController::kLeftHand); // Rotation = Joystick X Axis

// Set Slow and Reverse Modes
double dSlow = (pJoyDrive->GetBumper(XboxController::kRightHand)) ? 0.5 : 1;
double dReverse = (this->isReverse) ? -1 : 1;

// Joystick Deadzone
if (fabs(xSpeed) <= XBOX_DEADZONE_LEFT_JOY) {
xSpeed = 0.0;
}

if (fabs(zRotation) <= XBOX_DEADZONE_LEFT_JOY) {
zRotation = 0.0;
}

// Calculate final speed and rotation
xSpeed = (xSpeed * dSlow * dReverse);
zRotation = (zRotation * dSlow);

// If the vision mode is enabled, get info from table and store in vars
if(Vision && pJoyDrive->GetBButton()){
double Speed, Rotation;
std::tie(Speed, Rotation) = GetMotorSpeeds(table); // Get Movement Data
xSpeed = Speed;
zRotation = Rotation;
}

// Call DriveTrain
CommandBase::pDriveTrain->ArcadeDrive(xSpeed, zRotation);

return;
}

bool DriveWithJoystick::IsFinished() { return false; }
bool DriveWithJoystick::IsFinished() {
return false;
}

void DriveWithJoystick::End() { return; }
void DriveWithJoystick::End() {
return;
}

void DriveWithJoystick::Interrupted() { return; }
void DriveWithJoystick::Interrupted() {
return;
}

0 comments on commit 2878366

Please sign in to comment.