Log in

View Full Version : Simple Pnuematics Program Issue


LFRobotics
21-01-2015, 16:54
Okay so I typed up a simple pnuematics program according to examples on WPILib to extend a cylinder for a second and then retract it.

Netbeans says that it "cannot find the symbol" when I say

solenoid1 = new DoubleSolenoid(1, 2);

It is referring to not being able to find the solenoid1

Here is the program:

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.wpilibj.Driver2015.commands;

import edu.wpi.first.wpilibj.DoubleSolenoid;

/**
*
* @author FrankyMonez
*/
public class Solenoid1 extends CommandBase {

public Solenoid1() {
// Use requires() here to declare subsystem dependencies
// eg. requires(chassis);
doubleSolenoid = new DoubleSolenoid(1, 2);
setTimeout(1);
}

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

// Called repeatedly when this Command is scheduled to run
protected void execute() {
doubleSolenoid.set(DoubleSolenoid.Value.kForward);
}

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

// Called once after isFinished returns true
protected void end() {
doubleSolenoid.set(DoubleSolenoid.Value.kReverse);
}

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

ANY help will be appreciated! THANKS!

notmattlythgoe
21-01-2015, 16:57
Are you getting an error saying doubleSolenoid doesn't exist?

GeeTwo
21-01-2015, 17:10
You never defined the object doubleSolenoid anywhere. You first used it inside the constructor, and then tried to use it in a method. You need to add the declaration of the object as an instance variable.

Try adding "DoubleSolenoid doubleSolenoid;" between the two lines which begin with public.