View Single Post
  #2   Spotlight this post!  
Unread 04-12-2015, 20:46
GeeTwo's Avatar
GeeTwo GeeTwo is online now
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,654
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Spike Code Problems

Quote:
Originally Posted by simon1636 View Post
So I updated my code, but nothing seems to be happening! Here's the updated version:

Code:
.
.
.
    public void operatorControl() {

        while (isOperatorControl() && isEnabled()) {

            myDrive.mecanumDrive_Cartesian(moveStick.getY(), rotateStick.getX(), moveStick.getX(), 0);

            if (rotateStick.getTrigger(GenericHID.Hand.kLeft) && isEnabled()) {
                relay.set(Relay.Value.kOff);
                relay.setDirection(Relay.Direction.kForward);
            }

        }

        //mecanumDrive_Polar(moveStick.getY(), moveStick.getX(), rotateStick.getX());
        Timer.delay(0.1);
    }

}
.
.
.
I see two issues:
First, you called relay.set(Relay.Value.kOff); This essentially disables the relay; it won't let either the forward or re reverse direction be enabled. The relay.set is usually called in the initialize method, unless the way in which it operates changes for different parts of the program.

Second, you don't have any way to turn the relay off. The if statement that wraps the relay.setDirection() should have an else case that does this.

Further, this if statement probably doesn't need the isEnabled() as part of the condition, as it was checked just a few microseconds earlier at the top of the while loop.

Edit: One more thing - didn't you mean to include the delay within the loop?
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.

Last edited by GeeTwo : 04-12-2015 at 21:33.
Reply With Quote