Go to Post After the norovirus outbreak at VCU, we had our entire team sterilized. Oh, wait, that doesn't sound right... - dlavery [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: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 11-12-2012, 10:59
Toa Circuit's Avatar
Toa Circuit Toa Circuit is offline
Thaddeus Maximus
AKA: Thad Hughes
FRC #4213 (MetalCow Robotics)
Team Role: Leadership
 
Join Date: Nov 2012
Rookie Year: 2012
Location: Shirley, IL
Posts: 131
Toa Circuit is an unknown quantity at this point
Re: XBox controller

Quote:
Originally Posted by Zuelu562 View Post
Toa, our reasoning for using the floats was a double whammy type deal; we added a small deadband to the controller by keeping an eye on the values. We were aware of the issue that the robot could potentially move without a human interacting with the controller due to the minuscule difference between 0 (dead stop) and .25 (moving) on the xbox controllers. This also solved the issue with GetRawAxis() freaking out in the main loop.
Funny, the controller I used never had a deadband issue.

Quote:
Originally Posted by ekapalka View Post
So does that mean we don't vave to use
Code:
		leftStick = new Joystick(1);			
		rightStick = new Joystick(2);
or that in addition to the code you suggested? Thanks for your reply! I really appreciate it!
Oh, you will still need to do all the code you had before, I just wrote up the portion that you need to add/replace.
Reply With Quote
  #2   Spotlight this post!  
Unread 12-12-2012, 08:28
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: XBox controller

I haven't been back to this thread in a while, so I haven't had a chance to say THANK YOU ALL SO MUCH! I really appreciate it! I just had a few more questions...
THe code provided by Toa works, but I had a few questions about how exactly it works. It only references
Code:
leftStick->GetRawAxis(1), leftStick->GetRawAxis(2)
so why do I even need
Code:
rightStick = new Joystick(2);
? Also, why is it myRobot->Drive() and not robotDriver.ArcadeDrive() or myRobot->ArcadeDrive()? Any help would be great! Once again, thanks for all your help!
Reply With Quote
  #3   Spotlight this post!  
Unread 14-12-2012, 21:34
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,562
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: XBox controller

Quote:
Originally Posted by ekapalka View Post
.
THe code provided by Toa works, but I had a few questions about how exactly it works. It only references
Code:
leftStick->GetRawAxis(1), leftStick->GetRawAxis(2)
so why do I even need
Code:
rightStick = new Joystick(2);
?
You don't

Quote:
Originally Posted by ekapalka View Post
Also, why is it myRobot->Drive() and not robotDriver.ArcadeDrive() or myRobot->ArcadeDrive()? Any help would be great! Once again, thanks for all your help!
There are several different methods provided by RobotDrive, including ArcadeDrive and Drive. They are described in the "WPI Robotics Library User’s Guide". You should pick the one that does what you want, or experiment and try them all.
Reply With Quote
  #4   Spotlight this post!  
Unread 15-12-2012, 00:59
Zuelu562's Avatar
Zuelu562 Zuelu562 is offline
Ready for WPI District!
AKA: Jake Janssens
FRC #3623 (Terror Bots)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Massachusetts
Posts: 340
Zuelu562 is a splendid one to beholdZuelu562 is a splendid one to beholdZuelu562 is a splendid one to beholdZuelu562 is a splendid one to beholdZuelu562 is a splendid one to beholdZuelu562 is a splendid one to beholdZuelu562 is a splendid one to beholdZuelu562 is a splendid one to behold
Re: XBox controller

Quote:
Originally Posted by Toa Circuit View Post
Funny, the controller I used never had a deadband issue.
We had fresh controllers as well (ie just out of the box). The thing we were worried about is a situation where the analog stick just isn't 100%, and sometimes would actually rest on what would be .25. Also, we didn't want to run it full power anyway, thinking about it now, because it would jump at the slightest touch.

We can look at it again and re-evaluate the need, but it worked for us.
__________________
Team Resume
562 "S.P.A.R.K." - Student Programmer 2008-2011, Field Coach 2011
3623 "Terror Bots" - Technical Mentor, Field Coach 2012 - Present

Volunteer Resume:
BattleCry@WPI 12, 13, 15, 16 - Queuing
BattleCry@WPI 14 - Field Reset
Granite State District Event 2014 - Team Queueing
NEFIRST District Championships '14,'15,'16 - Team Queuing
Reply With Quote
  #5   Spotlight this post!  
Unread 02-01-2013, 00:14
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: XBox controller

