How to Count Lines While Line Following

Поделиться
HTML-код
  • Опубликовано: 14 июл 2024
  • This video covers how to count intersections while line following. You could also adapt this to look for left and right turns by looking at specific IR sensors.
    Check out my PID video here: • How to Write a Simple ...
    Jump to three separate solutions:
    00:00 Intro
    06:42 Solution 1
    09:47 Solution 2
    14:07 Solution 3
  • НаукаНаука

Комментарии • 21

  • @capistor1
    @capistor1 4 года назад +1

    i have always used the delay thing.... never thought another solution existed.. great video im so excited that there is an actual arduino programming focused channel on RUclips... please keep uploading...

  • @azverndias913
    @azverndias913 Год назад +1

    This is way better then the delay solution that i came up with, thanks aot.

  • @CallousCoder
    @CallousCoder 3 года назад +2

    I personally used digital sensors for my sumobot and tide those to an interrupt. That way you don’t have to poll.
    You could do that here too, put the two pins in an AND and tie that to a pin and setup hardware interrupt.
    When you work with analogue you can of course use opamps as a window competitor and create a logic out.
    A line follower isn’t that demanding on reading many different environment factors. So your solutions will work.
    But when in sumo you are chasing a competitor and your following that and also have to read the edge sensors in a loop you can overshoot or undershoot it. And out of the ring means, losing the match. So the priority is basically handled by interrupts.

    • @RobotResearchLab
      @RobotResearchLab  2 года назад +1

      Yeah, there are a lot of variables when choosing how to approach a solution. In my case the focus is on reading the line so I don't mind that it constantly polls but yeah, if your focus is on another task then you'd want the line follow to not be the focus.
      The binary digital sensors do work for line follow but you get much smoother results having the range of reflectance values rather than just having two results (line or no line)
      Another major factor is the MCU speed, faster ones like the teensy are near instantaneous to read all line sensor values but Arduino Uno is much slower. 96-600 MHz vs 16 Mhz.
      Thanks for the input and thanks for watching.

    • @CallousCoder
      @CallousCoder 2 года назад +1

      @@RobotResearchLab definitely! For just line following polling is perfectly fine. I only used the digital sensor (actually last week in a one day scratch build and code - on my channel). I used the Pi3 and created my own lean library for reading it. And I was amazed how well the QTR8 digital works, i had expected a lot more “chatter” but it’s spot on.
      I actually found your awesome channel looking for otc line follower sensors. And I just bought the digital and the rest of the components I just collected from my junk pile stash.

  • @abhishankar9636
    @abhishankar9636 4 года назад

    I was looking for such a tutorial, thank you 💖

  • @rock1223
    @rock1223 4 года назад

    Always helpful video 🙃🙃🙃🙃🙏

  • @pocopoco3468
    @pocopoco3468 Год назад

    How to take acute angle turns?

  • @andhome9331
    @andhome9331 2 года назад +1

    How would you go about implementing code to detect a thick line vs a normal line? I only want to stop the robot when it detects a thick line (essentially two lines together)

    • @RobotResearchLab
      @RobotResearchLab  2 года назад +2

      That one can be simple or very complex depending on the accuracy you want. The problem is that speed has to be accounted for in order to get more accurate results.
      The most basic solution I would use is to have a boolean "flag" that gets set to true if over black or false if over white. Then, in that same code, when it's set to true (over black) record the current time, then when it gets set to false (over white) subtract the previously recorded time from the current time and have a threshold value if it's over a specific time. For example, if it takes 10 milliseconds on average to cross a single black line then maybe say, if it's over 15 milliseconds then we can assume it was two black lines.
      I know this is hard to explain over a comment but here's some pseudocode, feel free to ping me if you need more info on something or if you have some code started but need more help. I have a contact page where we can email back and forth robotresearchlab.com/contact-me/
      example with pseudocode:
      void detectLine() {
      // Are we over black or white?
      if over black AND isBlack == false {
      // set isBlack = true
      // Record current time in blackLineTime
      } else if not over black AND isBlack == true {
      // set isBlack = false
      // if currentTime - blackLineTime > singleBlackLineTime {
      // We passed over more than one black line
      }
      }
      }

  • @zulfarizyes8960
    @zulfarizyes8960 2 года назад +2

    Sir, can you make a tutorial of pathfinder/puzzle robot competition?

    • @RobotResearchLab
      @RobotResearchLab  2 года назад

      I will add this to my list, unfortunately I've been too busy to post a video for quite a while, I will try to get one up soon though.

  • @pengu176
    @pengu176 4 месяца назад

    my solution was to have a bool that is only true when all sensors are seeing a line and if it isnt it goes back to false and as long as the bool is true we dont check for intersections

  • @capistor1
    @capistor1 4 года назад

    Have you worked on android before? Could you make a video about two way communication between arduino and android using bluetooth and android studio? Nobody has a decent video on this.. would appreciate

    • @RobotResearchLab
      @RobotResearchLab  4 года назад

      Honestly, it's been years since I've worked with Android applications, I do frequently use bluetooth to transmit Arduino data to and from my phone using an app from the app store. That's a pretty simple project, just attach a bluetooth module to the Arduino circuit and then connect your phone to the module through a bluetooth streaming app. Does it have to be something like building your own Android app?

  • @reginn117
    @reginn117 3 года назад +1

    what if that line is white? can you help me please

    • @RobotResearchLab
      @RobotResearchLab  3 года назад +1

      Great question, the library handles this for you but it's defaulted to black. So, any time you call the readLine() function you'll have to explicitly provide values for the default values. Normally you would just pass sensorValues like this "readLine(sensorValues);" but instead you'll need to provide the values like this "readLine(sensorValues, QTR_EMITTERS_ON, true);"
      Because of the nature of default parameters, you need to provide all the default values up to the one you want to set so, QTR_EMITTERS_ON is just the default for what the LED mode should be, then the value "true" is setting the parameter for a white line, normally this value is "false" to indicate it's a black line so simply setting it to true will allow the same code to work for white lines instead of black lines.

    • @reginn117
      @reginn117 3 года назад

      @@RobotResearchLab I want to contact you. I still need some help can you help me to check my code? please.

    • @RobotResearchLab
      @RobotResearchLab  3 года назад

      @@reginn117 You could join my Slack group at www.robotresearchlab.slack.com and ask questions there, even paste your code in and I can take a look at it.

    • @CallousCoder
      @CallousCoder 3 года назад

      I actually hacked (from scratch parts and chassis done with styrene quick and dirty) ) my first line following today. And I coded my own motor class an qtr8 class.
      And what I do in that class is first count the number of bits set on the sensor.
      If it’s 1, I will just return the weighted value 1000-8000
      If it’s >1 and