|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
|||
|
|||
|
Re: On Java an Line Sensing.
Quote:
|
|
#4
|
|||
|
|||
|
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.
|
|
#5
|
|||
|
|||
|
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 |
|
#6
|
||||
|
||||
|
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();
}
}
}
|
|
#7
|
|||
|
|||
|
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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|