Hey CD! I've had an epiphany! XBox is actually spelled xBox, just like Ipod is actually spelled iPod! I've taken into consideration all the information I received from this thread and the example code, and have constructed this:
Code:
#include <WPILib.h>
class DefaultRobot : public SimpleRobot
{	
	Joystick *xboxStickManip;              
	Joystick *leftStick;			       
	Joystick *rightStick;                  
	Jaguar *leftDrive;                     
	Jaguar *rightDrive;                    
	RobotDrive *myRobot;                   
public:
	DefaultRobot(void)
	{	
		xboxStickManip = new Joystick(1);  
		leftStick = new Joystick(2);
		rightStick = new Joystick(3);
		leftDrive = new Jaguar(1);
		rightDrive = new Jaguar(2);
		myRobot = new RobotDrive(leftDrive, rightDrive);
	}
	void Autonomous(void)
	{
			while(IsAutonomous())
			{
			}				
	}
	void OperatorControl(void)
	{
		myRobot->TankDrive(0.0, 0.0);		
		while (IsOperatorControl())
		{	
			float leftStickYAxis = leftStick->GetY();
			float rightStickYAxis = rightStick->GetY();	
			myRobot->TankDrive(-leftStickYAxis, -rightStickYAxis);
		}
	}
};

START_ROBOT_CLASS(DefaultRobot);
It compiles (amazingly) but will not load onto the cRIO II, even though DefaultRobotProject compiles and runs. I've begun to think that my code may be at fault... Does anyone have any ideas? I'm pretty sure it's also a bit redundant. Any help would be awesome! Cheers!
Reply With Quote
  #6   Spotlight this post!  
Unread 12-01-2013, 14:39
Kit Fieldhouse Kit Fieldhouse is offline
Registered User
FRC #3216
 
Join Date: Jan 2013
Location: Missoula Montana
Posts: 3
Kit Fieldhouse is an unknown quantity at this point
Re: XBox controller

