Hello,
I’m the lead programmer for team 3706. Its my first year so i need a little help. I was wondering on how you add buttons to the servo motors in the program. I already put the three servo motors i need in the begin and finish sections.I just don’t know how to add it to the teleop section. I want my joystick2 to control three motors that will move a arm on the robot.
Can you give a little more detail about what you want the joystick to do? Which controls on the joystick should cause what actions to occur on the servos?
We are working on getting our arm working. For example we want the trigger button to move the arm up once squeezed and move it down when squeezed a second time. Our arm is being driven by the set of window motors from the KOP.
window motors aren’t servos, they’re just normal motors being used in a servomechanism. As such, you should be controlling them through a victor or a jaguar as you would a drive motor. Then you would add on the position feedback and control on top of that.
If you want a single trigger squeeze to move the arm to a specific position, you’ll need a way for the program to know when the arm is at that position. What will you be using to do that?
As Alan said, you’ll need to have some type of sensor which supplies feedback based on a setpoint. For example, if you are reading the angle of an extension with a single pivot point, a potentiometer, gyroscope, or encoder will suit your needs.
In this example, you’d read the output, and evaluate if it’s the value you want (or at least within a range of values). If it’s not, you’ll have to set the motor output of the motor controlling the extension to move in either direction, based on the magnitude of your error.
If you are controlling a servo, you can use the Servo Set Angle or Servo Set Position function within the WPI Robotics Library to set the servo to a specific angle or position upon the press of a button.
It is actually a lot simpler than that. The sensors you are looking for are limit switches. You need one that is triggered when the arm is up, an another that is triggered when the arm is down. Squeeze once and have the arm move up until the switch is turned off (normally on is a much better configuration than normally off). Squeeze it a second time and the arm moves down until the other switch is turned off.