Permalink
Please sign in to comment.
Browse files
new project
Showing
with
82 additions
and 0 deletions.
| @@ -0,0 +1,18 @@ | ||
| +<?xml version="1.0" encoding="UTF-8"?> | ||
| +<projectDescription> | ||
| + <name>JAVA_Six_CANTalon_ArcadeDrive</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> |
| @@ -0,0 +1,6 @@ | ||
| +# Project specific information | ||
| +package=org.usfirst.frc.team469.robot | ||
| +robot.class=${package}.Robot | ||
| +simulation.world.file=/usr/share/frcsim/worlds/GearsBotDemo.world | ||
| +#Uncomment and point at user libraries to include them in the build. Do not put libraries in the \wpilib\java folder, this folder is completely overwritten on plugin update. | ||
| +#userLibs=${user.home}/wpilib/user/lib |
| @@ -0,0 +1,58 @@ | ||
| + | ||
| +package org.usfirst.frc.team469.robot; | ||
| +import edu.wpi.first.wpilibj.CANTalon; | ||
| +import edu.wpi.first.wpilibj.IterativeRobot; | ||
| +import edu.wpi.first.wpilibj.Joystick; | ||
| +import edu.wpi.first.wpilibj.Joystick.AxisType; | ||
| +import edu.wpi.first.wpilibj.RobotDrive; | ||
| +import edu.wpi.first.wpilibj.RobotDrive.MotorType; | ||
| +import edu.wpi.first.wpilibj.CANTalon.TalonControlMode; | ||
| + | ||
| +/** | ||
| + * The VM is configured to automatically run this class, and to call the | ||
| + * functions corresponding to each mode, as described in the IterativeRobot | ||
| + * 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. | ||
| + */ | ||
| +public class Robot extends IterativeRobot { | ||
| + | ||
| + /* talons for arcade drive */ | ||
| + CANTalon _frontLeftMotor = new CANTalon(11); /* device IDs here (1 of 2) */ | ||
| + CANTalon _rearLeftMotor = new CANTalon(13); | ||
| + CANTalon _frontRightMotor = new CANTalon(14); | ||
| + CANTalon _rearRightMotor = new CANTalon(15); | ||
| + | ||
| + /* extra talons for six motor drives */ | ||
| + CANTalon _leftSlave = new CANTalon(16); | ||
| + CANTalon _rightSlave = new CANTalon(17); | ||
| + | ||
| + RobotDrive _drive = new RobotDrive(_frontLeftMotor, _rearLeftMotor, _frontRightMotor, _rearRightMotor); | ||
| + | ||
| + Joystick _joy = new Joystick(0); | ||
| + /** | ||
| + * This function is run when the robot is first started up and should be | ||
| + * used for any initialization code. | ||
| + */ | ||
| + public void robotInit() { | ||
| + /* take our extra talons and just have them follow the Talons updated in arcadeDrive */ | ||
| + _leftSlave.changeControlMode(TalonControlMode.Follower); | ||
| + _rightSlave.changeControlMode(TalonControlMode.Follower); | ||
| + _leftSlave.set(11); /* device IDs here (2 of 2) */ | ||
| + _rightSlave.set(14); | ||
| + | ||
| + /* the Talons on the left-side of my robot needs to drive reverse(red) to move robot forward. | ||
| + * Since _leftSlave just follows frontLeftMotor, no need to invert it anywhere. */ | ||
| + _drive.setInvertedMotor(MotorType.kFrontLeft, true); | ||
| + _drive.setInvertedMotor(MotorType.kRearLeft, true); | ||
| + } | ||
| + | ||
| + /** | ||
| + * This function is called periodically during operator control | ||
| + */ | ||
| + public void teleopPeriodic() { | ||
| + double forward = _joy.getRawAxis(1); // logitech gampad left X, positive is forward | ||
| + double turn = _joy.getRawAxis(2); //logitech gampad right X, positive means turn right | ||
| + _drive.arcadeDrive(forward, turn); | ||
| + } | ||
| +} |
Binary file not shown.
0 comments on commit
f44e015