Skip to content

Commit

Permalink
2017 Arcade Bot
Browse files Browse the repository at this point in the history
  • Loading branch information
Larry committed Nov 2, 2017
0 parents commit 41adf25
Show file tree
Hide file tree
Showing 16 changed files with 240 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="var" path="wpilib" sourcepath="wpilib.sources"/>
<classpathentry kind="var" path="networktables" sourcepath="networktables.sources"/>
<classpathentry kind="var" path="opencv" sourcepath="opencv.sources"/>
<classpathentry kind="var" path="cscore" sourcepath="cscore.sources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="var" path="USERLIBS_DIR/CANJaguar.jar"/>
<classpathentry kind="var" path="USERLIBS_DIR/CTRLib.jar"/>
<classpathentry kind="var" path="USERLIBS_DIR/navx_frc.jar"/>
<classpathentry kind="var" path="USERLIBS_DIR/niVisionWPI.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
18 changes: 18 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>2018 Arcade</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>edu.wpi.first.wpilib.plugins.core.nature.FRCProjectNature</nature>
</natures>
</projectDescription>
Binary file added bin/org/usfirst/frc/team3939/robot/Robot.class
Binary file not shown.
4 changes: 4 additions & 0 deletions build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Project specific information
package=org.usfirst.frc.team3939.robot
robot.class=${package}.Robot
simulation.world.file=/usr/share/frcsim/worlds/GearsBotDemo.world
30 changes: 30 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>

<project name="FRC Deployment" default="deploy">

<!--
The following properties can be defined to override system level
settings. These should not be touched unless you know what you're
doing. The primary use is to override the wpilib version when
working with older robots that can't compile with the latest
libraries.
-->

<!-- By default the system version of WPI is used -->
<!-- <property name="version" value=""/> -->

<!-- By default the system team number is used -->
<!-- <property name="team-number" value=""/> -->

<!-- By default the target is set to 10.TE.AM.2 -->
<!-- <property name="target" value=""/> -->

<!-- Any other property in build.properties can also be overridden. -->

<property file="${user.home}/wpilib/wpilib.properties"/>
<property file="build.properties"/>
<property file="${user.home}/wpilib/java/${version}/ant/build.properties"/>

<import file="${wpilib.ant.dir}/build.xml"/>

</project>
Binary file added build/jars/CANJaguar.jar
Binary file not shown.
Binary file added build/jars/CTRLib.jar
Binary file not shown.
Binary file added build/jars/NetworkTables.jar
Binary file not shown.
Binary file added build/jars/WPILib.jar
Binary file not shown.
Binary file added build/jars/cscore.jar
Binary file not shown.
Binary file added build/jars/navx_frc.jar
Binary file not shown.
Binary file added build/jars/niVisionWPI.jar
Binary file not shown.
Binary file added build/jars/opencv.jar
Binary file not shown.
Binary file added build/org/usfirst/frc/team3939/robot/Robot.class
Binary file not shown.
Binary file added dist/FRCUserProgram.jar
Binary file not shown.
174 changes: 174 additions & 0 deletions src/org/usfirst/frc/team3939/robot/Robot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
package org.usfirst.frc.team3939.robot;

import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.CANJaguar;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;
//import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
//import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

