Go to Post Pneumonoultramicroscopicsilicovolcanoconiosis. Be careful. - Ether [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 19-01-2015, 16:40
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 229
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
How to use Xbox controller with RobotPy?

Hi! So we have our code working with the Xbox controller's left joystick but that was just using the
Code:
self.stick=wpilib.Joystick(0)
and we can't figure out how to use the right joystick with it. Any help would be greatly appreciated!
  #2   Spotlight this post!  
Unread 19-01-2015, 18:20
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,102
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: How to use Xbox controller with RobotPy?

Recommend you search the forums, as your problem is a WPILib problem, and not necessarily specific to RobotPy.

Here's one that looks useful: http://www.chiefdelphi.com/forums/sh...highlight=xbox
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #3   Spotlight this post!  
Unread 19-01-2015, 18:36
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 229
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Re: How to use Xbox controller with RobotPy?

Quote:
Originally Posted by virtuald View Post
Recommend you search the forums, as your problem is a WPILib problem, and not necessarily specific to RobotPy.

Here's one that looks useful: http://www.chiefdelphi.com/forums/sh...highlight=xbox
After so more research, it seems like I have to make a AxisType Class and then put in what each axis is? Thanks for the response!
  #4   Spotlight this post!  
Unread 19-01-2015, 19:11
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,102
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: How to use Xbox controller with RobotPy?

Quote:
Originally Posted by team-4480 View Post
After so more research, it seems like I have to make a AxisType Class and then put in what each axis is? Thanks for the response!
Yeah, the docs aren't super clear on that, I'll need to update. When AxisType is specified, what it really means is pass in one of the constants that is defined in the class, or you can also just pass in a number. So something like...

Code:
joystick = wpilib.Joystick(0)
rightX = joystick.getAxis(4)
rightY = joystick.getAxis(5)
That might work. It might not.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #5   Spotlight this post!  
Unread 19-01-2015, 19:17
Nunez4296's Avatar
Nunez4296 Nunez4296 is offline
Programmer
AKA: Joseph Nuņez
FRC #4296 (Trident Robotics)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2013
Location: Gurnee IL
Posts: 39
Nunez4296 is an unknown quantity at this point
Re: How to use Xbox controller with RobotPy?

From the looks of it, your code is only written for one axis, axis 0. That is most likely the reason why only the left side is working. Go to the driver station with your controller plugged in and then to the USB panel. There you will find the connected joystick and all the buttons. Any button you press or joystick you move will show you the associated button value that you should implement into the code. remember that these are all array values, so you start with axis 0 and button 0.
  #6   Spotlight this post!  
Unread 19-01-2015, 20:30
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 229
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Re: How to use Xbox controller with RobotPy?

Quote:
Originally Posted by Nunez4296 View Post
From the looks of it, your code is only written for one axis, axis 0. That is most likely the reason why only the left side is working. Go to the driver station with your controller plugged in and then to the USB panel. There you will find the connected joystick and all the buttons. Any button you press or joystick you move will show you the associated button value that you should implement into the code. remember that these are all array values, so you start with axis 0 and button 0.
Thanks to both of you for the help and I will try it tomorrow!
  #7   Spotlight this post!  
Unread 20-01-2015, 17:33
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 229
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Re: How to use Xbox controller with RobotPy?

Quote:
Originally Posted by virtuald View Post
Yeah, the docs aren't super clear on that, I'll need to update. When AxisType is specified, what it really means is pass in one of the constants that is defined in the class, or you can also just pass in a number. So something like...

Code:
joystick = wpilib.Joystick(0)
rightX = joystick.getAxis(4)
rightY = joystick.getAxis(5)
That might work. It might not.
The joystick didn't work sadly. Is that the best way to do it or is there other ways? Thanks!
  #8   Spotlight this post!  
Unread 20-01-2015, 18:22
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,102
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: How to use Xbox controller with RobotPy?

I would see what code people are using in other languages, and translate it to python. It's definitely a WPILib related issue, so presumably someone else has had the problem too and fixed it.

I don't have an XBox, so I can't test it personally.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #9   Spotlight this post!  
Unread 20-01-2015, 19:20
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 229
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Re: How to use Xbox controller with RobotPy?

Quote:
Originally Posted by virtuald View Post
I would see what code people are using in other languages, and translate it to python. It's definitely a WPILib related issue, so presumably someone else has had the problem too and fixed it.

I don't have an XBox, so I can't test it personally.
Just a quick side question, how can you use one motor and one axis for aracadeDrive? I tried just using the ".set()" but that didn't work. Thanks again for all your help!
  #10   Spotlight this post!  
Unread 20-01-2015, 20:22
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,102
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: How to use Xbox controller with RobotPy?

Quote:
Originally Posted by team-4480 View Post
Just a quick side question, how can you use one motor and one axis for aracadeDrive? I tried just using the ".set()" but that didn't work. Thanks again for all your help!
I'm not quite sure what you mean. If you want to set a single motor:

Code:
joystick = wpilib.Joystick(0)
motor = wpilib.Talon(2)

motor.set(joystick.getX())
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #11   Spotlight this post!  
Unread 20-01-2015, 20:35
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 229
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Re: How to use Xbox controller with RobotPy?

Quote:
Originally Posted by virtuald View Post
I'm not quite sure what you mean. If you want to set a single motor:

Code:
joystick = wpilib.Joystick(0)
motor = wpilib.Talon(2)

motor.set(joystick.getX())
Do the motor.set and things like that have to be in the Teleop function to work properly? Thanks!
  #12   Spotlight this post!  
Unread 20-01-2015, 20:47
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,102
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: How to use Xbox controller with RobotPy?

Quote:
Originally Posted by team-4480 View Post
Do the motor.set and things like that have to be in the Teleop function to work properly? Thanks!
The roboRIO will disable motors when the robot is not enabled, so I would not recommend setting the motors outside of teleop/autonomous modes.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Closed Thread


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 02:55.

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