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