|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
C++ Functions
Is there a function in the WindRiver language that allows me to take the value of the joystick (speed of motor) and make it into a variable so that you can compare how fast you are intending to go based on joystick location and compare it to the actual speed?
|
|
#2
|
|||||
|
|||||
|
Re: C++ Functions
There's not a WPI library function for what you want, but there is a simple feature of the C language called an "assignment". It is implemented using the equals sign = character.
Code:
variable = retrieve_value(); If you didn't already know this, you should probably find and follow a basic C/C++ programming tutorial. Finding and following a knowledgeable mentor would be a good idea as well. [edit] I'm focusing on LabVIEW this season, so I'm not confident in my ability to give correct examples using the C++ classes to an insufficiently experienced programmer. Would someone else please answer specific questions about reading Joystick data? [/edit] Last edited by Alan Anderson : 30-01-2009 at 19:50. Reason: requesting C++ users to help out |
|
#3
|
|||
|
|||
|
Re: C++ Functions
Thank you very much. So if I use the float variable of the retrieve_value() function I can get the joystick speed?
|
|
#4
|
||||
|
||||
|
Re: C++ Functions
No, I don't believe that there's a function called retrieve_value() function. Try looking at WPILib and seeing what functions there are for the joystick class.
|
|
#5
|
||||
|
||||
|
Re: C++ Functions
If you're using the SimpleRobot demo, then you would use the instance of the Joystick class to retrieve the value of the Joystick.
Code:
// assuming that there is an instance of the Joystick class called 'stick' in the current scope float some_X = stick.GetX(); float some_Y = stick.GetY(); Reading the WPILib source code is the best way to understand how things work underneath. |
|
#6
|
|||
|
|||
|
Re: C++ Functions
Okay I'll try that. Thank you very much.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Accelerometer functions | RJohnston | Programming | 3 | 03-05-2008 11:23 |
| Camera functions. | winners | Programming | 1 | 21-01-2006 19:42 |
| Auton + Functions | ten3brousone | Programming | 0 | 27-02-2005 20:11 |
| Cordic functions... | Zalumaskov | Programming | 1 | 13-02-2005 00:58 |
| subs/functions | maDGag | Programming | 2 | 16-02-2003 23:27 |