Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
5d39df1
build.gradle was updated to version 2019.2.1, old ver. 2019.1.1
Zhiqin-He Jan 19, 2019
9b394a8
Pixy camera base code taken from BHSRobotix
Zhiqin-He Jan 22, 2019
2cef246
Deleted pixy code since Joey has already created working pixy code.
Zhiqin-He Feb 2, 2019
4594e57
Added ADIS gyro library, began code to get angles from gyro (buggy)
Zhiqin-He Feb 2, 2019
543feac
Command to turn angle given by vision when button pressed, still buggy
Zhiqin-He Feb 2, 2019
78b7ee1
Added comments for TODO
Zhiqin-He Feb 5, 2019
ae106b6
Changed drive back to static
Zhiqin-He Feb 5, 2019
753565a
Merge remote-tracking branch 'origin/NotTestedDidAtHome' into NotTest…
Zhiqin-He Feb 5, 2019
9e1a3d8
Pneumatics renaming
Zhiqin-He Feb 5, 2019
566b1fd
Merge branch 'NotTestedDidAtHome' into NotTestedZhiqin
JoeCowles Feb 5, 2019
848dabe
Final fixes to isFinished method in TurnDegrees
Zhiqin-He Feb 5, 2019
73852f6
Fixed several bugs and made drive in DriveTrain non-static
Zhiqin-He Feb 5, 2019
e1d8ed7
Added exit statement if target angle is 0 in TurnDegrees
Zhiqin-He Feb 7, 2019
cf46d72
Added the guide to target Command
JoeCowles Feb 7, 2019
736f90f
Added GuideToTarget Command
JoeCowles Feb 7, 2019
499f9b9
Commited all changes and merged the two laptops
JoeCowles Feb 7, 2019
687a489
Recommiting the merge
JoeCowles Feb 7, 2019
4fb905b
ADIS16448 library updated to r2
Zhiqin-He Feb 8, 2019
bad0c7d
Got Encoder and Vision working
JoeCowles Feb 9, 2019
1183603
Tested the arm
JoeCowles Feb 12, 2019
f057211
Ultrasonic code test
Zhiqin-He Feb 12, 2019
8ad6565
Merge branch 'NotTestedZhiqin' of https://github.com/rtr2421/DeepSpac…
Zhiqin-He Feb 12, 2019
ac03d19
Ultrasonic sensor switched to serial (Still buggy)
Zhiqin-He Feb 14, 2019
edc5acb
Commiting, arm works
JoeCowles Feb 14, 2019
4c127c4
Ultrasonic get distance now returns correct number in mm.
Zhiqin-He Feb 15, 2019
bfcb384
Got everything working again, no UltraSonic in this version
JoeCowles Feb 16, 2019
c0ea901
Added Halleffect and other subsystems
JoeCowles Feb 16, 2019
1dc88d9
Merge branches 'NotTestedZhiqin' and 'NotTestedZhiqin' of https://git…
Zhiqin-He Feb 16, 2019
d22583d
Got photoResistor working, got telecoping arm working, and got the ar…
JoeCowles Feb 16, 2019
e2871bd
Merged
JoeCowles Feb 16, 2019
3ab95e0
RobotMap created and deployed
Zhiqin-He Feb 18, 2019
18f740d
Sparks for DriveTrain replaced with Talons (untested), code cleaned u…
Zhiqin-He Feb 18, 2019
9976ca8
RobotMap updated.
Zhiqin-He Feb 18, 2019
a4ca15e
Updated ultrasonic display on Shuffleboard to Rumbler
Zhiqin-He Feb 18, 2019
2aa3cf4
Fixed claw
JoeCowles Feb 18, 2019
cb7b33c
Merged
JoeCowles Feb 18, 2019
4d25d74
Exponential drive added
JoeCowles Feb 20, 2019
a3f2bbc
TankDrive is now on a switch
JoeCowles Feb 20, 2019
fda9c2e
Commiting recent changes
JoeCowles Feb 24, 2019
4c49d98
Mapped all of the buttons and added the string pot
JoeCowles Feb 26, 2019
78157d0
Created Ultrasonic w/ echo
JoeCowles Feb 26, 2019
77452e1
Robot works
JoeCowles Mar 2, 2019
a1082b4
Robot works
JoeCowles Mar 2, 2019
8c1f546
All changes made at comp
JoeCowles Mar 9, 2019
d882a51
Wrist subsystem and turn wrist amount of degrees (not tested)
Zhiqin-He Mar 9, 2019
82bf5e8
Added climb subsystem
JoeCowles Mar 9, 2019
01a0d9a
Merge branch 'NotTestedZhiqin' of https://github.com/rtr2421/DeepSpac…
JoeCowles Mar 9, 2019
79d47e5
Wrist debugged
JoeCowles Mar 9, 2019
f9d1fab
Position arm command created, need to input actual distance in terms …
Zhiqin-He Mar 12, 2019
66ca724
Fixed arm positions, still not tested
JoeCowles Mar 13, 2019
d54eea0
Added arm positions, and custom controller
JoeCowles Mar 14, 2019
91d2f64
Got rid of telearm and made ArmMoveTo work
JoeCowles Mar 20, 2019
116dd87
Added arm reed switches instead of the sting pot
JoeCowles Mar 20, 2019
8548800
Added auto climb, fixed ultrasonic to be analog, and added hatch pane…
JoeCowles Mar 22, 2019
b11a60e
Added wrist controller
JoeCowles Mar 22, 2019
bf1ff61
Debugged robot code, all motors work now
JoeCowles Mar 23, 2019
cf19e6f
"
JoeCowles Mar 23, 2019
192768c
Deleted unused imports
JoeCowles Mar 23, 2019
1a157b0
Did stuff
JoeCowles Mar 23, 2019
60e23d3
Joystickdrive updated
2421RTR Mar 23, 2019
8b590df
Merged
JoeCowles Mar 23, 2019
7420a96
Climb code revised
JoeCowles Mar 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2019.2.1"
id "edu.wpi.first.GradleRIO" version "2019.4.1"
}

