Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   On Java an Line Sensing. (http://www.chiefdelphi.com/forums/showthread.php?t=89181)

james7132 15-01-2011 02:25

On Java an Line Sensing.
 
I don't know if I'm missing the obvious or not, but I can't seem to find a way to implement one of those three line sensors within our robot's program. Anyone tried this out yet?

Patrick Chiang 15-01-2011 02:57

Re: On Java an Line Sensing.
 
If the example code they gave us is correct, they're just 3 digital inputs. You place them next to each other and determine which once have "input". If it's showing true, then it you basically assume that the line is under that particular sensor. Using this information, you can determine whether the line is on your left, your right, or if you're right on it.

However, you might want to wait for someone who's actually tried them out to give you an expert opinion. I don't even know what they look like this year because we've been busy designing all week.

bakketti 15-01-2011 12:20

Re: On Java an Line Sensing.
 
We got line tracking up and running last night. We didn't use the line tracker example in Netbeans but our code is similar. You pretty much need to access the three digital inputs with the DigitalInput get() method. Just like the example.

1chess2u 05-02-2011 09:25

Re: On Java an Line Sensing.
 
Quote:

Originally Posted by Patrick Chiang (Post 1000513)
If the example code they gave us is correct, they're just 3 digital inputs. You place them next to each other and determine which once have "input". If it's showing true, then it you basically assume that the line is under that particular sensor. Using this information, you can determine whether the line is on your left, your right, or if you're right on it.

However, you might want to wait for someone who's actually tried them out to give you an expert opinion. I don't even know what they look like this year because we've been busy designing all week.

Where is this code?

bakketti 05-02-2011 12:06

Re: On Java an Line Sensing.
 
Its a little tricky. Start a new project and find the "Samples" folder. In this folder you will see a "FRC Java" folder. The line tracking sample is in there.

pigpc1993 10-02-2011 13:19

Re: On Java an Line Sensing.
 
My team has got our code working. If you guys need help drop us an email.
wasatchrobotics@gmail.com

Robototes2412 10-02-2011 13:47

Re: On Java an Line Sensing.
 
Here's my line sensing code:

Code:

package com.robototes.abomasnow;

import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;

public class Main extends SimpleRobot {
    Driver robot = new Driver(1,2);
    LineSensorGroup lsg  = new LineSensorGroup(1,2,3);
   
    final int middle = 2;
    final int left = 1;
    final int right = 3;

    public void autonomous() {
        getWatchdog().feed();
       
        int last = middle;  //last line sensor value
        while(this.isEnabled() && this.isAutonomous()) {
            if(lsg.getMiddle()) {
                last = middle;
            } if (lsg.getLeft()) {
                last = left;
            } if (lsg.getRight()) {
                last = right;
            }

            if (lsg.allAreOff()) {
                if (last == left) {
                    robot.arcadeDrive(0.4, 0.1);  //Forward and right*/
                    System.out.println("Left");
                } else if (last == middle) {
                    robot.arcadeDrive(0.5, 0);    /* Straight forward */
                    System.out.println("Forward");
                } else if (last == right) {
                    robot.arcadeDrive(0.4, -0.1);  /* forward and left */
                    System.out.println("Right");
                }
            }

            if (lsg.allAreOn()) {
                if (last == middle) {
                    robot.stop();
                    System.out.println("Stopping");
                    break;
                }
            }
            Timer.delay(0.05);
            this.getWatchdog().feed();
        }
    }
}

Driver is my own motor group controller, RobotDrive was too heavy for me

pigpc1993 10-02-2011 22:05

Re: On Java an Line Sensing.
 
If you want some additional help read this.

http://decibel.ni.com/content/servle...20Tutorial.pdf

It talks about labview but it can really be applied to any language. A digital input, which the photoswitch is, returns either a true or false depending up what it is calibrated too. True if its the line, false if it isn't.


All times are GMT -5. The time now is 10:51.

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