|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Anyone Have Servo Example Code?
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.
|
|
#3
|
|||
|
|||
|
Re: Anyone Have Servo Example Code?
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?
|
|
#4
|
|||
|
|||
|
Re: Anyone Have Servo Example Code?
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.
|
|
#5
|
|||
|
|||
|
Re: Anyone Have Servo Example Code?
Trust me, I made sure the robot was enabled.
|
|
#6
|
||||
|
||||
|
Re: Anyone Have Servo Example Code?
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_Mai...allTapper.java Commands: https://github.com/Team2168/2014_Mai...ommands/tapper And an example from 2016 for controlling hood position: Subsystem: https://github.com/Team2168/2016_Mai...ooterHood.java Command: https://github.com/Team2168/2016_Mai...odToAngle.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. Last edited by otherguy : 03-02-2017 at 22:15. |
|
#7
|
|||
|
|||
|
Re: Anyone Have Servo Example Code?
Awesome, appreciate it.
|
|
#8
|
|||
|
|||
|
Re: Anyone Have Servo Example Code?
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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|