|
Re: How to Program a Servo
If you can use robot builder to create your subsystem and commands. Robot builder is create for beginners. Always make sure to review the code it generates and try to understand what it is doing.
The basic approach (no code. I'm a C++ guru and am not confident I would not provide broken java code.).
Create a subsystem and add a Servo to it or add a Servo object to an appropriate existing subsystem.
Solution A
Create a command that moves the servo to position 1.
Create a command that moves the servo to position 2.
Create a command group that adds sequentially:
--MoveServoToPos1Command
--WaitCommand(timeItTakesForServoToRotate45Deg)
--MoveServoToPos2Command
Assign command group to a joystick button.
Solution B
Create a command that moves the servo to position 1 and then waits the timeItTakesForServoToRotate45Deg and then moves the servo to position 2.
The choice is up to you how much you want to break the problem down. 1 command will work but a command group of discrete commands would be more flexible.
__________________
"May the coms be with you"
Is this a "programming error" or a "programmer error"?
|