Robot never stops turning around even if put a "Stop driving" block

hi,
we are running a simple program to make the robot go in a straight line, Turn right and then go in a straight line.

The robot just goes straight and keeps turning and never stops.

This is our Code.

float myVariable;

// "when started" hat block
int whenStarted1() {
  Drivetrain.driveFor(forward, 150.0, mm, true);
  Drivetrain.stop();
  Drivetrain.turnFor(right, 90.0, degrees, true);
  Drivetrain.stop();
  Drivetrain.driveFor(forward, 150.0, mm, true);
  Drivetrain.stop();
  return 0;
}


int main() {
  // Calibrate the Drivetrain Gyro
  calibrateDrivetrain();

  whenStarted1();
}

What are we doing wrong?
We have tried the following with no resolution:

  1. factory reset the brain
  2. Deep calibrating inertial sensor using this article. https://kb.vex.com/hc/en-us/articles/4413102100500-Troubleshooting-the-VEX-IQ-2nd-gen-Inertial-Sensor-using-Deep-Calibration
  3. Using a different brain

Our blocks code:

Check out this article

1 Like

When turning, is the robot spinning left? Students sometimes have the left and right motors reversed which causes the robot to turn the wrong way. The sensors are waiting for the robot to arrive at a ‘right’ position but the robot never gets there because it’s turning left.

If I’m reading the code right… you are calibrating at the same time the robot begins moving… no way calibration of gyro will work. It needs 2-3 seconds of motionless robot to calibrate.

And, yes, make sure your turn direction is the same as the measurement direction for the gyro.

Hello! Thanks for bringing this to our attention. We’ll attempt to replicate the issue you’re encountering. In the meantime, could you kindly provide feedback through the app? This will give us additional details to assist you better.

The most efficient way to provide feedback is to replicate the issue within the app and then submit your feedback. Please ensure you include diagnostic and usage data, along with a custom message to help us identify your specific feedback.

Thank you.

We didnt add the calibrate code. it was auto added in the python version. We only used the blocks to. create the program.
When we start the program, the robot does take a few seconds for calibrating and then it starts.

Thanks for the comment. Can you let me know which app are you referring to? I have never used any Vex related app. we use codeiq.vex.com for our programming

The robot does turn left. This might actually be the issue. I will check it once I get back home today. Thank you

Assuming this is the issue, how do I fix it in the program without modifying the drive train?

  1. Make sure you have selected the correct ports for the left and right motors based on what is considered the front of the robot.
    image

  2. You may need to reverse the direction of the drivetrain depending on if the motors are facing toward or away from each other.
    image

2 Likes

What about manual control… using the controller? Is that reversed?

If it’s turning the wrong way, you can fix this in block by looking at the motor assignments, or the drivetrain assignments/config. There should be an option to 1) confirm which motors are in what places & ports 2) reverse motors.

You can submit a feedback using the “Feedback” button on top right.

However, make sure you replicate the problem before submitting the feedback and enable “Include diagnostics and usage Data” while submitting the feedback. This should provide us with your project and console logs so we can better help you.

hi. This issue is still not fixed. I submitted feedback through the app as well.

So the Robot does go forward and stops. It tries to turn right 90 degress and stops midway and there is no movement. if we try to nudge it a bit, it will start turning again and move forward.

We havent had any issues moving the robot with the controller, but the programming blocks are simply not working for us.

Please help.

I assume you fixed this.

Sounds like the turn is not able to complete. Generally this is due to gearing, build issues, wheel configuration or something along those lines.

I’ll try and look for the feedback later, but in the meantime

Is this an IQ Gen 1 or Gen 2 brain ? (looks like a gen 2, just want to confirm)

Is this a standard build (basebot, etc.) or custom robot, perhaps post a picture, that would help.

In terms of the code you originally posted.

int whenStarted1() {
  Drivetrain.driveFor(forward, 150.0, mm, true);
  Drivetrain.stop();
  Drivetrain.turnFor(right, 90.0, degrees, true);
  Drivetrain.stop();
  Drivetrain.driveFor(forward, 150.0, mm, true);
  Drivetrain.stop();
  return 0;
}

you really do not need a Drivetrain.stop() between each forward/turn command, that’s used with commands that do not specifiy a distance or angle to move, the driveFor and turnFor commands usually block and will not return until they complete, that’s why nudging the robot it’s able to complete the turn and continue to the next line of code. having the Drivetrain.stop() is not the root cause of your issue, I just mention FYI.

3 Likes

So all feedback could tell me is that it’s a 2 motor drivetrain, geared for speed it looks like (3:1), using IQ gen 2.

You could, as an experiment, try increasing turn velocity.

but if it’s a big heavy robot, with 3:1 gearing, the generic turn code may not work for it with only two motors.

again, pictures would help.

3 Likes

thanks for the quick feedback.
Yes this is a Gen 2 brain and a custom robot for the competition. It does have a 3:1 gear ratio for the drive train and is a heavy robot.
here is how it looks from the bottom.

we dont have any trouble turning or driving this with the controller, but why does the program fail?
I ll try the turn velocity block and report back

The default drivetrain (and motor) velocity is 50rpm, but that is wheel velocity not motor velocity.
You have a 3:1 gearing for speed, so to achieve 50rpm at the wheel the motor is running quite slow. We use 50rpm as that is suitable for the simple clawbot designs and keeps them controllable in a classroom.

You probably want to increase both turn velocity and drive velocity (separate blocks or text functions) to 150rpm (50%) or more. Having said that, the internal drivetrain code is generic and optimized for simple robots not competition robots, you would have a little more control if using text based coding, but eventually you may need to program the moves and turns with custom code tuned to your robot.

Using the controller, if configured using the graphical setup, you will be using all available power of the motors as the code will directly map 100% of controller joystick to become 100% of motor velocity.

3 Likes

This is very helpful and I didnt know that the drive and wheel velocity needs to be specifically optimized.

The team is elementary level and hence havent learnt text based coding yet. I ll teach them about these new blocks adn report back

Hi,
I wanted to close the loop here.
The problem is fixed now. We added a Calibrate Brain inertial block and set the drive and turn velocities manually and the robot is responding well

3 Likes