def ROBOT_MAIN_CLASS = "frc.robot.Main"
Expand Down
63 changes: 47 additions & 16 deletions src/main/java/frc/robot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@

package frc.robot;

import java.awt.event.KeyListener;
import java.util.ResourceBundle.Control;

import edu.wpi.first.wpilibj.Controller;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.buttons.Button;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
import frc.robot.commands.ArmToNextPosition;
import frc.robot.commands.ClawReverse;
import frc.robot.commands.MoveClaw;
import frc.robot.commands.SetSpeed;
import edu.wpi.first.wpilibj.buttons.Trigger;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.commands.*;
import frc.robot.subsystems.Arm;
import frc.robot.subsystems.CameraI2c;

/**
* This class is the glue that binds the controls on the physical operator
Expand Down Expand Up @@ -49,19 +55,44 @@ public class OI {
// button.whenReleased(new ExampleCommand());

public static XboxController xBoxControl = new XboxController(0);

public static Joystick xBoxControlArm = new Joystick(1);
Button pistonExtend = new JoystickButton(xBoxControl, 8);
Button pistonRetract = new JoystickButton(xBoxControl, 7);
Button lowRocket_c = new JoystickButton(xBoxControlArm, 1);
Button midRocket_c = new JoystickButton(xBoxControlArm, 2);
Button button = new JoystickButton(xBoxControl, 2);
Button climb = new JoystickButton(xBoxControl, 1);
Button highRocket_c = new JoystickButton(xBoxControlArm, 3);
Button lowRocket_h = new JoystickButton(xBoxControlArm, 4);
Button cargoShip_h = new JoystickButton(xBoxControlArm, 6);
Button midRocket_h = new JoystickButton(xBoxControlArm, 5);
public OI() {
// Button rTrig = new JoystickButton(xBoxControl, buttonNumber)
Button b1 = new JoystickButton(xBoxControl, 6);
b1.whenPressed(new SetSpeed(true));
//b1.whenReleased(new SetSpeed(false));

Button b2 = new JoystickButton(xBoxControl, 5);
b2.whenPressed(new SetSpeed(false));
b2.close();
Button aButton = new JoystickButton(xBoxControl, 1);
aButton.whenPressed(new ArmToNextPosition());
aButton.close();
//Button rTrig = new JoystickButton(xBoxControl, buttonNumber)

pistonExtend.whenPressed(new ExtendPiston());

pistonRetract.whenPressed(new RetractPiston());
climb.whenPressed(new ClimbStair());
button.whenPressed(new TurnDegrees());


lowRocket_c.whenPressed(new MoveArmTo(1));

midRocket_c.whenActive(new MoveArmTo(2));

highRocket_c.whenActive(new MoveArmTo(3));


lowRocket_h.whenPressed(new MoveArmTo(4));

midRocket_h.whenPressed(new MoveArmTo(5));
//not possible to do high rocket hatch due to no teleArm


cargoShip_h.whenPressed(new MoveArmTo(6));

/*Button aButton = new JoystickButton(xBoxControl, 1);
aButton.whenPressed(new ExtendPiston());
aButton.whenReleased(new StopTeleArm());*/
}
}
80 changes: 66 additions & 14 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@

