I’m trying to get a linear actuator we got to work. We’re using command based and I’d like to see some examples of how to get these things to move. I plugged it in and it extended to its max length, but using .Set() I can’t seem to get it to work.
The javadoc explains how it works pretty well. Can you post your code?
And the servo is definitely plugged in the correct way around?
The servo is definitely plugged in right, black is ground and white is signal. I have tried multiple command variations that just call a function I setup in the actuator’s subsystem where it does servo.set(double). Is this something that only needs to be called once or does this need to be executed for a certain amount of time in order to work?
This may sound obvious, but we had the same problem. We were testing with the rio powered up but not “enabled” so the PWM ports were disabled. Make sure you have enabled the robot/rio and then try moving the actuator.
Trust me, I made sure the robot was enabled.
Here’s an example subsystem from our 2014 robot which used some fingers on the end of servos to keep the ball centered over our catapult: Subsystem;
https://github.com/Team2168/2014_Main_Robot/blob/master/src/org/team2168/subsystems/ServoBallTapper.java
Commands: https://github.com/Team2168/2014_Main_Robot/tree/master/src/org/team2168/commands/tapper
And an example from 2016 for controlling hood position:
Subsystem:
https://github.com/Team2168/2016_Main_Robot/blob/master/src/org/team2168/subsystems/ShooterHood.java
Command: https://github.com/Team2168/2016_Main_Robot/blob/master/src/org/team2168/commands/shooterhood/DriveShooterHoodToAngle.java
The code is a little rough around he edges, but it’s fairly well commented and it’s all been used in match, so should work unless the Servo class has been changed.
Awesome, appreciate it.
Alright, so today I managed to get the L-16 working perfectly, here are my findings:
-The datasheet for this actuator contains an important piece of information: a PWM pulse width of 2ms fully extends the actuator, and a PWM pulse width of 1ms fully retracts the actuator. The default Max/Min pulse widths for a servo in WPILib is 2.4ms and .6ms, respectively. Be sure to use the setBounds function to ensure that the max and min widths are set for the L-16.
-The basic set function does not seem to work for whatever reason. Using setSpeed(1) and setSpeed(-1) properly calls setMaxPWM and setMinPWM wheres set(1) and set(0) do not properly call them.
-In your commands nothing has to be executed repeatedly. Just call your setSpeed function in the command’s init and the actuator takes care of the rest.
Now that the software is working, these are actually fantastic tools. Just wish that there was more documentation for getting these things to work properly.