Hello
i was wondering if anyone had figured out how to implement tank drive with an Xbox controller? Our team has gotten one joystick to work (using basically the code that's already here), but not both. One of our members who formerly programmed in LabView said that one of the Joysticks is recognized as a joystick and the other is recognized as a button (somehow). Is there some way to do this? Thanks!
Reply With Quote
  #7   Spotlight this post!  
Unread 12-01-2013, 16:20
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: XBox controller

Quote:
Originally Posted by Kit Fieldhouse View Post
Hello
i was wondering if anyone had figured out how to implement tank drive with an Xbox controller? Our team has gotten one joystick to work (using basically the code that's already here), but not both. One of our members who formerly programmed in LabView said that one of the Joysticks is recognized as a joystick and the other is recognized as a button (somehow). Is there some way to do this? Thanks!
That's not correct, I don't think. The entire Xbox controller is a Joystick, and each individual stick is a pair of axes. Perhaps the labview libraries work differently from the text languages in that regard, I don't know, but the C++ and Java libraries should consider both thumbsticks as 4 axes on the Joystick (left x-axis, left y-axis, etc).

Ex.

Code:
public OI() {                
        leftTank = driverXbox.getRawAxis(2);
        rightTank = driverXbox.getRawAxis(5);
}
with

Code:
// Axis indexes:
    public static final int
            LEFT_X_AXIS = 1,
            LEFT_Y_AXIS = 2,
            TRIGGERS = 3,
            RIGHT_X_AXIS = 4,
            RIGHT_Y_AXIS = 5,
            DPAD_LR = 6;
    
    // Button mappings:
    public static final int
            BUTTON_A = 1,
            BUTTON_B = 2,
            BUTTON_X = 3,
            BUTTON_Y = 4,
            BUMPER_L = 5,
            BUMPER_R = 6,
            BUTTON_BACK = 7,
            BUTTON_START = 8,
            LEFT_STICK_PRESS = 9,
            RIGHT_STICK_PRESS = 10;
As far as using an Xbox controller for tank drive, I don't recommend it. The fact that the thumbsticks are at different elevations vertically means it's going to be harder to operate it effectively. The Xbox controller also has a 20% deadzone in the center of the thumbsticks where you cannot accurately determine the position of the stick. This means that if you do not account for this, it will drift even when you're not touching it, and if you do, you will not be able to make movements of less than 20% power.

I would recommend the Logitech F310 instead, as both thumbsticks are at the same elevation, and the sticks themselves are more accurate (much less deadzone).
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional

Last edited by F22Rapture : 12-01-2013 at 16:27.
Reply With Quote
  #8   Spotlight this post!  
Unread 12-01-2013, 22:15
nightpool's Avatar
nightpool nightpool is offline
robotRectifier
AKA: Evan
no team (formerly of CORE 2062)
Team Role: Alumni
 
Join Date: Oct 2011
Rookie Year: 2011
Location: Waukesha, WI
Posts: 81
nightpool is on a distinguished road
Re: XBox controller

No, the labview code works in the same way. One joystick, with 6 axis and 10-ish buttons. Maybe he was thinking in the was the triggers work? (They're an axis, with the left trigger -1 and the right trigger +1. Both triggers are 0).
__________________
Proud alum of CORE 2062.
www.core2062.com
Reply With Quote
  #9   Spotlight this post!  
Unread 13-01-2013, 19:31
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: XBox controller

Does anyone happen to know the button mapping for the Logitech Gamepad F310 and/or Logitech Attack3 joystick? Is the gamepad mapping the same as the xBox controller? We'll be using the Attack3 joysticks until we order some sort of gamepad, probably the Logitech F310 gamepad, based on F22Rapture's testimony. Thanks!
Reply With Quote
  #10   Spotlight this post!  
Unread 13-01-2013, 19:34
nightpool's Avatar
nightpool nightpool is offline
robotRectifier
AKA: Evan
no team (formerly of CORE 2062)
Team Role: Alumni
 
Join Date: Oct 2011
Rookie Year: 2011
Location: Waukesha, WI
Posts: 81
nightpool is on a distinguished road
Re: XBox controller

Windows has a tool that shows you the state of any joystick you have plugged in (ie, what axis are where, what buttons are pressed). You can find it under control panel > Devices. Look for "Set up Game controllers", then press advanced on whichever connected game controller you want to inspect.
__________________
Proud alum of CORE 2062.
www.core2062.com
Reply With Quote
  #11   Spotlight this post!  
Unread 13-01-2013, 21:17
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: XBox controller

Quote:
Originally Posted by ekapalka View Post
Does anyone happen to know the button mapping for the Logitech Gamepad F310 and/or Logitech Attack3 joystick? Is the gamepad mapping the same as the xBox controller? We'll be using the Attack3 joysticks until we order some sort of gamepad, probably the Logitech F310 gamepad, based on F22Rapture's testimony. Thanks!
Not sure on the F310 (see nightpool's post), but the Attack3 is something like this:


Code:
   //Axis Indexes
    public static final int
            X_AXIS = 1,
            Y_AXIS = 2,
            THROTTLE = 3;
    
    //Buttons
    public static final int
            //Buttons on joystick
            TRIGGER = 1,
            //POV buttons on head of stick
            BUTTON_SOUTH = 2,
            BUTTON_NORTH = 3,
            BUTTON_WEST = 4,
            BUTTON_EAST = 5,
            //Pair of buttons left of stick
            BUTTON_BASE_WNW = 6,
            BUTTON_BASE_WSW = 7,
            //Pair of buttons below stick
            BUTTON_BASE_SSW = 8,
            BUTTON_BASE_SSE = 9,
            //Pair of buttons right of stick
            BUTTON_BASE_ESE = 10,
            BUTTON_BASE_ENE = 11;
I don't have one on me, so I'd appreciate it if someone could confirm.
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional
Reply With Quote
  #12   Spotlight this post!  
Unread 14-01-2013, 00:22
cgmv123's Avatar
cgmv123 cgmv123 is offline
FRC RI/FLL Field Manager
AKA: Max Vrany
FRC #1306 (BadgerBOTS)
Team Role: College Student
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Madison, WI
Posts: 2,075
cgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond repute
Re: XBox controller

Quote:
Originally Posted by F22Rapture View Post
I don't have one on me, so I'd appreciate it if someone could confirm.
The Attack3's buttons are numbered on the controller and they do correspond correctly in software.
__________________
BadgerBOTS Robotics|@team1306|Facebook: BadgerBOTS
2016 FIRST Championship Tesla Division | 2016 Wisconsin Regional Engineering Inspiration Award

2015 FIRST Championship Carson Division | 2015 Wisconsin Regional Chairman's Award

2013 FIRST Championship Curie Division | 2013 Wisconsin Regional Chairman's Award

2012 FIRST Championship Archimedes Division | 2012 Wisconsin Regional Engineering Inspiration Award, Woodie Flowers Finalist Award (Lead Mentor Ben Senson)

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 18:20.

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