How to arcade drive

I have been working on the CAD for the robot recently, and our drive team is looking to use arcade drive for the first time in our team’s experience. I have been searching WPILib, and for some reason I can’t understand how to get it to work.

My code so far is:

double forwardSpeed = driver->GetRawAxis(1);
double turnAmount = driver->GetRawAxis(2);

frc::RobotDrive::ArcadeDrive(forwardSpeed, turnAmount, false);

but I keep getting the error “error: cannot call member function ‘void frc::RobotDrive::ArcadeDrive(double, double, bool)’ without object”

Any help would be great, because I am in unfamiliar territory with this.

Thanks :slight_smile:

try
DifferentialDrive m_robotDrive = new DifferentialDrive(motor1, motor2);

m_robotDrive.arcadeDrive(forwardSpeed, turnAmount);

If you can’t figure out implementing that into your current code, just follow this guide to generate the example arcade drive project through WPILib.

Thank you so much, our meeting just ended, so I will take a look at it tomorrow!

Cool! I recommend just reading through some of the basic guides on WPILib.org

Oh I’m dumb, did not see this was in C++

You are just calling the namespace entry statically right?

Do you actually have an instance of a RobotDrive in your code somewhere, because you need one…

Edit to add:
Your code needs something like:

frc::RobotDrive m_drive( motor_controllerleft, motor_controllerright);

..... Sometime later in the code ......
m_drive.ArcadeDrive( forwardSpeed, turnAmount)

Secondly, take a look at the DifferentialDrive documentation, it probably does what you’re wanting to do smoothly.

The stuff above should get you working. The reason this doesn’t work is that ArcadeDrive() is an object method, that is, you have to have a specific RobotDrive object to drive. The syntax you used is appropriate for a class method, such as a constructor or a library function.

I have been trying all day and nothing seems to work. Does any of this change if I am using a CAN bus with VictorSPX motor controllers, because everything I’ve seen is for PWM controllers.

IIRC, you have to use the WPI_ version of the CAN speed controller objects to include them in the composite forms like the ArcadeDrive.

This finally got it working, thank you so much for all of your help!

1 Like