Announcement

Collapse
No announcement yet.

Line Following inside a program?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Line Following inside a program?

    Hello I have a question,

    In the past i wrote a line following program with PID (with some help) and it works really good

    Now i want to start programming for a competition. i started with 2 motor blocks at the beginning
    And then the roboter should follow the line (first he calibrates).
    But this doesn't work and i don't know why

    When i put a motor block infront of the linefollowing myblock he drives forward but then the calibration doesn't work.
    But without a motor block infront, it works.

    Can you say me what i have done wrong?

    I hope you can understand my problem because i am german

  • #2
    Re: Line Following inside a program?

    Originally posted by AngyLPer View Post
    Hello I have a question,

    In the past i wrote a line following program with PID (with some help) and it works really good

    Now i want to start programming for a competition. i started with 2 motor blocks at the beginning
    And then the roboter should follow the line (first he calibrates).
    But this doesn't work and i don't know why

    When i put a motor block infront of the linefollowing myblock he drives forward but then the calibration doesn't work.
    But without a motor block infront, it works.

    Can you say me what i have done wrong?

    I hope you can understand my problem because i am german
    Can you get the line follower to work at all? Does it work if you remove the move blocks from in front of the line following? That would be my first test.

    If you can get it to work, what are you adding that causes it to stop working? You mention motor blocks and you mention calibration. Is the robot supposed to drive to a dark (or bright) part of the mat and take a calibration reading? I would test to make sure that part is working. Have the robot drive out, do the calibration, and then go into a loop that displays the sensor reading. Move the robot by hand and look at different parts of the mat. Do the readings make sense?

    Comment


    • #3
      Re: Line Following inside a program?

      The linefollowing works but when i put a move block infront it doesn't work really.

      At first the roboter turs 40 degres (one wheel forward and one backward).
      There the roboter shecks the black line and white and at the end of the calibration the roboter has the middle value of black and white (gray).
      Then the roboter turns back until he sees the gray value.

      When i put a move block infront, the roboter doesn't turns 40 degres but 360 degres and so he doesn't find back the the line.(food factor field)
      But when i put the roboter while the program runs and put it back to the line he will follow the line.

      And the sensorvalues are all right, i try it.

      Comment


      • #4
        Re: Line Following inside a program?

        Originally posted by AngyLPer View Post
        The linefollowing works but when i put a move block infront it doesn't work really.

        At first the roboter turs 40 degres (one wheel forward and one backward).
        There the roboter shecks the black line and white and at the end of the calibration the roboter has the middle value of black and white (gray).
        Then the roboter turns back until he sees the gray value.

        When i put a move block infront, the roboter doesn't turns 40 degres but 360 degres and so he doesn't find back the the line.(food factor field)
        But when i put the roboter while the program runs and put it back to the line he will follow the line.

        And the sensorvalues are all right, i try it.
        It sounds like the calibration is part of the line following and you expect the robot to start on the dark line. I do not think this is a good idea.

        The easiest thing to do is calibrate before the match. Use the NXT calibration blocks or built in program to calibrate the robot to return a value of 0 when over the black line and 100 when over the white mat. I would then use a line following threshold value of 50. I think what your line following program does at the beginning is calculating this threshold value:

        threshold = (dark reading + bright reading) / 2.

        The problem doing the calibration programmatically during a mission is that it may not be possible to place the robot on the dark line to start, and driving out to find a dark line for calibration may be unreliable.

        When you put a move block in front, what is the move block supposed to do? Drive straight or turn? Does the move block work as you expect? Put a wait block betwee the move block and the calibration and find out if the extra turning happens before or after the wait.

        Comment


        • #5
          Re: Line Following inside a program?

          Originally posted by AngyLPer View Post
          At first the roboter turs 40 degres (one wheel forward and one backward).
          There the roboter shecks the black line and white and at the end of the calibration the roboter has the middle value of black and white (gray).
          Then the roboter turns back until he sees the gray value.
          What the robot is doing sounds very similar to a sample line-following program on nxtprograms.com.

          Watch the video associated with the project. The second sample program, which does proportional line-following, does a self-calibration step at the beginning of the program before the robot starts line-following.

          The sample proportional line following program from nxtprograms.com is not really in a state to be immediately converted to a reusable MyBlock. As Dean stated, you probably want to pull out the part of the program that performs the calibration, and do that calibration step before the robot is running a specific mission.

          Comment


          • #6
            Re: Line Following inside a program?

            Originally posted by timdavid View Post
            What the robot is doing sounds very similar to a sample line-following program on nxtprograms.com.
            If it is using this program, probably what is wrong when you add Move/Motor blocks in front is you need to reset the rotation sensors (yellow rotation sensor block set to reset, for reach drive motor) after the movements you added. The initial calibration at the beginning of the line following, which pivots the robot back and forth, assumes the robot is starting from the beginning of the program (motors all at 0 degrees).

            Dave Parker
            www.nxtprograms.com

            Comment


            • #7
              Re: Line Following inside a program?

              I have send you some pictures and of my line following calibration and how it works and how not.
              I already tried to reset rotationssensors and the motors.
              The calibration part is similar to the from nxtprograms.com but not the same.

              But i think the best way is it like Dean Hystad and timdavid said to to the calibration part at the beginning of the match.

              But i would prefer to do the calibrationpart in the match. maybe someone knows what i have done wrong when you see the pictures.
              Attached Files

              Comment


              • #8
                Re: Line Following inside a program?

                Originally posted by AngyLPer View Post
                I have send you some pictures and of my line following calibration and how it works and how not...
                ...But i would prefer to do the calibrationpart in the match. maybe someone knows what i have done wrong when you see the pictures.
                @AngyLPer,

                I can't really understand your programs from the pictures. The resolution on the pictures is fairly low, and I believe there are some custom MyBlocks in the program that are not included in the pictures.

                However, instead of having you send more pictures, I would recommend you start over with a simpler line-following algorithm. From the little I can discern from the pictures, it appears the program may be using a full PID algorithm, which is the most complicated algorithm most FLL teams will ever consider using. If you are having problems remembering or understanding how it works, it is not surprising.

                I sympathize with your situation. As a professional software developer, I've often had to try and get programs working that I don't fully understand. Sometimes I can do it, but sometimes I'm better off starting with something simpler than I will be able to understand and maintain.

                I would recommend you start with something like the basic "LineFollow2" program example from nxtprograms.com. This is a basic two-state line follower, that zip-zags from side to side.

                Dave Parker includes a nice explanation of calibration on that page, along with a sample calibration program.

                My suggestion would be
                1. Get the simple line following program working
                2. Turn it into a MyBlock
                3. Add to your program, with other blocks before and after it

                Once you have done that, you can evaluate your program and determine if you need some more complicated. If you get that far, it is not a large step to start using a simple proportional algorithm that may be a little smoother and faster.
                Last edited by timdavid; 04-29-2012, 05:00 PM.

                Comment


                • #9
                  Re: Line Following inside a program?

                  Originally posted by timdavid View Post
                  @AngyLPer,

                  I can't really understand your programs from the pictures. The resolution on the pictures is fairly low, and I believe there are some custom MyBlocks in the program that are not included in the pictures.

                  However, instead of having you send more pictures, I would recommend you start over with a simpler line-following algorithm. From the little I can discern from the pictures, it appears the program may be using a full PID algorithm, which is the most complicated algorithm most FLL teams will ever consider using. If you are having problems remembering or understanding how it works, it is not surprising.

                  I sympathize with your situation. As a professional software developer, I've often had to try and get programs working that I don't fully understand. Sometimes I can do it, but sometimes I'm better off starting with something simpler than I will be able to understand and maintain.

                  I would recommend you start with something like the basic "LineFollow2" program example from nxtprograms.com. This is a basic two-state line follower, that zip-zags from side to side.

                  Dave Parker includes a nice explanation of calibration on that page, along with a sample calibration program.

                  My suggestion would be
                  1. Get the simple line following program working
                  2. Turn it into a MyBlock
                  3. Add to your program, with other blocks before and after it

                  Once you have done that, you can evaluate your program and determine if you need some more complicated. If you get that far, it is not a large step to start using a simple proportional algorithm that may be a little smoother and faster.
                  I would suggest a simple proportional only line follower. Simpler to program than a two state line follower, intuitively easy to understand, and MUCH better performance. PID for line following is overkill. I find it hard to see any difference in performance between proportional and PID (proportional, integral, derivative), and a proportional controller can be done using three blocks.

                  Comment


                  • #10
                    Re: Line Following inside a program?

                    Thanks for your answers
                    The PID linefollower works really good for my roboter but the only thing that doesn't work is that i can't place a motor/move block infront of the calibration.

                    I also tried the programs from nxtprograms.com

                    I have already tried to solve this problem by using only the calibration part without the rest of the program but it't always the same.
                    I told the roboter to end the loop until motor B reaches 40 degres.
                    When there is nothing before the roboter turns 40 degres but when i put a block infront he turns 100 degres.

                    I think the problem has nothing to do with PID but with the calibration.
                    I tried using the calibration from the linefolower at nxtprograms.com but it's the same.

                    Comment


                    • #11
                      Re: Line Following inside a program?

                      Originally posted by AngyLPer View Post
                      Thanks for your answers
                      The PID linefollower works really good for my roboter but the only thing that doesn't work is that i can't place a motor/move block infront of the calibration.

                      I also tried the programs from nxtprograms.com

                      I have already tried to solve this problem by using only the calibration part without the rest of the program but it't always the same.
                      I told the roboter to end the loop until motor B reaches 40 degres.
                      When there is nothing before the roboter turns 40 degres but when i put a block infront he turns 100 degres.

                      I think the problem has nothing to do with PID but with the calibration.
                      I tried using the calibration from the linefolower at nxtprograms.com but it's the same.
                      I think you answered your problem.

                      "I told the roboter to end the loop until motor B reaches 40 degree...but when i put a block infront he turns 100 degres."

                      How does putting a block in front change the rotations sensor value for motor B? How can you correct the problem?

                      Comment


                      • #12
                        Re: Line Following inside a program?

                        [/QUOTE]How does putting a block in front change the rotations sensor value for motor B? How can you correct the problem?[/QUOTE]



                        This is the question i ask myself and i don't know why it is like this.
                        I can't really understand it so I ask you for help if someone knows it?

                        Changing the rotations loop to less than 40 degrees he turns the same and it doesn't matter if i choose 1 degree or 40 degrees but when i chose 360 degrees the roboter turns 360 degrees.

                        Comment


                        • #13
                          Re: Line Following inside a program?

                          Originally posted by AngyLPer View Post
                          How does putting a block in front change the rotations sensor value for motor B? How can you correct the problem?

                          This is the question i ask myself and i don't know why it is like this.
                          I can't really understand it so I ask you for help if someone knows it?

                          Changing the rotations loop to less than 40 degrees he turns the same and it doesn't matter if i choose 1 degree or 40 degrees but when i chose 360 degrees the roboter turns 360 degrees.
                          Perhaps this material will be useful.
                          http://forums.usfirst.org/showthread...5137#post55137

                          http://forums.usfirst.org/showthread.php?p=42964
                          FIRST Tech Challenge Judge: 2010, Referee: 2017
                          FIRST LEGO League Mentor, Instructor, and/or Referee/Head Referee since 2011
                          FIRST Robotics Competition judge (Chairman's Award): 2014
                          Dean says I'm an "Oompa Loompa of Science"

                          Comment


                          • #14
                            Re: Line Following inside a program?

                            Originally posted by AngyLPer View Post


                            This is the question i ask myself and i don't know why it is like this.
                            I can't really understand it so I ask you for help if someone knows it?

                            Changing the rotations loop to less than 40 degrees he turns the same and it doesn't matter if i choose 1 degree or 40 degrees but when i chose 360 degrees the roboter turns 360 degrees.
                            Think about this. What is the value of rotation sensor B when you START your loop? How does this change if you put a Move block BEFORE the loop.

                            Comment


                            • #15
                              Re: Line Following inside a program?

                              Yeah it works thank you for all your help

                              I put infront of the calibration two resetrotation B and C
                              Then I made a constante (Turning 40degrees) at that compares with rotationssensor C and when its same then he end the loop and it works

                              Comment

                              Working...
                              X