|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Pneumatics Programming
Hello,
I was just adding the pneumatics code required, and being the rookie I am , I came up with an error. The thing is that I used the code from http://wpilib.screenstepslive.com/s/...for-pneumatics exactly(or so I think) and there seems to be an error. The error message is: Syntax error, insert "AssignmentOperator Expression" to complete Expression. I have posted the code below:Code:
package org.usfirst.frc.team4939.robot;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class Robot extends IterativeRobot {
RobotDrive myRobot;
Joystick stick;
int autoLoopCounter;
Victor victor;
Compressor c;
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {
myRobot = new RobotDrive(0,1,2,3);
stick = new Joystick(0);
victor = new Victor(4);
c = new Compressor(0);
c->SetClosedLoopControl(true); // THIS SEEMS TO BE THE PROBLEM
}
/**
* This function is run once each time the robot enters autonomous mode
*/
public void autonomousInit() {
autoLoopCounter = 0;
}
/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
if(autoLoopCounter < 100) //Check if we've completed 100 loops (approximately 2 seconds)
{
myRobot.drive(-0.5, 0.0); // drive forwards half speed
autoLoopCounter++;
} else {
myRobot.drive(0.0, 0.0); // stop robot
}
}
/**
* This function is called once each time the robot enters tele-operated mode
*/
public void teleopInit(){
}
/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
double rot = -stick.getX();
double speed = -stick.getY();
myRobot.arcadeDrive(speed,rot);
if(stick.getRawButton(3)){
victor.set(1);
}
else if(stick.getRawButton(2)){
victor.set(-1);
}
else{
victor.set(0);
}
ArmsDouble= new DoubleSolenoid(1, 2);
ArmsDouble= new DoubleSolenoid(1, 1, 2);
if(stick.getRawButton(4)){
ArmsDouble.set(DoubleSolenid.Value.kForward);
}
else if(stick.getRawButton(5)){
ArmsDouble.set(DoubleSolenoid.Value.kReverse);
}
}
/**
* This function is called periodically during test mode
*/
public void testPeriodic() {
LiveWindow.run();
}
}
|
|
#2
|
|||||
|
|||||
|
Re: Pneumatics Programming
Change this...
Code:
c->SetClosedLoopControl(true); Code:
c.setClosedLoopControl(true); ![]() Last edited by Oromus : 13-02-2015 at 10:36. |
|
#3
|
||||
|
||||
|
Re: Pneumatics Programming
As Oromus said, that example is in C++. All you're doing is calling a function -- inside the Compressor object there is a function called setClosedLoopControl that takes a boolean as an argument. In Java, that would be articulated as...
Code:
c.setClosedLoopControl(true); Code:
c->SetClosedLoopControl(true); that was a horrible example imsosorry |
|
#4
|
|||
|
|||
|
Re: Pneumatics Programming
Quote:
Quote:
Thank You, very much that seems to have fixed my problem. |
|
#5
|
|||
|
|||
|
Re: Pneumatics Programming
Code:
package org.usfirst.frc.team4939.robot;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class Robot extends IterativeRobot {
RobotDrive myRobot;
Joystick stick;
int autoLoopCounter;
Victor victor;
Compressor c;
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {
myRobot = new RobotDrive(0,1,2,3);
stick = new Joystick(0);
victor = new Victor(4);
}
/**
* This function is run once each time the robot enters autonomous mode
*/
public void autonomousInit() {
autoLoopCounter = 0;
}
/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
if(autoLoopCounter < 100) //Check if we've completed 100 loops (approximately 2 seconds)
{
myRobot.drive(-0.5, 0.0); // drive forwards half speed
autoLoopCounter++;
} else {
myRobot.drive(0.0, 0.0); // stop robot
}
}
/**
* This function is called once each time the robot enters tele-operated mode
*/
public void teleopInit(){
}
/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
double rot = -stick.getX();
double speed = -stick.getY();
myRobot.arcadeDrive(speed,rot);
if(stick.getRawButton(3)){
victor.set(1);
}
else if(stick.getRawButton(2)){
victor.set(-1);
}
else{
victor.set(0);
}
ArmsDouble= new DoubleSolenoid(1, 2); // THATS SEEMS TO BE THE PROBLEM
ArmsDouble= new DoubleSolenoid(1, 1, 2);// THAT SEEMS TO BE THE PROBLEM
if(stick.getRawButton(4)){
ArmsDouble.set(DoubleSolenoid.Value.kForward);
}
else if(stick.getRawButton(5)){
ArmsDouble.set(DoubleSolenoid.Value.kReverse);
}
}
/**
* This function is called periodically during test mode
*/
public void testPeriodic() {
LiveWindow.run();
}
}
The error code that shows up is: Multiple markers at this line - DoubleSolenoid cannot be resolved to a type - ArmsDouble cannot be resolved to a variable Thank You |
|
#6
|
|||
|
|||
|
Re: Pneumatics Programming
Quote:
Code:
DoubleSolenoid ArmsDouble; |
|
#7
|
|||||
|
|||||
|
Re: Pneumatics Programming
As Rakusan2 said, you need to declare ArmsDouble somewhere, i.e. "DoubleSolenoid ArmsDouble = new DoubleSolenoid(1, 2)". DoubleSolenoid not being able to resolved may be fixed by that as well.
|
|
#8
|
|||
|
|||
|
Re: Pneumatics Programming
Quote:
That's the impression this gave me: http://wpilib.screenstepslive.com/s/...ders-solenoids |
|
#9
|
|||
|
|||
|
Re: Pneumatics Programming
Quote:
|
|
#10
|
|||||
|
|||||
|
Re: Pneumatics Programming
That example was just showing the different ways you can initialize your DoubleSolenoid; you do one constructor or the other.
|
|
#11
|
|||
|
|||
|
DoubleSolenoid(in channel, out channel). Also, the compressor does not need to be instantiated. The compressor is on a closed loop controlled by the PCM. You just need to instantiate the DoubleSolenoid once, and and set the position on button values.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|