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 . 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!
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?
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.
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.