Go to Post I know what you mean, but swerve drive is NEVER necessary. - Cory [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 02-20-2016, 04:58 PM
grimmsterj grimmsterj is offline
Registered User
FRC #4203 (Robokronos)
Team Role: Leadership
 
Join Date: Nov 2013
Rookie Year: 2013
Location: New York
Posts: 7
grimmsterj is an unknown quantity at this point
Exclamation URGENT: Command-Based Program Not Working

Hello everyone, a teammate and I (who didnt learn any sort of programming until the beginning of build season, and are extremely inexperienced) had our command-based program working fine. We had pistons opening/closing, a CAN Network working well and running several motors, and basically had our robot working fine. However, after seemingly no code changes.. we can no longer get any commands to run no matter what. We've tried everything and we are getting no errors.. but commands wont run when we enable our bot. We ran a separate project that was command-based and it worked fine (it just ran a relay). However, I believe we are doing everything the same so it isn't making much sense. We looked through all of the initialization, as I assume that must be the issue but I can't find anything. Posted below is our robot.java, oi, and one basic subsystem and command.

Code:
public class Robot extends IterativeRobot {

    Command autonomousCommand,intakeRun;

    public static OI oi;
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
    public static final DriveTrain driveTrain = new DriveTrain();
    public static final Intake intake = new Intake();
    public static final IntakePiston intakePiston = new IntakePiston();
    public static final Shooter shooter = new Shooter();
    public static final Aimer aimer = new Aimer();

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

    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public void robotInit() {
          // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
        oi = new OI(); 
    }

    /**
     * This function is called when the disabled button is hit.
     * You can use it to reset subsystems before shutting down.
     */
    public void disabledInit(){

    }

    public void disabledPeriodic() {
        Scheduler.getInstance().run();
    }

    public void autonomousInit() {
        // schedule the autonomous command (example)
        if (autonomousCommand != null) autonomousCommand.start();
    }

    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {
        Scheduler.getInstance().run();
    }

    public void teleopInit() {
    	aimer.setDefault();
        // This makes sure that the autonomous stops running when
        // teleop starts running. If you want the autonomous to
        // continue until interrupted by another command, remove
        // this line or comment it out.
        if (autonomousCommand != null) autonomousCommand.cancel();
    }

    /**
     * This function is called periodically during operator control
     */
    public void teleopPeriodic() {
    	Scheduler.getInstance().run();
    }

    /**
     * This function is called periodically during test mode
     */
    
   
    public void testPeriodic() {
        LiveWindow.run();
    }
}
Code:
package org.usfirst.frc4203.Stronghold;

import org.usfirst.frc4203.Stronghold.commands.*;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.buttons.JoystickButton;

/**
 * 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 {
	
	
    //Controllers
	private Joystick driveStick;
	public static Joystick xboxController;
	
	//Buttons
	public static JoystickButton intakeOnButton;
	public static JoystickButton lowGoalButton;
	public JoystickButton gyroResetButton;
	public static JoystickButton intakePositionButton;
	public static JoystickButton aimPositionButton;
	public static JoystickButton shootButton;
	public static JoystickButton loadButton;
	public static JoystickButton setPrecisionDrive;
	public static JoystickButton cancelPrecisionDrive;
	public static JoystickButton raiseIntakeButton;
	public static JoystickButton lowerIntakeButton; 
	public static JoystickButton fireButton;
   
	
	
    	public OI() {
			driveStick = new Joystick(1);
	    	xboxController = new Joystick(2);
	    	lowerIntakeButton = new JoystickButton(xboxController,RobotMap.L3);
	    	raiseIntakeButton = new JoystickButton(xboxController,RobotMap.R3);
	    	lowGoalButton = new JoystickButton(xboxController,RobotMap.A);
	    	//intakeOnButton = new JoystickButton(xboxController,RobotMap.X);
	    	loadButton = new JoystickButton(xboxController,RobotMap.B);
	    	shootButton = new JoystickButton(xboxController,RobotMap.Y);
	    	setPrecisionDrive = new JoystickButton(xboxController, RobotMap.LB);
	    	cancelPrecisionDrive = new JoystickButton(xboxController, RobotMap.RB); 
    		//fireButton.whenPressed(new Fire());
      		//loadButton.whenPressed(new LoadShooter());
      		//intakeOnButton.whenPressed(new IntakeRun());
	    	//Buttons
    	}
    	
	
		
	
	public Joystick getDriveStick(){
		return driveStick;
	}
    public Joystick getXboxController(){
    	return xboxController;
    }
}
Code:
package org.usfirst.frc4203.Stronghold.subsystems;

import org.usfirst.frc4203.Stronghold.RobotMap;
import org.usfirst.frc4203.Stronghold.commands.IntakeRun;

import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
import edu.wpi.first.wpilibj.command.Subsystem;


/**
 *
 */
public class Intake extends Subsystem {
	

    private final Relay motor = new Relay(RobotMap.intakeIntakeMotor);

    
    public void intakeToggleRun(JoystickButton button){
    	
    	if(button.get()==true){
    		
    		motor.set(Relay.Value.kForward);
    	
    	}
    	
    	else if(button.get()==false){
    		
    		motor.set(Relay.Value.kOff);
    		
    	}
    	
    }
    
    public void intake(){
    	
    	motor.set(Relay.Value.kForward);
    	
    }
    
    public void release(){
    	motor.set(Relay.Value.kReverse);
    }
    
    public void stop(){
    	
    	motor.set(Relay.Value.kOff);
    	
    }

	protected void initDefaultCommand() {
		setDefaultCommand(new IntakeRun());
	}

    
}
Code:
package org.usfirst.frc4203.Stronghold.commands;

import org.usfirst.frc4203.Stronghold.OI;
import org.usfirst.frc4203.Stronghold.Robot;
import org.usfirst.frc4203.Stronghold.RobotMap;

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

/**
 *
 */
public class IntakeRun extends Command {

    public IntakeRun() {
    	requires(Robot.intake);
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
    }

    // Called just before this Command runs the first time
    protected void initialize() {
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
    	Robot.intake.release();
    	/*if(OI.xboxController.getRawButton(RobotMap.X)){
    	Robot.intake.intake();
    	}
    	
    	if(OI.xboxController.getRawButton(RobotMap.A)){
    		Robot.intake.release();
    	}
    	*/
    }

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

    // Called once after isFinished returns true
    protected void end() {
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }
}
Reply With Quote
  #2   Spotlight this post!  
Unread 02-20-2016, 07:02 PM
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: URGENT: Command-Based Program Not Working

well.. yeah... you commented out your actions code.

Code:
	
    	public OI() {
	...
    		//fireButton.whenPressed(new Fire());
      		//loadButton.whenPressed(new LoadShooter());
      		//intakeOnButton.whenPressed(new IntakeRun());
	    	//Buttons
    	}
__________________
FRC Team 1684 - Head Programmer (2013-2016)
FRC Team 5460 - Programming Mentor (2015-2016)

FIRST in Michigan - Technical Crew (2015-continuing)
Reply With Quote
  #3   Spotlight this post!  
Unread 02-20-2016, 07:14 PM
grimmsterj grimmsterj is offline
Registered User
FRC #4203 (Robokronos)
Team Role: Leadership
 
Join Date: Nov 2013
Rookie Year: 2013
Location: New York
Posts: 7
grimmsterj is an unknown quantity at this point
Re: URGENT: Command-Based Program Not Working

Right well we commented that our as the buttons did nothing... so we attempted to use the setDefaultCommand in the intake subsystem but that didn't work either
Reply With Quote
  #4   Spotlight this post!  
Unread 02-20-2016, 07:19 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,999
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: URGENT: Command-Based Program Not Working


Just re-load the last known working version of your code into the robot.

If it works, you made a code change which broke the software.

Just do a file-by-file comparison to identify the changes you made, then start adding the changes back in one at a time until the code breaks again.



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 08:58 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