Go to Post There can be only one.... - Koko Ed [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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 15-01-2017, 00:16
Eric_Dao Eric_Dao is offline
Registered User
FRC #6397
 
Join Date: Jan 2017
Rookie Year: 2017
Location: Toronto
Posts: 11
Eric_Dao is an unknown quantity at this point
Use both joysticks to drive robot on Xbox controller?

How can I use both thumb sticks on an Xbox controller to move the robot's left and right motors?
Reply With Quote
  #2   Spotlight this post!  
Unread 15-01-2017, 02:01
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 377
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Use both joysticks to drive robot on Xbox controller?

Code:
robotDrive.tankDrive(xboxController.getRawAxis(1), xboxController.getRawAxis(3))
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #3   Spotlight this post!  
Unread 15-01-2017, 11:48
AustinShalit's Avatar
AustinShalit AustinShalit is offline
Registered User
AKA: אוסטין
no team (WPILib Suite Developer)
 
Join Date: Dec 2013
Rookie Year: 2008
Location: Los Angeles/Worcester/Israel
Posts: 144
AustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of light
Re: Use both joysticks to drive robot on Xbox controller?

You can also try this:

Code:
robotDrive.tankDrive(xboxController.getY(Hand.kLeft), xboxController.getY(Hand.kRight));
__________________
Reply With Quote
  #4   Spotlight this post!  
Unread 15-01-2017, 16:00
18gillespiery 18gillespiery is offline
Registered User
FRC #6421
 
Join Date: Jan 2017
Location: Wisconsin
Posts: 1
18gillespiery is an unknown quantity at this point
Re: Use both joysticks to drive robot on Xbox controller?

What we did was define two variables as joysticks on the same port

From there use the Joystick.setChannel() method to change it to the y axis on the other stick. It should be channel 5.

after that it should work.
Reply With Quote
  #5   Spotlight this post!  
Unread 15-01-2017, 23:40
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 377
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Use both joysticks to drive robot on Xbox controller?

Quote:
Originally Posted by 18gillespiery View Post
What we did was define two variables as joysticks on the same port

From there use the Joystick.setChannel() method to change it to the y axis on the other stick. It should be channel 5.

after that it should work.
Sorry, I'm a bit confused about what you're doing.
Quote:
Originally Posted by 18gillespiery View Post
What we did was define two variables as joysticks on the same port
Bad idea. Why do you need to do this?
Can you post your code please?
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #6   Spotlight this post!  
Unread 15-01-2017, 23:48
AustinShalit's Avatar
AustinShalit AustinShalit is offline
Registered User
AKA: אוסטין
no team (WPILib Suite Developer)
 
Join Date: Dec 2013
Rookie Year: 2008
Location: Los Angeles/Worcester/Israel
Posts: 144
AustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of lightAustinShalit is a glorious beacon of light
Re: Use both joysticks to drive robot on Xbox controller?

What 18gillespiery recommends is below. I do not recommend teams do this. Instead use either of the examples above.

Once again, this code is not recommended!
Code:
public class Robot extends IterativeRobot {
	
	private RobotDrive drive;
	
	private Joystick joystick1;
	private Joystick joystick2;
	
	@Override
	public void robotInit() {
		drive = new RobotDrive(0, 1);
		
		joystick1 = new Joystick(0);
		joystick2 = new Joystick(0);
		
		joystick2.setAxisChannel(AxisType.kY, 5);
	}
	
	@Override
	public void teleopPeriodic() {
		drive.tankDrive(joystick1, joystick2);
	}

}
__________________

Last edited by AustinShalit : 15-01-2017 at 23:52.
Reply With Quote
  #7   Spotlight this post!  
Unread 16-01-2017, 08:17
Eric_Dao Eric_Dao is offline
Registered User
FRC #6397
 
Join Date: Jan 2017
Rookie Year: 2017
Location: Toronto
Posts: 11
Eric_Dao is an unknown quantity at this point
Re: Use both joysticks to drive robot on Xbox controller?

Okay, thank you all for your help!
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 12:34.

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