Go to Post In the 2010 game, FRC and FVC robots will be working together to cut Dave's hair, mow his lawn, and serve him dinner. ;) - Rich Kressly [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Spotlight this post!  
Unread 02-04-2015, 10:15 PM
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Limit Swtich Help

I have setup the limit switch program with the suggestions but I am attempting to setup reverse for the victors. Also I am trying to setup the same if statement layout for my relays does this look okay?
Code:
public class Robot extends SampleRobot {
    RobotDrive robot;
    Joystick stick;
    Joystick xbox;
    Relay spike1;
    Relay spike2;
    Victor victor1;
    Victor victor2;
    DigitalInput limit;
    boolean limitPressed = false;

    public Robot() {
    	robot = new RobotDrive(0, 1);
        stick = new Joystick(1);
        xbox = new Joystick(0);
        spike1 = new Relay(0);
        spike2 = new Relay(1);
        limit = new DigitalInput(4);
        victor1 = new Victor(4);
        victor2 = new Victor(5);
    }
    public void operatorControl() {
    	
    	while (isOperatorControl() && isEnabled()) {
            stick.getThrottle();
            robot.arcadeDrive(stick.getY(), stick.getX());
            limitPressed = limit.get(); //Do I want this out side of my while operator control loop?
            System.out.println("limitPressed=" + limitPressed); //Read the RoboRIO log for some values before you go all out on your motors.
            
            if(limitPressed) {
            	victor1.set(0);
            	victor2.set(0);
            } else if (xbox.getRawButton(4)) {
            	victor1.set(1);
            	victor2.set(1);
            } else {
            	victor1.set(0);
            	victor1.set(0);
            }
            if(xbox.getRawButton(1)) {
            	victor1.set(-1);
            	victor1.set(-1);
            } else {
            	victor1.set(0);
            	victor2.set(0);
            }
            if(xbox.getRawButton(3)) {
            	spike1.set(Relay.Value.kForward);
            	spike2.set(Relay.Value.kForward);
            } else {
            	spike1.set(Relay.Value.kOff);
            	spike2.set(Relay.Value.kOff);            	
            }
            if(xbox.getRawButton(2)) {
            	spike1.set(Relay.Value.kReverse);
            	spike2.set(Relay.Value.kReverse);	
            } else {
            	spike1.set(Relay.Value.kOff);
            	spike2.set(Relay.Value.kOff);
            }    
    	}
    }
Reply With Quote
 


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 08:42 AM.

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