Go to Post Thanks and don't stay up all night waiting for Lavery Claus! - Beth Sweet [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-02-2016, 15:19
CyberTeam5713 CyberTeam5713 is offline
Registered User
FRC #5713
 
Join Date: Feb 2016
Location: Michigan
Posts: 25
CyberTeam5713 is an unknown quantity at this point
Tank Drive with one xbox controller

This is Tank Drive with one controller using left analog to control left drive train and right analog to control right drive.


public class Robot extends IterativeRobot {

RobotDrive Leftdrive;
RobotDrive Rightdrive;
Joystick mXboxController;
Joystick controlStick;
Talon frontLeft,frontRight, rearLeft, rearRight;

public void robotInit() { // this code will be ran each time we power on the robot

mXboxController = new Joystick(1); // depends on the usb connected to computer
controlStick = new Joystick(0);
frontLeft = new Talon(2);
frontLeft.setInverted(true);
frontRight = new Talon(1);

rearLeft = new Talon(3);
rearRight = new Talon(0);
rearRight.setInverted(true);
Leftdrive = new RobotDrive(frontLeft, rearLeft);
Rightdrive = new RobotDrive(frontRight, rearRight);
}


public void autonomousInit() { // triggers when we enter autonomous


}


public void autonomousPeriodic() { // this code runs periodically in autonomous
while (isAutonomous() && isEnabled()) {
Leftdrive.drive(0.5, 0.0);
Rightdrive.drive(0.5, 0.0);
Timer.delay(0.5);
Leftdrive.drive(0.0, 0.0);
Rightdrive.drive(0.0, 0.0);

}
}




public void teleopInit(){ // This triggers every time we enter telop mode.

mXboxController = new Joystick(0); // the number within the parathesis depends on the controllers usb order always check
controlStick = new Joystick(1);

}




public void teleopPeriodic() {
while (isOperatorControl() && isEnabled()) {
Leftdrive.setSafetyEnabled(true);
Rightdrive.setSafetyEnabled(true);
Leftdrive.tankDrive(mXboxController.getRawAxis(1), mXboxController.getRawAxis(1));
Rightdrive.tankDrive(mXboxController.getRawAxis(5) , mXboxController.getRawAxis(5));
Timer.delay(0.01); } } // this will constantly update motors and speed controllers periodically


At the speedcontroller setInverted you do not have to invert the controller thats just how ours was set up
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:35.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi