|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Problems running servos
Hi everyone,
I am a coach on Team 3373 out of Warrenton, VA. Recently, our programming team was writing some code for a generic servo (I didn't think it was necessary to label the part number) in order to make sure we know how to write the code. Displaying only the relevant portions, we defined a joystick (in Module 1) and a servo instance. Then we initialized the servo instance. We physically connected it to Module 2, Port/Channel 9. Afterwards, we noted because the joystick GetRawAxis function assumes values from [-1,1] and the Servo Set function assumes values from [0,1] we did a little algebra on the Servo Set argument. Lastly, I printed to the driver station the value of the Servo Set argument and I saw it change as I moved the Xbox joystick. HOWEVER, the servo itself does not move. We do have other code written (not displayed) which moves a motor and gets camera feed etc. which all work fine. But for whatever reason we cannot get the Servo to work. There are a limited number of functions for the Servo class so between trying different things and looking on Google, we just need a fresh pair of eyes. Can anyone make any suggestions? The code compiles when we run it. We obtained the skeleton of it from the Simple Robot Template in Windriver. Many thanks, Brian #####BEGIN CODE ##### #include “WPILib.h” class RobotDemo : public SimpleRobot { Joystick Xbox; Servo Elevation; public: RobotDemo() Xbox(1), Elevation(2,9) { /* GetWatchdog().SetEnabled(false); */ } void Autonomous() { /* commented out code */ } void OperatorControl() { while (IsOperatorControl()) { Elevation.Set((Xbox.GetRawAxis(5)+1)/2); } } }; START_ROBOT_CLASS(RobotDemo); #####END CODE ##### |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|