Go to Post I will read this blog, read your stories, learn from you, and be a better mentor because of you. You give me hope. Your diversity brings me joy. - Carolyn_Grace [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
  #1   Spotlight this post!  
Unread 20-01-2015, 18:29
michaelyork michaelyork is offline
Registered User
FRC #3680 (Elemental Dragons)
Team Role: Programmer
 
Join Date: Mar 2014
Rookie Year: 2014
Location: Statesville, NC, United States
Posts: 18
michaelyork is an unknown quantity at this point
Question Arm Issue

I have tried almost everything to fix this. I need some help.

Below is my OI code, and below that is my ArmClose code. My ArmOpen code is almost exactly the same as that, but the ArmClose code does not work.

Code:
package org.usfirst.frc3680.RecycleRush;

import org.usfirst.frc3680.RecycleRush.commands.*;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.*;
import edu.wpi.first.wpilibj.buttons.*;


/**
 * This class is the glue that binds the controls on the physical operator
 * interface to the commands and command groups that allow control of the robot.
 */
public class OI {
    //// CREATING BUTTONS
    // One type of button is a joystick button which is any button on a joystick.
    // You create one by telling it which joystick it's on and which button
    // number it is.
    // Joystick stick = new Joystick(port);
    // Button button = new JoystickButton(stick, buttonNumber);
    
    // There are a few additional built in buttons you can use. Additionally,
    // by subclassing Button you can create custom triggers and bind those to
    // commands the same as any other Button.
    
    //// TRIGGERING COMMANDS WITH BUTTONS
    // Once you have a button, it's trivial to bind it to a button in one of
    // three ways:
    
    // Start the command when the button is pressed and let it run the command
    // until it is finished as determined by it's isFinished method.
    // button.whenPressed(new ExampleCommand());
    
    // Run the command while the button is being held down and interrupt it once
    // the button is released.
    // button.whileHeld(new ExampleCommand());
    
    // Start the command when the button is released  and let it run the command
    // until it is finished as determined by it's isFinished method.
    // button.whenReleased(new ExampleCommand());

    
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
    public JoystickButton button10;
    public JoystickButton button11;
    public JoystickButton button6;
    public JoystickButton button7;
    public Joystick joystick1;
    public Joystick joystick2;

    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS

    public OI() {
        // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS

        joystick2 = new Joystick(1);
        
        joystick1 = new Joystick(0);
        
        button6 = new JoystickButton(joystick1, 6);
        button6.whenPressed(new ArmOpen());
        button7 = new JoystickButton(joystick1, 7);
        button7.whenPressed(new ArmClose());
        button11 = new JoystickButton(joystick1, 11);
        button11.whenPressed(new ArmUp());
        button10 = new JoystickButton(joystick1, 10);
        button10.whenPressed(new ArmDown());

	    
        // SmartDashboard Buttons
        SmartDashboard.putData("ArmUp", new ArmUp());

        SmartDashboard.putData("ArmDown", new ArmDown());

        SmartDashboard.putData("Autonomous Command", new AutonomousCommand());

        SmartDashboard.putData("ArmOpen", new ArmOpen());

        SmartDashboard.putData("ArmClose", new ArmClose());
        

    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    }
    
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=FUNCTIONS
    public Joystick getJoystick1() {
        return joystick1;
    }

    public Joystick getJoystick2() {
        return joystick2;
    }


    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=FUNCTIONS
}
Code:
package org.usfirst.frc3680.RecycleRush.commands;

import edu.wpi.first.wpilibj.command.Command;

import org.usfirst.frc3680.RecycleRush.Robot;
import org.usfirst.frc3680.RecycleRush.RobotMap;

import edu.wpi.first.wpilibj.*;


/**
 *
 */
public class  ArmClose extends Command {

    public ArmClose() {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);

        // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES
        requires(Robot.armOpenClose);

    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES
    }

    // Called just before this Command runs the first time
    protected void initialize() {
        Robot.armOpenClose.initializeCounter();
    	
    	Robot.armOpenClose.armClose();
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
    	
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        
        return Robot.armOpenClose.isSwitch1Set();
    }

    // Called once after isFinished returns true
    protected void end() {
    	Robot.armOpenClose.armStop();
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    	end();
    }
}
Help?

Last edited by michaelyork : 20-01-2015 at 18:57. Reason: mistake
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 11: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