Command execute(){jaguar.set(speed);} necessary?

Is it necessary to set(); a Jaguar’s speed every time upon execute() in my command?
Example:
can I change this:


        protected void initialize() {

		setTimeout(timeout);

		hasFinished = false;

		arm.setSpeed(this.speed);

	}
	protected void execute() {

		arm.setSpeed(this.speed);

		if (arm.getSensorRetracted())

			hasFinished = true;

	}

TO this:


       protected void initialize() {

		setTimeout(timeout);

		hasFinished = false;

		arm.setSpeed(this.speed);

	}


	protected void execute() {

                //The difference

		if (arm.getSensorRetracted())

			hasFinished = true;

	}

Thanks!

as long as arm is a required subsystem.

also, if your using java, dont set hasFinished but rather just do

protected void isFinished(){
return arm.getSensorRetracted();
}

The safety mechanisms built into WPILib and the cRIO mean you have to update the rate of a Jaguar every (I forget the exact number) microseconds or the digital module won’t update the rate for safety reasons.

As long as you update it faster than once every (I forget the number) microseconds, you should be fine.

The motor safety stuff is enabled by default on the RobotDrive class and disabled by default everywhere else. You can just set the motor speed in the initialize() method and check if it’s finished in the isFinished() method. Often the execute method can be empty.

For safety you can enable the motor safety on the actuator in question or use a timeout to make sure it turns off.

If you are relying on a sensor to stop the motor, you can add a timeout to the command and make sure it ends even if the sensor is never tripped. Just set the timeout to something longer than you’d expect the operation to take. Then in the end() method stop the motor and call the end() method from the interrupted() method. That way the robot won’t destroy itself if a sensor fails.

Look at the gearsbot example or the WPILib Cookbook to see how the timeout stuff works.

Brad