# How to turn with 6 motor drive

Our team is now using a 6-motor drivetrain for our Spin Up rebuild. I’m trying to program an autonomous, but have been finding it really difficult. What we do now in the configuration is that we have a 4 motor drive, 2 L and 2 R, and have the remaining 2 motors as seperate motors (so one is DriveR, one is Drive L).

For moving forward and back (when using the remaining motors not defined in the drivetrain configuration), i use this formula:
rotations = distance/(π*diameter)

However, I am not sure how I can calculate the amount the motor should spin when turning. Does anyone know?

Why would you do that ?

Ah, probably blocks, mixing a drivetrain and two additional motors is a bit of a non-starter, either define 6 motors and do it all in blocks code, or preferably, switch to C++ or Python and create a 6 motor drivetrain.

5 Likes

the thing is that my team member did all her configurations in block and all, so I need to do auton in block. Its convenient for me and the team to use a uniform language

sure, but blocks doesn’t support a 6 motor drivetrain.
How did you all do driver control ?

4 Likes

so you do that in addition to assigning the drivetrain to the controller ? LeftDrive and RightDrive are individual motors ?

3 Likes

yes. LeftDrive and RightDrive are individual

you are really making things hard to do turns in autonomous.

If the drivetrain is using an inertial sensor (or gyro) there’s probably no way to do this as it controls the drivetrain motors directly using a simple P controller.

if you are not using a gyro, the equation used to calculate the number of revolutions for the motor is.

``````    //
//         turns x (t*t + b*b) x PI
// revs =  ------------------------
//                 c x t
//
``````

where
t is trackwidth
b is wheelbase
c is wheel circumference
turns is number of turns where 360 degrees is 1 turn

then compensate for any gear ratio you have.

but if that’s all the driver control code you have, switch to C++ and make your life a bit easier.

4 Likes

I see…Where did you find this?

It’s a standard formula, but I pulled that out of the source code for the drivetrain class.

There are other physical things that will impact that, what type of wheels etc.

5 Likes

Also, I need to convert from
degrees the drivetrain turned → The number of rotations the motor needs to turn

That’s what the formula is doing.

So no inertial sensor ? This only applies if you are not using that.

revs is number of motor revolutions (assuming direct drive, compensate if using gears).
for a 90 degree turn, “turns” will be 0.25.

bear in mind this code (the drivetrain code) was developed for a simple robot. You didn’t say how many wheels you have and what type they are, that will impact things a lot. For the legacy clawbot with front and back wheels geared together, this is generally what is happening.

Think of the wheels having to drive to follow the red circle.

4 Likes

Edit: did some calculations, and derived it to calculate turns. I got

``````r (c * t)
-------------------- = turns
[(t*t) + (b*b)] * PI
``````

are all measurements in mm?

yes (although I think units cancel out)

why did you change the equation to calculate how much drivetrain should turn ?

anyway, to test, I would try with motors (one as a drivetrain motor and one driven using the equation) that are not on the robot. Try to turn 90 degrees and see if your code turns them both by the same amount. (and make sure to document all this in your notebook).

4 Likes

Alright, I will try that. thank you so much!

update: The turning works, however, there is still the sound of some motor running after the turn. Because of this, the robot isn’t doing the next series of commands, as it is stuck there.

I use 6 grey anti-static omni wheels, 1 motor per wheel. They are green cartridge

Edit: I found one of my mistakes in my code, but it still is having the problem stated above.

The issue is, after I turn, there would be some motor still running (I don’t know which one it is). This means that the remaining code after the turn does not run.

couple of things

turn left for 60 degrees

will block, use the and don’t wait setting.
(same with the first spin RightDrive command, only block on the last part)

you can actually simplify the calculation.
t, b, c and PI are all constants on your robot, just pre calculate all that part and assign to a variable.

3 Likes