Off Season Experimentation

Now during the off season I have been playing around with Labview and making the robot do different tasks using sensors by using the FRC Simulator. I have been very successful during these fun test, but I have just hit a stopping point :frowning: . Want I’m trying to accomplish is make the robot turn exactly 90 degrees in place by using a gyro. I have a provided a screenshot of my current autonomous code. The robot just rotates to its left and keeps rotating non stop. I can’t figure out why it does that. The “Left and Right Motors” should get a value of 0 as soon as the gyro angle is equal to 90. I have opened, set gained, and closed the gyro and gave it its Refnum Name called “Gyro”. The False Case is empty. Thanks in Advance!

Auto.JPG


Auto.JPG

It keeps turning because you have values outside of the case structure. you need to move the values before the case structure to after the case structure. And have a wire running through the structure while it is false in to the tank drive vi. And and keep whats in the case structure like that when its true.

I made the changes and the robot did actually rotate 90 degrees, Thxs. But, I noticed that after the robot rotated 90 degrees it began to drive forward. It was suppose to stop the motors. Any idea why?

Auto.JPG
AutoII.JPG


Auto.JPG
AutoII.JPG

I see two issues with the code you posted. First, it only runs once. In order for it to do what you want, reading the Gyro angle and setting the motor speeds need to be inside a While loop. Second, you’re checking for exactly 90 degrees, and that’s a very unlikely number. Try stopping the motors after it has turned at least 90 degrees; that way you won’t fail to stop because you miss the brief instant when it’s right at 90 degrees.

I placed the While Loop and instead I changed “Equal to” to “Greater or Equal” but I still get the same results. The robot rotates 90 degrees(maybe a little bit more since its not exactly 90) and then continues to drive forward.

Auto.JPG


Auto.JPG

Try putting all of the drive vi’s inside the case structure and leave the gyro vi out. And make sure that there is are no other drive vi’s in your autonomous code.

you need to have the while loop stop once the angle >90, otherwise each while loop execution (to infinity) will pulse the motors. Notice how the Tank drive (0,-.8) is outside of the case structure. That means that regardless of what is going on with the gyro, it will always turn.

Forward as in straight? or forward as in continued to turn?

What I mean as in “continues to drive forward” is that after the robot rotates the required 90 degrees(at least), it(the motors) still continue to run and causes the robot to drive forward non stop. I placed all the Drive vi inside the case structure and made the while loop stop when its true which is when the gyro angle is >=90. But I still remain having the same problem I indicated that I described at the beginning of my post.





Personally, I’d place a probe on the angle. Perhaps it would help to place a breakpoint where the motors are zeroed.

The other thing to watch for is other code updating the motors. You may want to search for the refnum name.

Greg McKaskle

It is not likely that not having a wait timer would cause the robot to not stop moving, but they are good to have. Also, before you enter the while loop you should reset the gyro, so that moving the robot around before you run the code won’t make it go more or less than 90 degrees. Another thing you should check is to see if turning in the direction you are telling the robot to turn in gives you a negative angle, like -90 degrees.