Line tracker Sensor 2019?

Trying to find a sensor to use to track the alignment lines on the field and only pulling up 2007? posts. Has anybody tried tracking the white lines on the floor, and what sensors did you use?

1 Like

Pixy2 has line following capabilities as well as color sensing. My team is looking into using it.

1 Like

Bannet might have some line sensors. You may be better off imementing line finding in open cv with a camera.

Normally, our team uses VEX Line Followers. I don’t know if there is a specific line follower to use, and I can’t find anything else off the top of my head.

In 2011 many teams did line tracking with the three photo sensors included in the KOP, which (according to this post) were Allen-Bradley 42EF-D1MNAK-A2 sensors.

Here is a very similar option in FIRST Choice, donated by Rockwell Automation (who own Allen-Bradley.)

2 Likes

I can’t find any resources that point to how to wire any of these photo sensors to the roborio and then further more to read the values in code. Can anyone point to a tutorial or something of that nature? Even better if it’s specific to the Rockwell Automation version from First Choice. Thanks.

They are simple to use. They are an open or closed circuit that you can hook up to your DIO. Their sensitivity is adjustable via s small plastic screw on the sensor.

Rev sells one too

I can confirm this. I found our sitting in a box on Saturday. They worked very well for us in 2011!

1 Like

Thanks for this. Do you know if Limelight also can do line tracking? I was not aware it worked with sensing nonreflective tape

I haven’t used it, but I did identify this low cost sensor which should be good at finding a 2" wide white line from 2" off the carpet. I would likely only use every third sensor, at least toward the edges to keep down the number of DIO ports required, or feed these sensors to an arduino or similar and just send a “summary” report to the RIO about ten to a hundred times a second.
Oops: https://www.pololu.com/product/4356

I think you lost a link in this post. I’m guessing you’re referring to something like the Pololu QTR reflectance sensor arrays?

Look at using 3 line sensors. This exact thing was a challenge for autonomous in 2011.

https://www.chiefdelphi.com/search?expanded=true&q=before%3A2012-01-01%20line%20follow%20track

also see: Lining up with tape on ground for new game?

Provided you have sensor layout as follows (where the "o"s represent sensors in the direction of travel):

------------------------------------
|            o | o | o              |
|                                   |

To get to follow line (provided line is activating ANY sensor, sensors need to be suitably close together):

  1. Read sensor values in as a binary number from left to right (i.e. the leftmost sensor is in the “hundreds place”, middle in the “tenths place” rightmost in the “ones place” )
  2. Pipe that binary number into a switch/case statement
  3. a) If output of binary is [100] speed up right side of drivetrain slightly, if binary is [010] drive train as normal, If output of binary is [001] speed up left side of drivetrain slightly, if binary is [000] or [111] stop robot (off of line completely or sideways to line), if binary is [101] stop robot (erroneous input)

In pseudo code:

    array line = new array[3]
    while (alignButton.state()) {
        int leftDriveAccumulator = *left forward input*     // you will want these inputs to be as equal as possible
        int rightDriveAccumulator = *right forward input*
        line[0] = lineLeftSensor.get()
        line[1] = lineMiddleSensor.get()
        line[2] = lineRightSensor.get()
        switch(arrayToBinaryNumber(line)){
            case 100:
                leftDriveAccumulator += .10
               // robot needs slight right turn
            case 110:
                leftDriveAccumulator += .05
               // robot needs very slight right turn
            case 001:
                rightDriveAccumulator += .10
               // robot needs slight left turn
            case 011:
                rightDriveAccumulator += .05
               // robot needs very slight left turn
            case 010:
                // robot is straight
            case 000:
                leftDriveAccumulator *= 0
                rightDriveAccumulator *= 0
               // robot is not sensing a line to follow, stop machine
            case 111:
                leftDriveAccumulator *= 0
                rightDriveAccumulator *= 0
               // robot is sensing a line sideways, stop machine
            case 101:
                leftDriveAccumulator *= 0
                rightDriveAccumulator *= 0
               // robot is sensing erroneous input, stop machine
           }
    drive.tankdrive(leftDriveAccumulator,rightDriveAccumulator)
    }
1 Like

So in theory this works for as many sensors as you want. If a team wants to line a whole side of the bot with 5 or 7 sensors they don’t really need any human driver accuracy in getting to target once they see the line.

1 Like

Yes. However once you get past 5 sensors I would look for a more elegant solution to convert the input binary to a robot correction. That switch/case structure would get out of control real fast, with 64 combinations on a 6 sensor setup (albiet a fair number of them erroneous).

Also remember the more sensors you have the higher the chance for a false reading, you will want to be careful in your code to quickly get the robot centered with all the sensors, then figure out what you want to do if one on the extreme edge gets a positive reading while you know the robot is centered. I suggest “turning off” all but the middle 6" of sensor coverage (use the middle group of sensors covering ~3x line width only).

Another possibility is to use a “multi-aperture” technique. On approach, use the outer edges and center sensor. After you’re roughed in, sample sensors closer to the center to improve precision.

A couple of things to note:

  • A 2" wide line appears almost 3" wide if you’re intersecting it at a 45 degree angle, and 4" at 60 degrees off.
  • Tracking the 18" of line will likely NOT be long enough to get you square with the face of the port by itself.
1 Like

Dropping this in here:

1 Like

Automation direct has a good video on the different types of photoelectric sensors.

For line detection your generally looking for a diffuse reflection sensor. You adjust the pot on it till it “sees” the white tape and ignores the grey carpet. The same sensor can be used to detect objects like balls in your intake by adjusting it’s sensitivity or setting it closer to the object.
Because there are so many different types of photoelectric sensors and the same ones can be used in different ways is confusing for newbies.
As for wiring them, all I can do is talk generally. But generally you have a power in, ground and a signal line. The sensor at FirstChoice is a PNP sensor so if you have a choice you will want a PNP sensor. You can hook it to the signal in line on the DIO ports of the Roborio.
The power in can be 3.3, 5 , 12, 24 or more volts. As far as I know we can only use 3.3, 5 and 12 volts. We don’t have a 24v or higher supply on the robot. There is a 3.3 volt supply on the MXP port but I don’t know about using it for this. So that leaves 5v and 12v which ate the most common ones anyway. The 5v is right on the DIO pins that your already hooking to. So a 3 pin PWM style connector and your done. If you need 12 volts, use the 500ma output on the VRM Voltage Regulator Module. This is preferred over the battery lines because it is protected from sagging as your voltage goes down. The other regulated 12V sources are for other stuff and we are not allowed by rule to use them.
If your sensor has more than 3 wires the additional ones might be NPN or serial or something else that you can ignore, Just don’t let them short to anything.
The sensors can cost from $3 to $100. I can post more on what I know about the differences if there is interest.

3 Likes

I also remember using these sensors in 2011 but this year the models are
Allen Bradley 42EF-D2MPAK-F4 found in our KOP

The suppy is 10-30VDC and they are PNP which means if you power them with 12VDC when the output turns on it will deliver 12VDC to the DIO of the robo RIO.

I am unable to find what the max input value to the roboRIO is and I have posted a question on the NI Fourms asking for the information.

Back in 2011 we were using cRIOs which may have been able to handle the 12VDC input through the side car but I also remember having to create a circuit to drop the voltage from 12 to 5VDc (Not sure I needed to)

1 Like

I misread the roboRIO manual and NI has confirmed that the max voltage you can put on the DIO signal pin is 5.25VDC. So before you use these sensors with a digital input pin you will need to reduce the voltage output of the sensor from 12 to 5VDC.