Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Kaj Drive in c++? (http://www.chiefdelphi.com/forums/showthread.php?t=129948)

thatprogrammer 02-07-2014 10:16

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.

ekovacs 02-07-2014 11:37

Re: Kaj Drive in c++?
 
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.

Code:

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

thatprogrammer 02-07-2014 12:00

Re: Kaj Drive in c++?
 
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?

connor.worley 02-07-2014 12:11

Re: Kaj Drive in c++?
 
I think this is roughly what you're looking for

Code:

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


Joe Ross 02-07-2014 12:24

Re: Kaj Drive in c++?
 
Quote:

Originally Posted by ekovacs (Post 1391901)
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.

Code:

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

Quote:

Originally Posted by thatprogrammer (Post 1391906)
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?

ekovacs example above is using the following form of ArcadeDrive.
Code:

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.

ekovacs 02-07-2014 12:56

Re: Kaj Drive in c++?
 
Quote:

Originally Posted by Joe Ross (Post 1391910)
ekovacs example above is using the following form of ArcadeDrive.
Code:

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.

thatprogrammer 02-07-2014 14:26

Re: Kaj Drive in c++?
 
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!


All times are GMT -5. The time now is 12:09.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi