This repository has been archived by the owner on Nov 2, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
735 additions
and
442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
#include <Commands/Autonomous/CommandGroups/Auto.hpp> | ||
#include <Utilities/Log.hpp> | ||
|
||
JustDriveForward::JustDriveForward() { LOG( "[Auto] Constructed" ); } | ||
JustDriveForward::JustDriveForward() { | ||
LOG("[Auto] Constructed"); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
Oops, something went wrong.