|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Joystick Buttons
We have two servos on our robot, which I would like to have controlled by a single button on the joystick. The servos will go up when the button is pressed, and down when it's released. I can't seem to get the buttons on the joystick to work. stick->GetRawButton(1) works, but that corresponds to the trigger, which is already in use.
I can't seem to get "GetTop()" or "GetRawButton(2)" to work, though. We've verified that the servos work, but the button won't work. We updated the software on the driver station when we set it up. Are there any updates that we missed? Thanks in advance. |
|
#2
|
|||
|
|||
|
Re: Joystick Buttons
Hmmm...have you set the software to printf() the value of the joystick buttons? If it prints 'false' when you've got the joystick button down, you've got hardware problems (or really bad software problems). If it prints 'true' (or something to that extent) when the button is down, you've got software problems.
Out of curiosity, are you controlling your servos through the Servo class? I wasn't able to get them to work with that...currently I drive them with a RobotDrive, although that's a kluge. |
|
#3
|
|||
|
|||
|
Re: Joystick Buttons
How do I use the printf() function? Right now I'm using a laptop that is wirelessly connected to the router, which I download the code through. Do I have to be "running" code instead of "downloading" it?
I am using the servo class to control the servos, and it worked wonderfully. Like I said, I use stick->GetRawButton(1); which gets the value of the trigger. That works. But none of the other buttons work--not GetTop() or GetRawButton(x). |
|
#4
|
|||
|
|||
|
Re: Joystick Buttons
You should be debugging your code...FRC has instructions for that in one of their manuals. Put printf() statements in your code...I assume you know how to do this. If not, http://www.learncpp.com is a good place for C++ tutorials and will explain that.
Then, in your Remote Systems window down in the left-hand corner of WR, right click on the cRio, then about halfway up the menu there will be a submenu whose name I cannot remember. It's right under the Reset Target section of the menu. In that submenu there will be a Target Console option. Click that, and you will get the cRio's console. All your printf() statements will go there. Thanks for the info on the servo class...I'll keep trying =] |
|
#5
|
|||
|
|||
|
Re: Joystick Buttons
To use "printf", simply do
Code:
printf("Hello World!");
Code:
float number = 7.241;
printf("The value is: %f", number); // The value is: 7.241
![]() For the joystick issue, (I haven't actually tested it myself), I think it should work like: Code:
Joystick stick(1); // Joystick plugged into USB port 1
Servo sv1(5);
if(stick.GetRawButton(2))
{
// Set the servo
sv1.set(someAngle);
}
![]() |
|
#6
|
||||
|
||||
|
Re: Joystick Buttons
LinuxMercedes, do you do
Servo sv(3); sv.Set(value between 0 and 170); ? |
|
#7
|
|||
|
|||
|
Re: Joystick Buttons
That's how we've been doing it, byteit. It worked fine for the servos. Actually it worked very well. It's just the buttons that our code hasn't been working with.
We've been debugging, just not with the console... I'll try this today. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Labview Joystick Buttons... | team877 | NI LabVIEW | 36 | 02-17-2009 07:23 PM |
| Joystick buttons access | byteit101 | C/C++ | 3 | 01-14-2009 07:38 PM |
| Programing joystick buttons | Shivang1923 | Programming | 8 | 02-09-2008 04:21 PM |
| Buttons to Pins on Joystick | yarb65 | Electrical | 1 | 08-24-2007 08:39 PM |
| Assigning Joystick buttons.... | archiver | 2001 | 5 | 06-24-2002 12:59 AM |