Skip to content

Driving the Robot

2018macbookair edited this page Jun 6, 2024 · 4 revisions

So, you want to drive the robot? For the sake of this we are going to assume that you are just curious about the drive() method. The drive() method uses something called Percent Output. Percent Output is fairly simple, but “Percent” is a misnomer. It’s more of a fractional duty cycle. Percent Output in FRC roughly equates to a percentage of the input voltage. It always ranges from -1 to 1, and the “percent output” aspect of this is that PWM modulation is applied to effectively vary the applied voltage from -1 (100% of battery power) to 1 (100% of battery power). With this approach, things are always either fully “on” or fully “off”, but the time-averaged voltage is varied across this full range. The reason for doing this is efficiency. Power is either applied to the motor, or it is dissipated as heat. The way to get the highest efficiency is to do the fully on/off thing. This is all combined with the need to apply voltage to different coils of wire inside the motor at different points in time. Now with percent output explained, let me explain why we care. For the drive() method, it is controlled by percent output, not only just because I'm too lazy to change it, but also because it makes it really easy for control, with most joysticks also having a range of -1 to 1. This is also referred to as velocity based control, because the joystick inputs are translated almost directly into velocity, allowed for easily repeatable velocities. Say you wanted to move the robot forwards at exactly 7.8m/s. There would be a consistent value that moves the robot forward at exactly that speed, and it would work consistently.

The downside of this is that we have to use PID loops to calculate for any exact movement to positions or rotation. For more information on this, reference the PID loops section. An example of using the drive method would be: drive(0.5, 0.5, 0.5, true, true). This simply means that it will move half speed forward, and half speed to the right, as negative is backwards/left depending on which position it's in. The first boolean, generally set to true is if the movement speeds passed to the drive are field relative or robot relative. For driving using inputs, the speeds are usually set as field relative, but if you are doing autonomous, field relative should be set to false. The second boolean, also generally set to true is whether rate limiting is enabled. Rate limiting is simply a softening of movements so that the robot is easier and more intuitive to control.

Clone this wiki locally