import edu.wpi.first.cameraserver.CameraServer;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.commands.ExampleCommand;
import frc.robot.commands.GetDistance;
import frc.robot.commands.PneumaticsDrive;
import frc.robot.commands.Teleop;
import frc.robot.commands.TurnDegrees;
import frc.robot.subsystems.Arm;
import frc.robot.subsystems.ArmLimitSwitch;
import frc.robot.subsystems.BaseLimitSwitch;
import frc.robot.subsystems.CameraI2c;
import frc.robot.subsystems.Claw;
import frc.robot.subsystems.Climb;
import frc.robot.subsystems.DriveTrain;
import frc.robot.subsystems.ExampleSubsystem;
import frc.robot.subsystems.LaserFinder;
import frc.robot.subsystems.Photoresistor;
import frc.robot.subsystems.pneumatics;
import frc.robot.subsystems.SerialDistance;
import frc.robot.subsystems.UltraSonic;
import frc.robot.subsystems.Wrist;

/**
* The VM is configured to automatically run this class, and to call the
Expand All @@ -42,30 +42,34 @@ public class Robot extends TimedRobot {
public static pneumatics m_pneumatics;
public static OI m_oi;
public static DriveTrain m_driveTrain;
//public static final ADIS16448_IMU imu = new ADIS16448_IMU();
public static Teleop m_teleop;
Command m_autonomousCommand;
Compressor com = new Compressor(0);
SendableChooser<Command> m_chooser = new SendableChooser<>();
public static SerialDistance m_serialPort;
public static UltraSonic m_ultraSonic;
public static Claw claw;
public static CameraI2c camera;
public static Arm arm;
public static ArmLimitSwitch m_limitSwitch;
public static BaseLimitSwitch m_baseSwitch;
public static Photoresistor resistor;
public static Timer m_timer;
public static LaserFinder m_laser;
public static Wrist m_wrist;
public static Climb m_climb;
//public static Ramps m_ramps;
/**
* This function is run when the robot is first started up and should be used
* for any initialization code.
*
*/
@Override
public void robotInit() {
SmartDashboard.putBoolean("Arm moving",false);
com.setClosedLoopControl(true);
com.start();
m_climb = new Climb();
claw = new Claw();
arm = new Arm();
m_baseSwitch = new BaseLimitSwitch();
m_limitSwitch = new ArmLimitSwitch();
camera = new CameraI2c();
m_driveTrain = new DriveTrain();
m_chooser.setDefaultOption("Default Auto", new ExampleCommand());
Expand All @@ -74,11 +78,21 @@ public void robotInit() {
CameraServer.getInstance().startAutomaticCapture(0);
CameraServer.getInstance().startAutomaticCapture(1);
Scheduler.getInstance().add(new Teleop());
// m_serialPort = new SerialDistance();
// m_ultraSonic = new UltraSonic();
Scheduler.getInstance().add(new GetDistance());
resistor = new Photoresistor();
m_timer = new Timer();
m_laser = new LaserFinder();
SmartDashboard.putBoolean("TankDrive", false);
m_wrist = new Wrist();
m_climb.dropFront();
m_climb.dropBack();
m_ultraSonic = new UltraSonic();

//Scheduler.getInstance().add(new GetDistance());
//OI must be init last
SmartDashboard.putNumber("Claw Speed", claw.speed);
SmartDashboard.putNumber("Offset", TurnDegrees.offset);
m_oi = new OI();
m_timer.start();
}

/**
Expand All @@ -91,7 +105,44 @@ public void robotInit() {
*/
@Override
public void robotPeriodic() {
SmartDashboard.putNumber("Wrist Encoder", m_wrist.getAngle());
SmartDashboard.putNumber("Reed switch", arm.readPos());
SmartDashboard.putNumber("String pot", arm.readPos());
SmartDashboard.putNumber("UltraSonic", m_ultraSonic.getDistance());
//--------------------------Do 10 times per Second --------------------------------------------------
if(m_timer.hasPeriodPassed(.1)){
CameraI2c.read();
m_laser.read();
m_timer.reset();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//m_serialPort.getString(); //REMOVE LATER LSKJDFLKSDFLJAFHSDGJOEWJ9248&(*#@!^%(*!@&$(*@&$37)))
//CameraI2c.read();
/*
SmartDashboard.putNumber("Gyro-X", m_driveTrain.getGyroX());
SmartDashboard.putNumber("Gyro-Y", m_driveTrain.getGyroY());
SmartDashboard.putN
umber("Gyro-Z", m_driveTrain.getGyroZ());
*/
/*
TurnDegrees.offset = SmartDashboard.getNumber("Offset", TurnDegrees.offset);
SmartDashboard.putNumber("Offset", TurnDegrees.offset);
/*
SmartDashboard.putNumber("Gyro-X", m_driveTrain.getGyroX());
SmartDashboard.putNumber("Gyro-Y", imu.getAngleY());
SmartDashboard.putNumber("Gyro-Z", imu.getAngleZ());

SmartDashboard.putNumber("Accel-X", imu.getAccelX());
SmartDashboard.putNumber("Accel-Y", imu.getAccelY());
SmartDashboard.putNumber("Accel-Z", imu.getAccelZ());

SmartDashboard.putNumber("Pitch", imu.getPitch());
SmartDashboard.putNumber("Roll", imu.getRoll());
SmartDashboard.putNumber("Yaw", imu.getYaw());

SmartDashboard.putNumber("Pressure: ", imu.getBarometricPressure());
SmartDashboard.putNumber("Temperature: ", imu.getTemperature());
*/
}
@Override
public void disabledInit() {
Expand Down Expand Up @@ -159,6 +210,7 @@ public void teleopInit() {
*/
@Override
public void teleopPeriodic() {
//CameraI2c.read();
Scheduler.getInstance().run();
}

Expand Down
45 changes: 38 additions & 7 deletions src/main/java/frc/robot/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,42 @@ public class RobotMap {
// number and the module. For example you with a rangefinder:
// public static int rangefinderPort = 1;
// public static int rangefinderModule = 1;
public static int UltraSonic = 1;
public static int ArmLimitSwitch = 2;
public static int leftMotor1 = 0;
public static int leftMotor2 = 1;
public static int leftMotor3 = 2;
public static int leftMotor4 = 3;
public static int arm = 4;

//Analog
public final static int PHOTORESISTOR = 0;
public final static int ULTRASONIC = 3;
public static final int STRING_POT = 2;
//public final static int ARMLIMITSWITCH = 2;

//DIO
public final static int ARM_REED_2 = 2;
public final static int ARM_REED_3 = 3;
public final static int ARM_SWITCHBOTTOM = 0;
public final static int ARM_REED_1 = 1; //UNUSED(?)
//public final static int ULTRASONIC = 4;
public final static int ULTRASONIC_ECHO = 5;
public final static int WRIST_ENCODER_A = 6;
public final static int WRIST_ENCODER_B = 7;

//CAN
public final static int ARM_L = 4;//
public final static int ARM_R = 5;//
public final static int CLAW_1 = 6;//
public final static int CLAW_2 = 8;//
public final static int LEFTMOTOR_1 = 3; //
public final static int LEFTMOTOR_2 = 1;//
public final static int RIGHTMOTOR_1 = 2;//
public final static int RIGHTMOTOR_2 = 0; //
public final static int WRISTMOTOR = 7;//

//Pneumatics
public final static int PNEUMATIC_COMPRESSOR = 0;
public final static int DOUBLESOL_FORWARD = 0;
public final static int DOUBLESOL_REVERSE = 1;
public final static int DOUBLESOL_FORWARD1 = 2;
public static final int DOUBLESOL_REVERSE1 = 3;
public static final int CLIMBSOL_FRONT_FORWARD = 7;
public static final int CLIMBSOL_FRONT_REVERSE = 6;
public static final int CLIMBSOL_BACK_FORWARD = 4;
public static final int CLIMBSOL_BACK_REVERSE =5;
}
73 changes: 73 additions & 0 deletions src/main/java/frc/robot/commands/ArmDrive.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/

package frc.robot.commands;

import edu.wpi.first.wpilibj.GenericHID.Hand;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.OI;
import frc.robot.Robot;

public class ArmDrive extends Command {
public static final double WRIST_POSISTION_STRAIGHT = 15;
int count = 1;
public ArmDrive() {
// Use requires() here to declare subsystem dependencies
requires(Robot.arm);
requires(Robot.m_wrist);
}

// Called just before this Command runs the first time
@Override
protected void initialize() {
}

// Called repeatedly when this Command is scheduled to run
@Override
protected void execute() {
SmartDashboard.putBoolean("Swtich one", Robot.arm.switchOne());
SmartDashboard.putBoolean("Switch two", Robot.arm.switchTwo());
SmartDashboard.putBoolean("Switch three", Robot.arm.switchThree());
SmartDashboard.putNumber("Arm position", Robot.arm.readPos());
if(OI.xBoxControl.getBumper(Hand.kLeft)){
Robot.arm.move();
SmartDashboard.putBoolean("Arm moving", true);
}else if(OI.xBoxControl.getBumper(Hand.kRight)){
Robot.arm.moveDown();
SmartDashboard.putBoolean("Arm moving", true);
}else{
SmartDashboard.putBoolean("Arm moving", false);
Robot.arm.stop();
}
if(OI.xBoxControl.getY(Hand.kLeft) > .1 || OI.xBoxControl.getY(Hand.kLeft) < .1){
Robot.m_wrist.raise(OI.xBoxControl.getY(Hand.kLeft));
}
if(OI.xBoxControl.getStickButton(Hand.kLeft)){
Robot.m_wrist.setTarget(WRIST_POSISTION_STRAIGHT);
Robot.m_wrist.move();
}

}

// Make this return true when this Command no longer needs to run execute()
@Override
protected boolean isFinished() {
return false;
}

// Called once after isFinished returns true
@Override
protected void end() {
}

// Called when another command which requires one or more of the same
// subsystems is scheduled to run
@Override
protected void interrupted() {
}
}
Loading