Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Joystick axis values in new controller (http://www.chiefdelphi.com/forums/showthread.php?t=70645)

koreabell 16-12-2008 13:50

Joystick axis values in new controller
 
Are the values of joystick axis(x,y,and z) in new controller 0 to 255 like last controller? or do they have float value of -1.0 to +1.0?

i can't find what value it returns although my guess is float value of -1.0 to +1.0 since doxgen says function type is float.

just making sure

billbo911 16-12-2008 14:02

Re: Joystick axis values in new controller
 
READ the Programming Guide, your question will be answered.

koreabell 16-12-2008 14:47

Re: Joystick axis values in new controller
 
well I'm programming in c++ and there is no examples or something like that on C/C++ Users Guide for joystick axis value(there's nothing except for big "DRAFT" across the page when you go to joystick page)

there is GetRawAxis() function under joystick class which i assume it will return values between 0 to 255, but that is also float type function while GetRaw() function under PWM class is int type(actually UINT8 type) function.

i know float can handle more wide range than int, thus GetRawAxis() might return values between 0 and 255, but still i'm not sure and i won't know until new controller comes

anyway, i wrote a function that will return values between 0 and 255 even if GetY() or GetAxis() function returns values between -1.0 and +1.0

slavik262 16-12-2008 17:05

Re: Joystick axis values in new controller
 
Refer to the C/C++ Programmer Reference Guide.

You can either use Joystick::GetRawAxis(UINT32 axis), where axis is a value between 1 and 6 specifying the axis, or you can simply use Joystick::GetX() and Joystick::GetY(). All of these functions return a floating point value between -1.0f and 1.0f. Returning values between 0 and 255 will lower your precision, as a floating point variable can hold much more data than an unsigned character.

Joe Ross 16-12-2008 17:23

Re: Joystick axis values in new controller
 
In most cases, the WPI Robotics Library is equivalent between LabVIEW and C++, although the documentation isn't always as good for one or the other. 99% of the time, you should be able to look at the LabVIEW documentation if the C++ documentation isn't clear (and vice versa). Don't get caught up in the name of the document.

Quote:

Returning values between 0 and 255 will lower your precision, as a floating point variable can hold much more data than an unsigned character.
I don't believe that is true in this case. I'm pretty sure that DS sends the values to the cRIO as a single byte integer. In this case, they should be equivilent.

If you are trying to directly copy an algorithm from the IFI controller, it may be easier if you use the raw joystick values and the PWM class, but for implementing new things, you'll probably find it easier to work with the floating point values.

slavik262 16-12-2008 22:19

Re: Joystick axis values in new controller
 
Quote:

Originally Posted by Joe Ross (Post 784540)
I'm pretty sure that DS sends the values to the cRIO as a single byte integer. In this case, they should be equivilent.

I may be wrong, but in doing basic tests it seemed that the joystick had greater precision than that. What you're saying does make sense though. I'll have to take a deeper look at it.

Mike Soukup 17-12-2008 10:38

Re: Joystick axis values in new controller
 
Quote:

Originally Posted by slavik262 (Post 784529)

I've downloaded that document on two computers and when I open it on both I get "The address is not valid" in the right pane. Is it a problem with the user or the document?

Mark McLeod 17-12-2008 11:39

Re: Joystick axis values in new controller
 
Is it due to Microsoft's problem with .chm format?

http://forums.usfirst.org/showthread.php?t=10708


All times are GMT -5. The time now is 17:32.

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