View Single Post
  #5   Spotlight this post!  
Unread 05-02-2012, 10:09
loafdog loafdog is offline
Registered User
AKA: Maciej
FRC #2876 (DevilBotz)
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2009
Location: Burlington, MA
Posts: 37
loafdog is on a distinguished road
Re: Wiring the photosensors (Rockwell)

I don't think the code you have written will work the way you want. The photo sensors are only read once when OI class is created. Is that what you intended? Or did you want the sensors being read during the entire time the robot is operated? I'm going to assume the latter is what you want.

In your main robot class find teleopPeriodic function. In there put calls to read the photo sensors and if all 3 are true start your command. You can do something similar for autonomousPeriodic if you want your command to run in autonomous mode. The *Periodic funcs get called repeatedly while the robot is running. I didn't test this code. You might want to post further programming questions on the Java section of the forum.

Code:
public class YourRobotClass {
    DigitalInput camera1, camera2, camera3;
    public YourRobotClass() {
	camera1 = new DigitalInput(1);
	camera2 = new DigitalInput(2);
	camera3 = new DigitalInput(3);
    }
    public void teleopPeriodic() {
        Scheduler.getInstance().run();

	boolean C1 = camera1.get();
	boolean C2 = camera2.get();
	boolean C3 = camera3.get();
        if (C1 && C2 && C3) {
          Command c = new ThreeCameras();
          c.start();
	}
	SmartDashboard.putBoolean("c1", C1);
	SmartDashboard.putBoolean("c2", C2);
	SmartDashboard.putBoolean("c3", C3);
    }
}
Have you read this doc? I found a hint for what you wanted to do on pages 31-36. The examples are in C++ but same thing applies for Java.
http://firstforge.wpi.edu/sf/docman/..._documentation

Have you seen the youtube videos about using CommandBased templates?
http://www.youtube.com/user/BradAMiller/videos

In the example projects in Netbeans you can open GearsBot sample and see lots of examples of a what a CommandBased robot can do.

Have you also checked that you are getting signals when an object you want to detect is passed in front of the sensors? Not sure if you are using the same model as last year, but those had led lights that changed color to indicate if the sensor was detecting anything or not. And they had to be calibrated.

-Maciej