/**
* This is a demo program showing the use of the RobotDrive class. The
* SampleRobot class is the base of a robot application that will automatically
* call your Autonomous and OperatorControl methods at the right time as
* controlled by the switches on the driver station or the field controls.
*
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the SampleRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*
* WARNING: While it may look like a good choice to use for your code if you're
* inexperienced, don't. Unless you know what you are doing, complex code will
* be much more difficult under this system. Use IterativeRobot or Command-Based
* instead if you're new.
*/
public class Robot extends SampleRobot {

CANJaguar LeftBackMotor, LeftFrontMotor, RightBackMotor, RightFrontMotor;
CANJaguar.ControlMode currControlMode;
RobotDrive myRobot;
Joystick stick = new Joystick(0);
int maxOutputSpeed;







public Robot() {
LeftBackMotor = new CANJaguar(1); //Left Back
LeftFrontMotor = new CANJaguar(3); //Left Front
RightBackMotor = new CANJaguar(5); //Right Back
RightFrontMotor = new CANJaguar(4); //Right Front
myRobot = new RobotDrive(LeftFrontMotor, LeftBackMotor, RightFrontMotor, RightBackMotor);

}


@Override
public void robotInit() {
}

public void initaimdrive() {
LeftFrontMotor.disableControl();
LeftFrontMotor.configMaxOutputVoltage(12.0);
LeftFrontMotor.configNeutralMode(CANJaguar.NeutralMode.Brake);
LeftFrontMotor.setPositionMode(CANJaguar.kQuadEncoder, 4320, 75, .0, 0);
LeftFrontMotor.enableControl();

RightFrontMotor.disableControl();
RightFrontMotor.configMaxOutputVoltage(12.0);
RightFrontMotor.configNeutralMode(CANJaguar.NeutralMode.Brake);
RightFrontMotor.setPositionMode(CANJaguar.kQuadEncoder, 4320, 75, .0, 0);
RightFrontMotor.enableControl();

LeftBackMotor.disableControl();
LeftBackMotor.configMaxOutputVoltage(12.0);
LeftBackMotor.configNeutralMode(CANJaguar.NeutralMode.Coast);
LeftBackMotor.setPositionMode(CANJaguar.kQuadEncoder, 4320, 75, .0, 0);
LeftBackMotor.enableControl();

RightBackMotor.disableControl();
RightBackMotor.configMaxOutputVoltage(12.0);
RightBackMotor.configNeutralMode(CANJaguar.NeutralMode.Coast);
RightBackMotor.setPositionMode(CANJaguar.kQuadEncoder, 4320, 75, .0, 0);
RightBackMotor.enableControl();

}

void initMotor( CANJaguar motor ) {
try {
if ( currControlMode == CANJaguar.JaguarControlMode.Position )
{
motor.configMaxOutputVoltage(12.0);
motor.configNeutralMode(CANJaguar.NeutralMode.Brake);
motor.setPositionMode(CANJaguar.kQuadEncoder, 4320, 0, .0, 0);
}
else
{
motor.configNeutralMode(CANJaguar.NeutralMode.Brake);
motor.setPercentMode();
}
motor.enableControl();
} catch (Exception ex) {
ex.printStackTrace();
}
}

void setMode( CANJaguar.ControlMode controlMode ) {

currControlMode = controlMode;

if ( currControlMode == CANJaguar.JaguarControlMode.Position )
{

}
else // kPercentVbus
{
maxOutputSpeed = 1;
}

initMotor(LeftBackMotor);
initMotor(LeftFrontMotor);
initMotor(RightBackMotor);
initMotor(RightFrontMotor);
//initMotor(Jag_08);
}

void checkForRestartedMotor( CANJaguar motor, String strDescription )
{
if ( currControlMode != CANJaguar.JaguarControlMode.Speed ) // kSpeed is the default
{
try {
if ( !motor.isAlive() )
{
Timer.delay(0.10); // Wait 100 ms
initMotor( motor );
String error = "\n\n>>>>" + strDescription + "Jaguar Power Cycled - re-initializing";
System.out.println(error);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

/**
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable
* chooser code works with the Java SmartDashboard. If you prefer the
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
* getString line to get the auto name from the text box below the Gyro
*
* You can add additional auto modes by adding additional comparisons to the
* if-else structure below with additional strings. If using the
* SendableChooser make sure to add them to the chooser code above as well.
*/
@Override
public void autonomous() {
}

/**
* Runs the motors with arcade steering.
*/
@Override
public void operatorControl() {
myRobot.setSafetyEnabled(true);
while (isOperatorControl() && isEnabled()) {
myRobot.arcadeDrive(-stick.getY(), stick.getX());

Timer.delay(0.005); // wait for a motor update time
}
}

/**
* Runs during test mode
*/
@Override
public void test() {
}
}

0 comments on commit 41adf25

Please sign in to comment.