Why is our robot turning left and right continuously during auton using the inertial sensor?

Hello, im trying to code auton for my robot using v5 blocks. When I have my robot turn 55 degrees, it overturns and tries to correct itself making it go in a loop of turning left and right until auton ends. Its really annoying and we need to finish our auton.

1 Like

What type of code are you using? Can you post the code? If not, can you describe how it works?

1 Like

Ensure that you have the motor to wheel gear ratios correct. It’s actually backwards of what is technically correct. For instance, a 24 tooth gear/sprocket on a motor with a 12 tooth on the wheel is a 1:2 ratio (one turn of the motor equates to two turns of the wheel); however, blocks has a backwards convention issue, where they want you to put in the ratio of teeth (2 teeth on the motor for every one tooth on the wheel).

This very issue impacted my oldest until it got reversed, at which time it largely went away (other than having a turn velocity too high which overshot).

@jpearman This is such a fundamental input issue that really needs clarified in setup of drivetrains in all forms of Vex coding products. Please consider having a tooltip at least that describes what the user needs to input, or even maybe consider a dropdown to allow the users to select which gears are in use, or even no gears (direct drive).

I might be wrong here, but wouldn’t that be a 2:1 ratio? I’m pretty sure it’s inputGear:outputGear. At least that’s what this site claims

Edit: Upon further research, the site linked above seems to contradict what the vex knowledge base article says. So I’m just wondering, which one is correct?
https://kb.vex.com/hc/en-us/articles/360035590932-Using-Gear-Ratios-with-the-V5-Motor

I got schooled up on this by a now-retired extremely smart mechanical engineer (@botcats1018), so I’m going with what I learned from him and reading on it more myself. In mechanical terms, it’s the ratio of turns from input to output, which is basically inverse of the gear ratios. A 2:1 tooth ratio (e.g. 24 teeth to 12 teeth) causes a 1 (motor rotation):2 (wheel rotation) ratio.

This is precisely what’s confusing about this, and really needs some sort of clarification in drivetrain setup to prevent the misunderstanding and lost time troubleshooting something that’s not obvious. If you’re doing things manually without a drivetrain and converting motor degrees to motion inches, then it’s likely less a problem, because you pretty much have to understand the ratios to do the calculations right.

Having now tagged him, hopefully I haven’t embarrassed myself. ;p

1 Like

I’m using block, ill post the code. The auton is the part to the right and I know its not a lot because of this overturning issue, which I wanted to fix before I finished coding.

I’m now confused about gear ratios so I’m just gonna say that our drivetrain has a 36 tooth gear on the motors and an 84 tooth gear on the wheels. Along with that we are using blue cartridges in the motors (600 RPM).

To be honest, I find it backwards as well, but it’s probably too late to change the UI. For reference, I don’t have that much involvement with the VEXcode UI and I’m not sure if that area was deliberately setup that way or if it was just an accident. However, I agree that we should probably clarify that the number to enter is the ratio of gear teeth from motor (input) to wheel (output).

@tfriez over to you.

6 Likes

Would something like this help? I’m not opposed to changed the UI to make it clearer, but I also don’t want to clutter it with lengthy explanations.

7 Likes

@tfriez

I might suggest a tooltip popup like the ones by the track length and wheelbase, and it could describe there that it’s the gear/sprocket tooth ratios, maybe even with a quick example of 2:1 being 24 tooth on motor to 12 tooth on wheels. That would look to answer what appears to be a common error based on topics here. :slight_smile:

Appreciate you all looking at improving this!

(As a related suggestion for your backlog, a loading splashscreen for blocks products that have a long load time could be helpful to let folks know that it’s loading, so that impatient kids aren’t starting like 8 instances :rofl: )

5 Likes

Our competition robot does the same, a constant back and forth when we use the inertial sensor to turn. We have our input and output gears set up per the instructions mentioned earlier in this post. (1st Picture) Both of our competition teams have the same issue, so I can’t think that we got two faulty inertial sensors. Could it be how we have built and programmed our base? We have six motors driving the base. The front and back motors on both sides are in the drive train and the other two are driven by special driver program and not used and set to coast during autonomous.
Screenshot 2022-03-01 5.25.22 PM

Screenshot 2022-03-01 7.02.53 PM

So the ratios should be the least common denominator essentially, rather than the gear tooth counts, so in this case 3:7 would be the ratio that should go in there. Just confirming, it’s 36 tooth at the motor, and 84 at the wheel? Seems like that would generate a lot of drivetrain torque, but not much speed.

Step 1 is definitely getting that set up right and trying again. When it’s backwards, you definitely get the seesaw action, at almost any turn velocity.

Er, well, that won’t help.

This is a comment I made about using drivetrain a few days ago.

The key part from that is
The drivetrain class is great to get something working quickly and for classroom use, but if you find it does not work as desired then it’s time to write your own control loop that’s tuned to your robot

3 Likes

The 36 is at the motor and the 84 is on the wheel, 600 rpm motors power it.

We changed the code setup like the code in the screenshots to make our pivots with the inertial sensor. It is accurate and consistent, but it requires the programmer to remove the drive train.

The Main Part is

I don’t know if you found a solution or not but the same thing happened to me, my auton always fails when I do something like turn left till
inertial15 = 0, this fails because it either reads too slowly or the robot goes to fast and keeps overturning. The simple solution I found was to slow down the velocity a bit and the second thing I found was doing turn in till inertial15 > -3 and inertial15 < 3, this keeps it fairly straight.

1 Like

I figured it out, I changed the code to a while function, and put the

drive rotation in degrees in it, with a greater than or less than block, then finish with a turn right/left and the stop driving otherwise it will continue to spin left/right. It seems to work, but now I have a new problem, our robot does not complete the first drive forward. It drives into the goal and it should fire the piston to grab the goal, but its freezing after the drive forward and not doing the rest of the code.

I had a problem like this in IQ. It seemed to be that the program didn’t move on to the next line until the drivetrain had driven 50 inches (in your case). But when we tried to run into a wall or something, it could not go forward, and so it never went 50 inches and never finished the line. That would be weird in your case, since I would think you would be able to just shove the goal and finish the 50 inches, but you could try changing it to 40 or so, since it doesn’t hurt to try.

That’s what I was worried/wondering about is that I tried with and without the goal with plenty of open space, but it still wouldn’t drive forward for the full 50.