Making one controller axis perform two different actions

Hi everyone,

I am currently trying to code an arcade drive for our 6 motor drivetrain. As driver, I found that the “traditional” arcade drive where you essentially have to stop your bot, spin, then move forward again did not work for me. As such, I am trying to make it so that when I move axis 4 towards the LEFT, the motor group LeftDrive goes forward at 30% velocity, the motor group RightDrive goes forward at 100% velocity, and vice versa. this will hopefully make turning smoother but I am having trouble making code that performs different actions when a joystick is moved in two different direction because it is just one axis in the code

Thanks

You can do somethibg like this (not actual code, just pseudocode);
Loop infinity(
//left?
If axis4>0 , then
LeftMotor velocity = 0.3*\axis4Position
RightMotor velocity = axis4Position
//Right?
If axis4<0, then
LeftMotor velocity = -1*axis4Position
RightMotor velocity = -0.3*axis4Position
)

2 Likes

Assuming your arcade control is set up right, you should have no problem turning while driving. If you have one-stick arcade you can push the stick diagonally, and on split arcade you move the turn stick and the drive stick at the same time. You can use the search bar on the forum to find how arcade control is usually done.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.