Go to Post We are all just pawns in FIRST's quest for global domination. - Tom Bottiglieri [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-01-2011, 02:25
james7132
 
Posts: n/a
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?
Reply With Quote
  #2   Spotlight this post!  
Unread 15-01-2011, 02:57
Patrick Chiang Patrick Chiang is offline
Programming
FRC #3070 (Team Pronto)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Seattle
Posts: 162
Patrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to all
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.
Reply With Quote
  #3   Spotlight this post!  
Unread 15-01-2011, 12:20
bakketti bakketti is offline
Registered User
FRC #0443 (Freelance Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Denver, Co
Posts: 18
bakketti is an unknown quantity at this point
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.
Reply With Quote
  #4   Spotlight this post!  
Unread 05-02-2011, 09:25
1chess2u 1chess2u is offline
Registered User
FRC #2771
 
Join Date: Jan 2011
Location: Wyoming, M!
Posts: 3
1chess2u is an unknown quantity at this point
Re: On Java an Line Sensing.

Quote:
Originally Posted by Patrick Chiang View Post
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?
Reply With Quote
  #5   Spotlight this post!  
Unread 05-02-2011, 12:06
bakketti bakketti is offline
Registered User
FRC #0443 (Freelance Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Denver, Co
Posts: 18
bakketti is an unknown quantity at this point
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.
Reply With Quote
  #6   Spotlight this post!  
Unread 10-02-2011, 13:19
pigpc1993 pigpc1993 is offline
Registered User
AKA: Colin Feeney
FRC #3716 (WARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2009
Location: Manhasset, NY
Posts: 41
pigpc1993 is an unknown quantity at this point
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
Reply With Quote
  #7   Spotlight this post!  
Unread 10-02-2011, 13:47
Robototes2412's Avatar
Robototes2412 Robototes2412 is offline
1 * 4 != 14
FRC #2412 (Robototes)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Bellevue
Posts: 312
Robototes2412 is on a distinguished road
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
Reply With Quote
  #8   Spotlight this post!  
Unread 10-02-2011, 22:05
pigpc1993 pigpc1993 is offline
Registered User
AKA: Colin Feeney
FRC #3716 (WARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2009
Location: Manhasset, NY
Posts: 41
pigpc1993 is an unknown quantity at this point
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.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:34.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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