Go to Post Robotics competitions take place in the same "perfect" environment that basic physics equations take place in. :rolleyes: - Branden Ghena [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 23-01-2009, 17:55
KRibordy KRibordy is offline
Registered User
FRC #1000 (Cybearcats)
Team Role: Mentor
 
Join Date: Mar 2008
Rookie Year: 2006
Location: Valparaiso, IN
Posts: 36
KRibordy is an unknown quantity at this point
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.
Reply With Quote
  #2   Spotlight this post!  
Unread 23-01-2009, 20:33
LinuxMercedes LinuxMercedes is offline
Real men use Macs
FRC #1444 (Lightning Lancers)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: St. Louis, MO
Posts: 22
LinuxMercedes is an unknown quantity at this point
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.
__________________
Reply With Quote
  #3   Spotlight this post!  
Unread 23-01-2009, 21:03
KRibordy KRibordy is offline
Registered User
FRC #1000 (Cybearcats)
Team Role: Mentor
 
Join Date: Mar 2008
Rookie Year: 2006
Location: Valparaiso, IN
Posts: 36
KRibordy is an unknown quantity at this point
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).
Reply With Quote
  #4   Spotlight this post!  
Unread 24-01-2009, 01:02
LinuxMercedes LinuxMercedes is offline
Real men use Macs
FRC #1444 (Lightning Lancers)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: St. Louis, MO
Posts: 22
LinuxMercedes is an unknown quantity at this point
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 =]
__________________
Reply With Quote
  #5   Spotlight this post!  
Unread 24-01-2009, 01:09
Pancake Pancake is offline
Registered User
FRC #0991 (The Dukes)
Team Role: Photography
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Phoenix
Posts: 11
Pancake is an unknown quantity at this point
Re: Joystick Buttons

To use "printf", simply do
Code:
printf("Hello World!");
Or if you want to print a variable:
Code:
float number = 7.241;
printf("The value is: %f", number); // The value is: 7.241
And you need the cRIO connected to your computer via a serial cable to see the output

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);
}
Hope this helps, haven't actually tried this myself
Reply With Quote
  #6   Spotlight this post!  
Unread 24-01-2009, 08:16
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Joystick Buttons

LinuxMercedes, do you do
Servo sv(3);
sv.Set(value between 0 and 170);
?
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #7   Spotlight this post!  
Unread 24-01-2009, 10:06
KRibordy KRibordy is offline
Registered User
FRC #1000 (Cybearcats)
Team Role: Mentor
 
Join Date: Mar 2008
Rookie Year: 2006
Location: Valparaiso, IN
Posts: 36
KRibordy is an unknown quantity at this point
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.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Labview Joystick Buttons... team877 NI LabVIEW 36 17-02-2009 19:23
Joystick buttons access byteit101 C/C++ 3 14-01-2009 19:38
Programing joystick buttons Shivang1923 Programming 8 09-02-2008 16:21
Buttons to Pins on Joystick yarb65 Electrical 1 24-08-2007 20:39
Assigning Joystick buttons.... archiver 2001 5 24-06-2002 00:59


All times are GMT -5. The time now is 14:08.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi