4 motor drivetrain programming issues

Students are doing 4 motor drivetrains and some are placing their motors in opposite directions on the same side causing the wheels to spin opposite when using the drivetrain command drive forward… does anyone know of a fix for this besides having them redesign/ flipping the motors on the bot.

I know that when we do motor groups it has an option come up so you tell the program which way the motor is oriented by toggling a button showing the motor is reversed., but that option is not available under the drivetrain options.

Thoughts?

That is not a supported configuration when using the drivetrain object in blocks.

If you’re programming in C++ you could make it work – configure two motor groups in the configuration menu (reversing individual motors as needed), then set up a drivetrain in code as follows:

// substitute these values for the correct values for your robot:
const int myWheelTravel = 200;
const int myWheelBase = 180;
const int myTrackWidth = 250;
smartdrive myDrivetrain(LeftDrive, RightDrive, MyGyro, myWheelTravel, myWheelBase, myTrackWidth);

or in Python for 2nd gen:

# Begin project code
myWheelTravel = 200
myWheelBase = 180
myTrackWidth = 250
myDrivetrain = SmartDrive(LeftDrive, RightDrive, brain_inertial, myWheelTravel, myWheelBase, myTrackWidth)

Also – it might just be the angle the photo is taken from, but it looks like that robot has 250mm wheels on the back and Omnis (200mm circumference) on the front – that will also cause problems with the built-in drivetrain object since the motors would need to spin at different speeds. In general all the powered wheels on a drivetrain should have the same circumference.

1 Like

This won’t happen. If a motor is flipped around as shown in the picture clockwise is still clockwise.

1 Like

I took the bot and wrote a new test code and it worked fine… I looked at their code on the CB and it looked correct and the wheels turn in opposite directions… I have a feeling that they have something else mixed up in the code that I didn’t see during class… we will do more debugging tomorrow. Thanks!

They will find out shortly how bad the omni wheels are for sumo bot and I will guide them through some investigation on the wheel circumferences and see if they will pick up on it… good stuff!.. thanks for the pointers