RobotDrive Function to Drive at set speed

So I’m looking for function(s) which I can use to drive my robotDrive at a certain speed in a controlled matter for the Autonomous portion.
I also want a spin function for testing/

I’m totally open to new suggestions so here is what is want the functions to do.

Spin();

I want it to do a simple, medium -paced 360. That’s it.

Drive(); (its not called that, but I mean the driving straight).

i just want the robot to drive forward a meter or two at a medium pace.
In the real program, I make it drive back and forth but all I want to know is how to make it drive.

That’s it really. I’m just looking for the appropriate fucntions that I can use with my drive train.

Thanks!

Assuming you’re using Java for a minute: To make your robot drive for auto, if you’re using the robotDrive class, you can just use the method drive().

drive() takes two parameters, the first is the output magnitude, the second is the curve magnitude, both should range from -1 to 1.

This function will not make your robot turn a precise amount of degrees, or drive a precise distance forward. Both of these things require sensor feedback to work (a gyro for turning, encoders for driving a distance), and you’ll want to write at least a simple proportional control loop for this sort of control.

Note that robotDrive is deprecated in favor of differentialDrive, which has basically the same functions for the most part, but does not itself have a “drive()” function. You can use “arcadeDrive” with the third parameter as “false” for identical behavior.

RobotDrive documentation in the API docs: http://first.wpi.edu/FRC/roborio/release/docs/java/edu/wpi/first/wpilibj/RobotDrive.html

DifferentialDrive documentation in the API docs: http://first.wpi.edu/FRC/roborio/release/docs/java/edu/wpi/first/wpilibj/drive/DifferentialDrive.html

Yea, I’m using Java…

As far as I’m concerned, we don’t have any of those sensors so do you know any functions that don’t need any? I can’t find any anywhere…

Thanks!

You can use the above functions without sensors (the functions themselves don’t actually take sensors as input, they just tell the robot to move), but all you will be able to do is command the robot to move or stop moving.

You have no way of measuring how far the robot moved or how much it turned, so you can’t drive to a specified distance or drive to a specified angle. You can write code using these functions combined with a timer or something in order to move the robot for set intervals of time, but this may not produce results accurate enough for what you are trying to do. It’s better than no autonomous mode at all, as you can “guess and check” by adjusting how long you allow the robot to drive straight / turn until you get what you want, but the autonomous behavior will not be consistent - as you use different batteries of different levels of charge, etc. the robot may move more or less distance within the same interval of time.

Some very rough pseudo code for iterative robot code might be:

init:
start timer

periodic:
if (timer < 5 seconds)
drive(1,0)
else
drive(0,0)

You may want to look into example code for simple autonomous routines, available in this forum if you search or on other various websites.

driveTrain.arcadeDrive(forward/backward speed, rotate speed);

curvatureDrive() is a closer analog to RobotDrive.drive() than arcadeDrive() because curvatureDrive()'s rotation command controls the curvature of the turn independently of the forward speed. arcadeDrive()'s turning radius for a given rotation command varies with the forward speed.