Drive an individual moter

We’re using eclipse to program our cRIO, and are having difficulty getting the .set method to work. How do we use it properly, and is there a better/different way of controlling specific motors?

Use the PWM class. You construct it with the port # of where the speed controller is connected to. Then use its setRaw method. That is the way I prefer, but there are multiple ways to do it. Each speed controller gets its own PWM object associated to it.

If you use something like


import edu.wpi.first.wpilibj.Jaguar;

public class FullSpeedAhead{
    Jaguar motor;
    public FullSpeedAhead(){
        motor = new Jaguar(1);
    }
    public void go(){
        motor.set(1);
    }
}

then your code should work just fine regardless of your IDE, assuming you have your files in the right place (edu.wpi.first.wpilibj.TeamXXYY seems to be standard). Jaguar.set() is no better/worse than the methods it actually uses to set the given value to the Jaguar, but using it is simpler than other methods.

What is your reasoning to support going straight through to the PWM class? Are there any benefits provided over using a Jaguar?

Jaguar.set(double value) is equivalent to PWM.setRaw(int channel, double value). With the PWM class, you need to specify the channel each time you change the speed of a Jaguar; however, you just need to change the speed with the Jaguar class. That’s the only difference.

I can’t think of any reason to use the PWM class instead of the jaguar class, except to brag that you like to do things low level. On the other hand, using the PWM class without fully understanding all the options will lead to worse performance.

That is true for the set methods, but you also have to look at how the Jaguar is constructed.The Jaguar constructor sets particular parameters for the parent PWM object that are based on the specific pulse width timings that correspond to a Jaguar’s minimum, maximum, centerpoint and deadband.

The Jaguar and Victor objects exist for a reason, nobody would have bothered to code them otherwise. Please save yourself the headache and use the appropriate speed controller object instead of the raw PWM class.

PWM is the mother class of the Speed Controllers. The OP did not specify any speed controllers, so I had to appeal to the common denominator. I use it personally.

If you really want to brag about the low level… Use the tDIO class found in fpga package.

I don’t know where you got that idea from… But for 3 years, I have used the PWM class and its “setRaw” function without having to do that. Both for Victors and Jaguars.