Announcement

Collapse
No announcement yet.

Strange linear op behavior

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

  • Strange linear op behavior

    We wrote a simple liner op program for autonomous mode. It moves forward, turns 45 degrees, moves forward, turns 45 degrees again, and then moves forward again. It works fine about half the time. The other half is weird. Sometimes both motors will continue to run, and sometimes one motor will continue to run. It always seems to run the first time, then when we stop and restart it goes haywire. Have a look at our code. Any suggestions?
    https://www.dropbox.com/s/pgbuxb35b8...0Auto.JPG?dl=0

  • #2
    Originally posted by tvsknights View Post
    We wrote a simple liner op program for autonomous mode. It moves forward, turns 45 degrees, moves forward, turns 45 degrees again, and then moves forward again. It works fine about half the time. The other half is weird. Sometimes both motors will continue to run, and sometimes one motor will continue to run. It always seems to run the first time, then when we stop and restart it goes haywire. Have a look at our code. Any suggestions?
    https://www.dropbox.com/s/pgbuxb35b8...0Auto.JPG?dl=0
    I would suggest adding TelemetryAdd... blocks from the RobotController drawer. You can use these to inform the drive station which step in your program is executing and the current value of the motors' CurrentPosition values. This should help you sort where the problem is. Perhaps the ResetEncoder is not working properly. If so, try repeating it to see if that helps. You may also discover that you need monitor the encoder values of both motors rather than just motor1.
    ...Bruce

    Comment


    • #3
      We had a bunch of telemetry readings following every part of the code. We took them out when we did the screen shot to make the code more compact. Everything was as it should be, except the motors don't shut off at the end. It's strange. Sometimes they shut off, but most of the time they don't.

      Comment


      • #4
        Originally posted by tvsknights View Post
        We wrote a simple liner op program for autonomous mode. It moves forward, turns 45 degrees, moves forward, turns 45 degrees again, and then moves forward again. It works fine about half the time. The other half is weird. Sometimes both motors will continue to run, and sometimes one motor will continue to run. It always seems to run the first time, then when we stop and restart it goes haywire. Have a look at our code. Any suggestions?
        https://www.dropbox.com/s/pgbuxb35b8...0Auto.JPG?dl=0
        This is exactly the same problem we have been having. It is very frustrating and they do not seem to be able to get it fixed. I do not trust linear op mode at all.

        Comment


        • #5
          Maybe you can try "setPowerFloat" block to stop motor

          Comment


          • #6
            Originally posted by tvsknights View Post
            We had a bunch of telemetry readings following every part of the code. We took them out when we did the screen shot to make the code more compact. Everything was as it should be, except the motors don't shut off at the end. It's strange. Sometimes they shut off, but most of the time they don't.
            It shouldn't be necessary but seems to help to issue power commands more than once. I note that your power commands are repeated in all but the last step because they are in While Test loops. Try putting your last step where you set the powers to 0 in a loop. You could use a For-Each-Number and repeat it 5 times.
            ...Bruce

            Comment


            • #7
              We don't trust linear op mode either, but we have other things to do with servos between some of the encoder runs. That is a programming nightmare running the loop in op mode.
              We aren't familiar with "setpowerfloat". We'll look for it and give it a try. Schafer's suggestion of putting the "set motors to zero" in a loop sounds like a good idea. We'll definitely try that.

              Comment


              • #8
                OK, we put a loop in with the commands to set motors to zero. We looped it a thousand times. First time, the program worked. Second run, both motors kept running. We then discovered that if we exit the app on the robot controller (actually select exit and close) and restart the app, it works the first time. I guess we'll just have to make sure we restart the app before our run.

                Comment


                • #9
                  Hi tvsknights...

                  Do you have legacy motor controllers (the older NXT-compatible ones) or newer Modern Robotics motor controllers?

                  Can you put your .aia file online somewhere so we can test your app?

                  Tom

                  Comment


                  • #10
                    I forgot to mention... In your while loops, I think you might want to put some WaitOneFullHardwareCycle statements to give the code a chance to process your commands.

                    Comment


                    • #11
                      We've had the same issue, the autonomous code works as expected the first time, but try running the robot again without exiting the app, it has acted very unexpectedly. I see it's not just us.

                      Comment


                      • #12
                        Hi Tom
                        Thanks for looking in. We are using all new Modern Robotics equipment. We have wondered what WaitOneFullHardwareCycle does, and we stuck it in various places. It didn't help. Of course, it's possible that we didn't put it in the right place.
                        We set the motors to zero and put those commands in a loop that runs a thousand time.
                        Here's a link to the aia file:
                        https://www.dropbox.com/s/jm64mtoop2...ctive.aia?dl=0

                        Comment


                        • #13
                          Originally posted by tvsknights View Post
                          Hi Tom
                          Thanks for looking in. We are using all new Modern Robotics equipment. We have wondered what WaitOneFullHardwareCycle does, and we stuck it in various places. It didn't help. Of course, it's possible that we didn't put it in the right place.
                          We set the motors to zero and put those commands in a loop that runs a thousand time.
                          Here's a link to the aia file:
                          https://www.dropbox.com/s/jm64mtoop2...ctive.aia?dl=0
                          I suggest putting WaitOneFullHardwareCycle in every while loop in your RunOpMode event block.

                          Comment


                          • #14
                            Thanks, Comrade. We'll try it and let everyone know how it works. We still don't know what the command means, but we'll trust you.

                            Comment


                            • #15
                              Originally posted by tvsknights View Post
                              Thanks, Comrade. We'll try it and let everyone know how it works. We still don't know what the command means, but we'll trust you.
                              You can find command definition in this documents https://docs.google.com/document/d/1...it?usp=sharing

                              In this documents,WaitForNextHardwareCycle()* means:
                              Wait*for*the*start*of*the*next*hardware*cycle.* Each*cycle*of*the*hardware*your*commands*are*sent* out*to*the*hardware;*and*the*latest*data*is* read*back*in.* This*method*will*wait*for*the*current*hardware*cyc le*to*finish,*which*is*also*the*start*of*the*next* hardware*cycle.*

                              Comment

                              Working...
                              X