Should I do motor groups?

Should I switch to using motor groups? This is my auton right now:


It feels very cluttered but I don’t really know how to use motor groups.
Some insight would help!

I would recommend making a a function to drive the robot given number of turns

2 Likes

you could also try to use the drivetrain function, this makes coding auto so much easier.

Could you please explain that a bit?

Basically you can declare a function and the function will run code inside of it when called. I don’t know how to explain it well so hers an example

void drive(float left, float right)
{
front_right.spinFor(forward, right, turns);
front_left.spinFor(forward, left, turns);
back_right.spinFor(forward, right, turns);
back_left.spinFor(forward, left, turns);
}
``
Inside of auton

drive(.5,.5);
Drives each motor side .5 turns
2 Likes

I can’t because I have an X-Drive.

Can you explain why you can’t. @EcstaticPilot just used your code as the template for the example code.

I’ll try that, thanks!

I just don’t know how to use motor groups.

Here’s how to create one:

motor_group  motorGroupName(motor1, motor2);

And to use it it is just like controlling a motor, for example:

motorGroupName.spinFor(fwd, .5, turns);
2 Likes

Try using drivetrain. It would be much easier.

As I’ve said before to someone else. I cannot use it because I have an X-Drive.

Oh, sorry, didn’t realize that, should’ve remembered to exclude x-drive and mecanum drive.

I say probably not, as it would be easier to do them individually, most likely, though it wouldn’t be quite as convenient. Besides, it works like this, right?

1 Like

Yeah, it does work. I just wanted to try to clean up my auton. I’m gonna try the functions and test it tomorrow.