Skip to content

Commit

Permalink
Updates from comps
Browse files Browse the repository at this point in the history
  • Loading branch information
StripedMonkey committed Mar 23, 2019
1 parent ecef1d6 commit 4294155
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2019.4.1"
id "edu.wpi.first.GradleRIO" version "2019.3.2"
}

// Define my targets (RoboRIO) and artifacts (deployable files)
Expand Down
22 changes: 18 additions & 4 deletions src/main/cpp/Robot.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
#include "Robot.h"
#include <iostream>

void Robot::RobotPeriodic()
{

//Toggle between the two cameras
if(cameraToggle && controller.GetRawButton(1)) {
camServer.SetSource(camFront);
cameraToggle = !cameraToggle;
}
if(!cameraToggle && controller.GetRawButton(1)) {
camServer.SetSource(camRear);
cameraToggle = !cameraToggle;
}
}

void Robot::AutonomousPeriodic() {
PlayerControl();
}
void Robot::TeleopPeriodic()
{
PlayerControl();
}

void Robot::PlayerControl() {
// Drive with arcade style controls
diffDrive.ArcadeDrive(controller.GetY(), controller.GetX());
if(controller.GetRawAxis(5) > speed) {
speed = speed + controller.GetRawAxis(5)/16;
} else if(controller.GetRawAxis(5) < speed) {
speed = speed - controller.GetRawAxis(5)/16;
}
diffDrive.ArcadeDrive(-speed, controller.GetRawAxis(4) * .8);

//"Intake mode" that allows the user to set the intake running constantly until a ball is caught
if (controller.GetRawButton(9) && !(controller.GetRawAxis(2) > 0))
if (controller.GetRawButton(9) && (controller.GetRawAxis(2) == 0))
{
intakeMode = true;
cargoMotor.Set(.25);
cargoMotor.Set(.2);
}
if (controller.GetRawAxis(2) > 0)
{
Expand Down
7 changes: 5 additions & 2 deletions src/main/include/Robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class Robot : public frc::TimedRobot
//As these are the only two classes we utilize they are the only two overridden
void RobotPeriodic() override;
void TeleopPeriodic() override;
void AutonomousPeriodic() override;
void PlayerControl();

private:
//A single Xbox controller
Expand All @@ -33,8 +35,8 @@ class Robot : public frc::TimedRobot
frc::Spark rightMotor{1};
frc::DifferentialDrive diffDrive{leftMotor, rightMotor};

//Intake for "carog"
frc::Spark cargoMotor{2};
//Intake for "cargo"
frc::Spark cargoMotor{3};

//Cameras used for viewing at the Driver station
//Sink is used to switch between cameras and (hopefully) save on bandwidth and latency
Expand All @@ -46,5 +48,6 @@ class Robot : public frc::TimedRobot
//Msc variables
bool intakeMode = false;
bool cameraToggle = 0;
double speed = 0;

};

0 comments on commit 4294155

Please sign in to comment.