View Single Post
  #7   Spotlight this post!  
Unread 06-11-2012, 23:07
y-aji y-aji is offline
Registered User
FRC #3734
 
Join Date: Dec 2011
Location: Lake Forest
Posts: 38
y-aji is an unknown quantity at this point
Re: Lost our last programmer

Thanks for all the replies!

My responses don't seem to be going through, so if suddenly 5 replies come out of this from me, I apologize. We got the code to work, but still can't seem to get it to drive. I've gotten a response out of button presses with the suggested code. I left the whole block regarding watchdog off as it's in the autonomous section, anyway, which we are currently not working with. In fact, let me post the following to clarify what lines we're working with at this point:

Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. 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 edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.Relay.Value;
/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the SimpleRobot
 * 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 AwesomO extends SimpleRobot {
    
    RobotDrive drive = new RobotDrive(1,2);
    Joystick leftStick = new Joystick(1);
    Joystick rightStick = new Joystick(2);
    Relay firingMechanism;
    
    public void robotInit() {   
        firingMechanism = new Relay(1);
    }
    
    public void autonomous() {
        //not using autonomous atm
    }

    public void operatorControl() {
        while (true && isOperatorControl() && isEnabled()) // loop until change
        {
            drive.tankDrive(leftStick, rightStick); // drive w/ joysticks
            Timer.delay(0.005);
            System.out.println("Left: "+leftStick.getX()+", "+leftStick.getY());
            System.out.println("Right: "+rightStick.getX()+"' "+rightStick.getY());
            
            if(rightStick.getTrigger()){
                firingMechanism.set(Value.kReverse);
            }
            if(leftStick.getTrigger()){
                firingMechanism.set(Value.kForward);
            }
        }
    }
}
Currently everything works except driving. It reads the controller positions as well as pushes out relay commands (we can see blinks on the controller of red and green), however, the jaguar's are still not responding. Do they only work whenever watchdog is correctly configured? I can throw watchdog.setenabled(false) into robotInit.
Reply With Quote