Kaj Drive in c++?

I’ve seen quite a bit of posts talking about 2 stick arcade drive or kaj drive. With this method, 1 stick controls the rotation of the robot, and the other controls the throttle of the robot or thumb pads in the case of a controller . I’m not sure how to implement this in c++ and would love some help setting this up.

This is what my team has done for the last few years now. It can be done with one line of code that is built in to the RobotDrive class in wpilib.


yourRobotDriveobject.ArcadeDrive(joystick.getRawAxis(forwardaxis), joystick.getRawAxis(rotateaxis));

While that method should work for a single joystick, it doesn’t appear to work if using 2 stick arcade or Kaj drive. Any idea if changing arcade drive in the robotdrive header file could fix this?

I think this is roughly what you’re looking for

float speed = throttleStick->GetY();
float turn = turnStick->GetX();
float leftSpeed = speed + turn;
float rightSpeed = speed - turn;
//output speed to motors

ekovacs example above is using the following form of ArcadeDrive.

void ArcadeDrive(float moveValue, float rotateValue, bool squaredInputs = true);

It doesn’t matter where the moveValue and rotateValue come from. You could read from a second joystick, or a sensor, or anything else.

This is the form that we used, with the moveValue coming from a the left thumb stick/dpad on a controller and the rotateValue coming from the right thumb stick. But as Joe said, the values can come from anywhere.

Thanks for all the help! I won’t be able to work on the robot until monday, but when I do, you can bet I’ll implement this!