We got two Smart Robot Servo for our shooter hood and we want it to run in continuous mode. I have been looking up posts on chiefdelphi and some other places to find example codes but I could not find anything. Does anyone have example code for the servo in continuous mode?
Do you have a SRS Programmer to set it to continuous mode? WIthout this, I do not believe there is any way to set the Smart Robot Swervo to continuous mode just using code. Once it’s set to continuous mode, just giving the servo a percent output PWM signal should make it move continuously.
Yes we did use the SRS Programmer to set both servos to continuous mode. I just do not know where to start with the code to make it run with a certain amount of time from using buttons on the joystick.
There are multiple approaches to this. Without knowing much about how your code is set up, the simplest way would be to use a
ParallelDeadlineGroup() using a wait command as the time you want the command to execute and a second command to set the servo output. An example of this in java would be something like this:
joystickButton.whenPressed( new ParallelDeadlineGroup( new WaitCommand(commandExecutionTime), new SetServoOutput(m_servoSubsystem, servoOutput) ) );
Conveniently, you can do exactly this with less boilerplate by using the
joystickButton.whenPressed( new SetServoOutput(m_servoSubsystem, servoOutput) .withTimeout(commandExecutionTime) );
Oblarg beat me to it, but i’ll share the link to the documentation. There are lots of nice convenience features, like
withTimeout baked into WPILib!
Yeah, I keep forgetting about the convenience features that were added with the new command base. I’m just used to everything needing to be a command from the old command base.
yeah, though my favorite convenience feature is still the Trigger Composition.