Go to Post Ideally, you'll make sure your drive system can handle some Irritating Failures without them becoming Paralyzing Failures. - Billfred [more]
Home
Go Back   Chief Delphi > Technical > Programming > Python
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 19-01-2016, 15:59
onenerdyguy onenerdyguy is offline
Registered User
FRC #5929
 
Join Date: Jan 2016
Location: Lake Park, MN
Posts: 42
onenerdyguy is an unknown quantity at this point
Tank drive on Xbox Controller

I'm having difficulty getting a tank drive up and running on an Xbox controller. For some reason, it won't detect the right stick.

according to the driver station, our right stick Y axis is axis 5. My code is as follows:

self.leftstick = wpilib.Joystick(0,1)
self.rightstick = wpilib.Joystick(0,5)

The drive code is the very simple
self.myRobot.tankDrive(self.leftStick, self.rightStick)


The left stick works fine. Right stick doesn't even appear. Is there something I'm missing?
Reply With Quote
  #2   Spotlight this post!  
Unread 19-01-2016, 16:08
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: 217
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Re: Tank drive on Xbox Controller

Quote:
Originally Posted by onenerdyguy View Post
I'm having difficulty getting a tank drive up and running on an Xbox controller. For some reason, it won't detect the right stick.

according to the driver station, our right stick Y axis is axis 5. My code is as follows:

self.leftstick = wpilib.Joystick(0,1)
self.rightstick = wpilib.Joystick(0,5)

The drive code is the very simple
self.myRobot.tankDrive(self.leftStick, self.rightStick)


The left stick works fine. Right stick doesn't even appear. Is there something I'm missing?
For us, the way the right stick worked was by doing self.joystick.getRawAxis(x) and self.joystick.getRawAxis(y) IN the teleop period. Our self.joystick was defined as self.joystick = wpilib.Joystick(0) IN the robotinit().

Replace the X and Y in the arguments with 5 or whatever number that shows up in your dashboard.
Reply With Quote
  #3   Spotlight this post!  
Unread 19-01-2016, 17:02
onenerdyguy onenerdyguy is offline
Registered User
FRC #5929
 
Join Date: Jan 2016
Location: Lake Park, MN
Posts: 42
onenerdyguy is an unknown quantity at this point
Re: Tank drive on Xbox Controller

Exactly what we tried, however still no response. I can see the 5 axis moving in the driver station, but when we sim it, nothing. Our team is still slapping together their drive train, so I'm hoping this will change on a standard bot.
Reply With Quote
  #4   Spotlight this post!  
Unread 19-01-2016, 17:27
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,043
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: Tank drive on Xbox Controller

The simulation only supports 4 axis at the moment. It should be pretty straightforward to add a fifth axis, could you file a bug on pyfrc's github?

Also, the robotpy-wpilib-utilities has an XBoxController class, you may find that useful.
__________________
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
Reply With Quote
  #5   Spotlight this post!  
Unread 19-01-2016, 17:30
onenerdyguy onenerdyguy is offline
Registered User
FRC #5929
 
Join Date: Jan 2016
Location: Lake Park, MN
Posts: 42
onenerdyguy is an unknown quantity at this point
Re: Tank drive on Xbox Controller

well hot dang, that's exactly what I needed to hear before we bashed our heads in trying to figure out what the heck we were doing wrong!

I'll look into this class, it could be very helpful!
Reply With Quote
  #6   Spotlight this post!  
Unread 21-01-2016, 11:29
WubbaDuck WubbaDuck is offline
Registered User
FRC #0074 (Chaos)
Team Role: Mentor
 
Join Date: Jan 2016
Rookie Year: 2010
Location: Michigan
Posts: 6
WubbaDuck is an unknown quantity at this point
Re: Tank drive on Xbox Controller

Any luck getting the tank drive to work? We have been able to get it working with the left stick y axis but not the right stick y axis. None of the available axes seem to respond to that input.
Reply With Quote
  #7   Spotlight this post!  
Unread 21-01-2016, 11:42
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,043
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: Tank drive on Xbox Controller

Quote:
Originally Posted by WubbaDuck View Post
Any luck getting the tank drive to work? We have been able to get it working with the left stick y axis but not the right stick y axis. None of the available axes seem to respond to that input.
On the robot or on the simulator? The real robot should work on up to 12 axes -- if that doesn't work, let me know.

On the simulator, if you upgrade pyfrc to the latest version it will support all of the axes and POV for a xbox controller.
__________________
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
Reply With Quote
  #8   Spotlight this post!  
Unread 21-01-2016, 12:53
WubbaDuck WubbaDuck is offline
Registered User
FRC #0074 (Chaos)
Team Role: Mentor
 
Join Date: Jan 2016
Rookie Year: 2010
Location: Michigan
Posts: 6
WubbaDuck is an unknown quantity at this point
Re: Tank drive on Xbox Controller

We have had limited access to the drive base until this evening. So we will try that and hope that it works. Thanks for the clarification. I will forward it on to our programmer.
Reply With Quote
  #9   Spotlight this post!  
Unread 22-01-2016, 08:21
onenerdyguy onenerdyguy is offline
Registered User
FRC #5929
 
Join Date: Jan 2016
Location: Lake Park, MN
Posts: 42
onenerdyguy is an unknown quantity at this point
Re: Tank drive on Xbox Controller

Sorry, just got to this. Been a busy week.

The tank drive code works great, using getRawAxis(1) for the left stick, and getRawAxis(5) for the right.

however, the sim still does not detect the right axis. This was a fresh install pulled from pip, so I'm wondering if the github code isn't integrated into the pip install at this time?

Important part is that it drives though! Now I just need to figure out how to make it drive..easier. The sticks having such small amounts of travel mean it's very easy to not have them be perfectly in sync, meaning our robot drifts right or left instead of driving straight. any suggestions?
Reply With Quote
  #10   Spotlight this post!  
Unread 22-01-2016, 10:28
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,043
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: Tank drive on Xbox Controller

Quote:
Originally Posted by onenerdyguy View Post
The tank drive code works great, using getRawAxis(1) for the left stick, and getRawAxis(5) for the right.
Great.

Quote:
however, the sim still does not detect the right axis. This was a fresh install pulled from pip, so I'm wondering if the github code isn't integrated into the pip install at this time?
What version of pyfrc do you have installed -- when you run the sim, it shows the version in the title bar of the window. I just did a clean install of 2016.1.5 from pip, and the axis shows up. Screenshot attached -- is that what you see? Note how there are 6 axis + a POV.

Quote:
Important part is that it drives though! Now I just need to figure out how to make it drive..easier. The sticks having such small amounts of travel mean it's very easy to not have them be perfectly in sync, meaning our robot drifts right or left instead of driving straight. any suggestions?
Use a bigger joystick instead.

An often used solution is to square the inputs to make them less sensitive at lower speeds. RobotDrive.tankDrive accepts a parameter 'squaredInputs' that will do this if you set it to true. Other people use xbox controllers, I suggest searching CD (not just python, but Java and C++ too) to see what kinds of solutions others have employed to solve this problem.
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2016-01-22 10-24-33.png
Views:	25
Size:	29.8 KB
ID:	19846  
__________________
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
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 06:25.

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