View Full Version : Programming the teleop
Twisted eric
15-02-2010, 17:47
My programming team are stuck
like the title says I'm tying to program I don't know what I'm missing
code
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Watchdog;
public class Demonized extends SimpleRobot {
RobotDrive drive = new RobotDrive(1, 2);
Joystick leftStick = new Joystick(1);
Joystick rightStick = new Joystick(2);
Watchdog Fenrir = Watchdog.getInstance();
public void autonomous() {
while(true && isAutonomous() && isEnabled())
for (int i = 0; i < 4; i++) {
Fenrir.feed();
drive.drive(0.5, 0.0); // drive 50% fwd 0% turn
Fenrir.feed();
drive.drive(0.0, 0.5);
}
drive.drive(0.0, 0.0); // drive 0% fwd, 0% turn
}
public void operatorControl() {
while (true && isOperatorControl() && isEnabled()) // loop until change
{
drive.tankDrive(leftStick, rightStick);
Timer.delay(0.005);
Fenrir.feed();
}
}
}
help will be much appreciated
team 581
BradAMiller
16-02-2010, 16:04
You need to "feed" the watchdog timer in the operatorControl() method. I'm not sure if that's what you're seeing, but I would expect that you are getting a "Watchdog not fed" message on the driver station.
Insert a Fenrir.feed() in the loop with the drive.tankDrive() call.
Twisted eric
16-02-2010, 17:26
Thank you that was what i was missing any help with the pneumatic compressor.
Twisted eric
16-02-2010, 18:18
code
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Watchdog;
import edu.wpi.first.wpilibj.Compressor;
public class Demonized extends SimpleRobot {
RobotDrive drive = new RobotDrive(1, 2);
Joystick leftStick = new Joystick(1);
Joystick rightStick = new Joystick(2);
Watchdog Fenrir = Watchdog.getInstance();
Compressor Siberian = new Compressor(1,1);
public void autonomous() {
while(true && isAutonomous() && isEnabled())
for (int i = 0; i < 4; i++) {
Fenrir.feed();
drive.drive(0.5, 0.0); // drive 50% fwd 0% turn
Fenrir.feed();
drive.drive(0.0, 0.5);
}
drive.drive(0.0, 0.0); // drive 0% fwd, 0% turn
}
public void operatorControl() {
while (true && isOperatorControl() && isEnabled()) // loop until change
{
drive.tankDrive(leftStick, rightStick);
Timer.delay(0.005);
Fenrir.feed();
}
}
}
new code update
Robototes2412
16-02-2010, 18:36
add a Siberian.start() to the outside of your while loop
Twisted eric
16-02-2010, 18:53
add a Siberian.start() to the outside of your while loop
which wiled loop auto or tele op
OH
and can everyone help with sensing pressure and every thing first time using java.
Robototes2412
16-02-2010, 18:57
i reccomend you make a setupRobot method for stuff like that.
insert the following inbetween the autonomous and teleop code
void setUpRobot() {
Siberian.start();
Fernir.feed();
}
then just add setUpRobot(); to your teleop and autonomous code.
That should fix it :D
Twisted eric
16-02-2010, 19:10
i reccomend you make a setupRobot method for stuff like that.
insert the following inbetween the autonomous and teleop code
void setUpRobot() {
Siberian.start();
Fernir.feed();
}
then just add setUpRobot(); to your teleop and autonomous code.
That should fix it :D
Thanks
do you know how to sense pressure value and auto shut off
Thanks in advance and sorry for so-many questions.
Robototes2412
16-02-2010, 20:11
Dude, its ok, i had the same questions.
it will automatically shut off as long as the wiring is correct (check the diagrams), so programming can now rest easy. :D
Twisted eric
16-02-2010, 20:48
Dude, its ok, i had the same questions.
it will automatically shut off as long as the wiring is correct (check the diagrams), so programming can now rest easy. :D
in the pneumatics manual here (http://www.usfirst.org/uploadedFiles/Community/FRC/Game_and_Season__Info/2010_Assets/2010%20Pneumatics%20Manual%20Rev%20-.pdf)
says that there is no default program in the cRIO to control
the compressor power.
Robototes2412
16-02-2010, 21:48
in the pneumatics manual here (http://www.usfirst.org/uploadedFiles/Community/FRC/Game_and_Season__Info/2010_Assets/2010%20Pneumatics%20Manual%20Rev%20-.pdf)
says that there is no default program in the cRIO to control
the compressor power.
its always worked for us
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.