Go to Post At one point, we were all once rookies. - Vin211 [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 Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 02-23-2015, 11:44 AM
Travis Hoffman's Avatar Unsung FIRST Hero
Travis Hoffman Travis Hoffman is offline
O-H
FRC #0048 (Delphi E.L.I.T.E.)
Team Role: Engineer
 
Join Date: Sep 2001
Rookie Year: 2001
Location: Warren, Ohio USA
Posts: 4,044
Travis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond repute
Setting up a Joystick class for Logitech Attack 3?

It seems the default definition for a Joystick class includes a twist axis, since the default joystick provided to rookies has such an axis. The first axis is X, the second Y, the third twist, and the fourth throttle.

Well, when we try to use our trusty Logitech Attack 3's, these do not possess a twist axis, so a formerly-functional GetThrottle() call returns nothing, since the default for throttle in the class is the 4th axis.

I was wondering why we were seeing "WARNING: Joystick Axis missing, check if all controllers are plugged in" showing up on the console, and now I think I understand why. I'd like to get rid of this warning.

I understand I can get the throttle value by calling GetZ() instead, but I wanted to know, short of writing a custom class, is there a way to instantiate a joystick class that correctly defines the axes and buttons for a Logitech Attack 3 such that GetThrottle will work?
__________________

Travis Hoffman, Enginerd, FRC Team 48 Delphi E.L.I.T.E.
Encouraging Learning in Technology and Engineering - www.delphielite.com
NEOFRA - Northeast Ohio FIRST Robotics Alliance - www.neofra.com
NEOFRA / Delphi E.L.I.T.E. FLL Regional Partner

Last edited by Travis Hoffman : 02-23-2015 at 12:12 PM.
Reply With Quote
  #2   Spotlight this post!  
Unread 02-23-2015, 12:34 PM
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Properly calling a Logitech Attack 3 Joystick Class

I don't understand why you suggest that writing a custom class is not the appropriate answer. If you want to support the Attack 3 in particular, I think the best way to do it is to extend the Joystick class as an Attack_3 class.

Since the named functions don't give you what you want, the second-best way to do it is probably to avoid them and instead use things like getRawAxis().

We did basically the custom class solution in LabVIEW for several different brands of game controllers this year. It lets us provide the axes and buttons as named components of a cluster, which helps keep the programmer and the driver speaking the same language. Instead of having to remember which array element's number is the left stick's Y axis, we just unbundle LeftX. Similarly, we can refer to the A, X, Start, etc. buttons by name.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-23-2015, 01:03 PM
Travis Hoffman's Avatar Unsung FIRST Hero
Travis Hoffman Travis Hoffman is offline
O-H
FRC #0048 (Delphi E.L.I.T.E.)
Team Role: Engineer
 
Join Date: Sep 2001
Rookie Year: 2001
Location: Warren, Ohio USA
Posts: 4,044
Travis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond repute
Re: Properly calling a Logitech Attack 3 Joystick Class

Quote:
Originally Posted by Alan Anderson View Post
I don't understand why you suggest that writing a custom class is not the appropriate answer. If you want to support the Attack 3 in particular, I think the best way to do it is to extend the Joystick class as an Attack_3 class.

Since the named functions don't give you what you want, the second-best way to do it is probably to avoid them and instead use things like getRawAxis().

We did basically the custom class solution in LabVIEW for several different brands of game controllers this year. It lets us provide the axes and buttons as named components of a cluster, which helps keep the programmer and the driver speaking the same language. Instead of having to remember which array element's number is the left stick's Y axis, we just unbundle LeftX. Similarly, we can refer to the A, X, Start, etc. buttons by name.
I don't enjoy diverging from the well-beaten path, so if there was a way to instantiate a standard joystick class to fit an Attack 3 without making a custom class, I'd be all for it, which is why I asked.

As for the custom class, it doesn't help matters much when the WPILib C++ source code location isn't a heavily advertised thing...I found it...but it doesn't seem to be something that is as readily available as it was in the past.

We read all joystick and gamepad values into more functionally-descriptive variables, and this code is well-commented to provide a cross reference between actual controller axis/button and function, so using "GetZ" or "GetRawAxis" won't be an issue.
__________________

Travis Hoffman, Enginerd, FRC Team 48 Delphi E.L.I.T.E.
Encouraging Learning in Technology and Engineering - www.delphielite.com
NEOFRA - Northeast Ohio FIRST Robotics Alliance - www.neofra.com
NEOFRA / Delphi E.L.I.T.E. FLL Regional Partner
Reply With Quote
  #4   Spotlight this post!  
Unread 02-23-2015, 01:40 PM
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Properly calling a Logitech Attack 3 Joystick Class

Quote:
Originally Posted by Travis Hoffman View Post
I don't enjoy diverging from the well-beaten path, so if there was a way to instantiate a standard joystick class to fit an Attack 3 without making a custom class, I'd be all for it, which is why I asked.
There does seem to be a way in the basic Joystick class to remap axes to the X/Y/Z/Throttle functions, but I don't use C++ enough to have tried it.

Quote:
As for the custom class, it doesn't help matters much when the WPILib C++ source code location isn't a heavily advertised thing...I found it...but it doesn't seem to be something that is as readily available as it was in the past.
What do you need the source code for? All you'd be doing is inheriting from and extending an existing class. You wouldn't be reimplementing any of the lower-level code.

Quote:
We read all joystick and gamepad values into more functionally-descriptive variables, and this code is well-commented to provide a cross reference between actual controller axis/button and function, so using "GetZ" or "GetRawAxis" won't be an issue.
Such cross-referencing would seem to be a natural fit for a brand-specific joystick class, and perhaps even a higher-level "driver controls" class as well. Maybe you're thinking of something more complicated than extending the base class, but I don't believe that much work is called for here.
Reply With Quote
  #5   Spotlight this post!  
Unread 02-23-2015, 01:55 PM
Travis Hoffman's Avatar Unsung FIRST Hero
Travis Hoffman Travis Hoffman is offline
O-H
FRC #0048 (Delphi E.L.I.T.E.)
Team Role: Engineer
 
Join Date: Sep 2001
Rookie Year: 2001
Location: Warren, Ohio USA
Posts: 4,044
Travis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond repute
Re: Properly calling a Logitech Attack 3 Joystick Class

Quote:
Originally Posted by Alan Anderson View Post
There does seem to be a way in the basic Joystick class to remap axes to the X/Y/Z/Throttle functions, but I don't use C++ enough to have tried it.
I don't believe you can re-map the default value of the throttle, which is set to axis 3 (0-based values). You can define the number of axes and buttons, but not which axis is which.

Quote:
What do you need the source code for? All you'd be doing is inheriting from and extending an existing class. You wouldn't be reimplementing any of the lower-level code.
Last I "wrote" a custom class, I took gyro.cpp/.h source, renamed the files gyro48.cpp/.h, and changed the code to permit adjustment of the sensitivity parameter, which was previously not exposed to the end user. Seemed easier and more likely to work to adapt existing code than figure out all the BS of inheritance and writing my own classes and worrying about missing some inane piece of required syntax that would break the code or worse, compile it and cause unintended results I am not equipped to debug. If this somehow violates some code of appropriateness seasoned programmers adhere to, well, I'm not a seasoned programmer, nor do I aspire to be, so I guess it doesn't matter.

In the case of the joystick class, I'd simply change the default throttle axis from 3 to 2. Bing bang zoom. But with GetZ or GetRawAxis in the default class, I don't need to do that, so I won't even bother.
__________________

Travis Hoffman, Enginerd, FRC Team 48 Delphi E.L.I.T.E.
Encouraging Learning in Technology and Engineering - www.delphielite.com
NEOFRA - Northeast Ohio FIRST Robotics Alliance - www.neofra.com
NEOFRA / Delphi E.L.I.T.E. FLL Regional Partner

Last edited by Travis Hoffman : 02-23-2015 at 01:57 PM.
Reply With Quote
  #6   Spotlight this post!  
Unread 02-23-2015, 02:34 PM
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Properly calling a Logitech Attack 3 Joystick Class

Quote:
Originally Posted by Travis Hoffman View Post
I don't believe you can re-map the default value of the throttle, which is set to axis 3 (0-based values). You can define the number of axes and buttons, but not which axis is which.
The documentation for the Joystick::SetAxisChannel() method suggests otherwise.

Quote:
Last I "wrote" a custom class, I took gyro.cpp/.h source, renamed the files gyro48.cpp/.h, and changed the code to permit adjustment of the sensitivity parameter, which was previously not exposed to the end user.
If you were adding an interface to a private attribute of the class, then the way you did it was probably necessary. But was there ever a version of the Gyro class that didn't have the SetSensitivity() method?

Quote:
Seemed easier and more likely to work to adapt existing code than figure out all the BS of inheritance and writing my own classes and worrying about missing some inane piece of required syntax that would break the code or worse, compile it and cause unintended results I am not equipped to debug. If this somehow violates some code of appropriateness seasoned programmers adhere to, well, I'm not a seasoned programmer, nor do I aspire to be, so I guess it doesn't matter.
Since you seem to think subclassing by way of inheritance is complicated, I suspect you don't know what it means. It is not complicated. It should be as easy as
Code:
public class Axis_3 extends Joystick {
  float Axis_3::GetThrottle()
  {
	return GetRawAxis(2);
  }
}
That's kind of crude, but it should be effective. Note that I don't use C++ enough to be confident that I've done it correctly. Perhaps someone else with more experience and expertise can chime in and either confirm or correct my code.

Quote:
In the case of the joystick class, I'd simply change the default throttle axis from 3 to 2. Bing bang zoom. But with GetZ or GetRawAxis in the default class, I don't need to do that, so I won't even bother.
With the existence of SetAxisChannel(), I think you can indeed change the throttle axis of any Joystick object from 3 to 2 without even creating a new class.
Reply With Quote
  #7   Spotlight this post!  
Unread 02-23-2015, 03:47 PM
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 152
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: Properly calling a Logitech Attack 3 Joystick Class

I concur with Alan. Making a specific derivative of Joystick is the way to go. I think there's a mis-understanding with what this means. The following links will show an example of deriving jankyXBoxJoystick from Joystick - cpp and header folllow...

https://github.com/FRCTeam1967/FRCTe...oxJoystick.cpp

https://github.com/FRCTeam1967/FRCTe...XboxJoystick.h
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
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


All times are GMT -5. The time now is 10:11 AM.

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