Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Pneumatics with command based programming (http://www.chiefdelphi.com/forums/showthread.php?t=152099)

Yildirim 10-28-2016 05:46 PM

Pneumatics with command based programming
 
Hello everyone I am from team 6429 this is our forst year in FRC and I am the programmer I am doing command based programming it was going well until the pneumatics showed their faces to me I do not know how to control pneumatics (single solenoid) on command based programming. I have short time to finish program so I need a quick help pls. Also I am using java.

GoldenGollem 10-28-2016 08:59 PM

Re: Pneumatics with command based programming
 
Do you have some of the code to post or any snipbit of it to show.

Penchant 10-28-2016 11:02 PM

Re: Pneumatics with command based programming
 
WPI Screensteps is very helpful for things like this, including their page on solenoids here.

Yildirim 10-29-2016 04:43 AM

Re: Pneumatics with command based programming
 
Quote:

Originally Posted by GoldenGollem (Post 1614084)
Do you have some of the code to post or any snipbit of it to show.

This is my subsystem's "wrist" code:
package org.usfirst.frc123.pnmatik.subsystems;

import org.usfirst.frc123.pnmatik.RobotMap;
import org.usfirst.frc123.pnmatik.commands.*;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Solenoid;

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


/**
*
*/
public class Wrist extends Subsystem {

// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTANTS

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

// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATİONS
private final Compressor compressor1 = RobotMap.wristCompressor1;
private final Solenoid solenoid1 = RobotMap.wristSolenoid1;

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATİONS


// Put methods for controlling this subsystem
// here. Call these from Commands.

public Compressor getCompressor1() {
return compressor1;
}

public Solenoid getSolenoid1() {
return solenoid1;
}

public void initDefaultCommand() {
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DEFAULT_COMMAND


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

// Set the default command for a subsystem here.
// setDefaultCommand(new MySpecialCommand());
}
}


And this is the command's "Raise Wrist" code:

// RobotBuilder Version: 2.0
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// Java from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in the future.


package org.usfirst.frc123.pnmatik.commands;

import edu.wpi.first.wpilibj.command.Command;
import org.usfirst.frc123.pnmatik.Robot;

/**
*
*/
public class RaiseWrist extends Command {

// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARİABLE_DECLARATİONS

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARİABLE_DECLARATİONS

// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTOR
public RaiseWrist() {

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTOR
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARİABLE_SETTİNG

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARİABLE_SETTİNG
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUİRES
requires(Robot.wrist);

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUİRES
}

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

}

// 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 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() {

}
}

So what am i going to write and where (I think I should write the code to the execute in command) and am I need to write something t o subsytems actually I have no idea about pneumatics on command based programing as I said .

Thanks for your helps.

bankst 10-29-2016 07:05 PM

Re: Pneumatics with command based programming
 
Going off the assumption you are using a Single solenoid (rather than a double), here is what I would put in 'execute':
Code:

RobotMap.wristSolenoid1.set(true); // open solenoid
And in the 'end' function:
Code:

RobotMap.wristSolenoid1.set(false); // close solenoid
Also make sure in the 'interrupted' function you put:
Code:

end(); // close solenoid if command is interrupted
If you have any more questions about command-based programming let me know and I'd be more than happy to help. :]

Yildirim 10-30-2016 05:54 AM

Re: Pneumatics with command based programming
 
Quote:

Originally Posted by bankst (Post 1614163)
Going off the assumption you are using a Single solenoid (rather than a double), here is what I would put in 'execute':
Code:

RobotMap.wristSolenoid1.set(true); // open solenoid
And in the 'end' function:
Code:

RobotMap.wristSolenoid1.set(false); // close solenoid
Also make sure in the 'interrupted' function you put:
Code:

end(); // close solenoid if command is interrupted
If you have any more questions about command-based programming let me know and I'd be more than happy to help. :]

Thank you very very much :)


All times are GMT -5. The time now is 08:22 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi