Go to Post Most of the people who fit the profile of long tenured FIRST mentor are either already on a team or locked up in an institution where they belong... - PayneTrain [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 11-02-2012, 15:34
ss9090 ss9090 is offline
Registered User
AKA: Stewart Smith
FRC #4367 (Streetbots)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: ON, Canada
Posts: 6
ss9090 is an unknown quantity at this point
Using the Logitech F510 Controller Help

Hello everyone,

I've been trying to get the Logitech F510 to work with the Command Based Robot Template structure. I've managed to get the axises working with 'GetRawAxis()', however I am having trouble getting the buttons to respond. I am not sure if I properly understand where and what to put in order to make them function. Can anybody help me with the structure of button OI in the code and - if you can - which button coresponds to what number (not really necessary, although helpful)?

P.S. I am using WindRiver C++

EDIT: We checked the controller to see if it functions properly, it does. We also used another teams controller to make sure it was the code, and it is. It is very urgent that this be solved as quickly as possible. Any help would be incredible, thank you.

Some additional info;
I have the following in OI.cpp:


Code:
#include "OI.h"
#include "Robotmap.h"
#include "Commands/C_PullyFwd.h"
#include "Commands/C_PullyRev.h"
#include "Subsystems/Chassis.h"

OI::OI() {
	
	Chassis *chassis;
	gamepad = new Joystick(GAMEPAD_PORT);
	
	
	bool gamepad_button_x = gamepad->GetRawButton(GAMEPAD_BUTTON_X);
	bool gamepad_button_a = gamepad->GetRawButton(GAMEPAD_BUTTON_A);
	bool gamepad_button_b = gamepad->GetRawButton(GAMEPAD_BUTTON_B);
	bool gamepad_button_y = gamepad->GetRawButton(GAMEPAD_BUTTON_Y);
	bool gamepad_button_L1 = gamepad->GetRawButton(GAMEPAD_BUTTON_L1);
	bool gamepad_button_L2 = gamepad->GetRawButton(GAMEPAD_BUTTON_L2);
	bool gamepad_button_R1 = gamepad->GetRawButton(GAMEPAD_BUTTON_R1);
	//bool gamepad_button_R2 = gamepad->GetRawButton(GAMEPAD_BUTTON_R2);
	
	if (gamepad_button_x == true) { 
		//
	}
	if (gamepad_button_a == true) {
		//Drive straight
		chassis->customTankDrive(1.0, 1.0);
	}
	if (gamepad_button_b == true) {
		//
	}
	if (gamepad_button_y == true) {
		//shooting
	}
	if (gamepad_button_L1 == true) {
		//bridge mech up
	}
	if (gamepad_button_L2 == true) {
		//pulley brings balls out
		new PullyRev(1000);
	}
	if (gamepad_button_R1 == true) {
		//bridge mech down
	}
	if (gamepad_button_R2 == true) {
		//Pully brings in balls
		new PullyFwd(1000);
	}
}

Joystick * OI::getJoystick() {		//activate the Joystick class
	return gamepad;
}

-I know the functions being called work
-I've tried making the if statement conditions without the '== true'
-Tried using if, else if, else if, ... else structure
-Tried replacing the if statements with
Code:
if ((gamepad->GetRawButton(GAMEPAD_BUTTON_R2) ) == true ) {}
__________________
FRC 4736 Streetbots
2012 Streetsville Secondary's pioneering FRC team

Thanks to our mentor team, 1241 Theory6, for all of their help! I wish everybody there the best in their futures.

-Lead Programmer (Wind River C++)
-Lead Electrical
-Lead Controls
-Part-time Build

2012 - 17th seed (GTR West)

Last edited by ss9090 : 12-02-2012 at 14:43. Reason: More info
Reply With Quote
  #2   Spotlight this post!  
Unread 12-02-2012, 14:48
WizenedEE's Avatar
WizenedEE WizenedEE is offline
Registered User
AKA: Adam
FRC #3238 (Cyborg Ferrets)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Anacortes, WA
Posts: 395
WizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to all
Re: Using the Logitech F510 Controller Help

That code will only be called once, since it's in the constructor. Assuming you construct everything in your main robot's constructor, that code will only get called once, and the robot will be disabled (so calling customTankDrive will have no effect).

Have you thought about using another method of output (like printf or smartdashboard) than your robot itself? If it prints out "Button A pressed" when you press button A, you have some valuable debugging info.
Reply With Quote
  #3   Spotlight this post!  
Unread 12-02-2012, 14:58
ss9090 ss9090 is offline
Registered User
AKA: Stewart Smith
FRC #4367 (Streetbots)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: ON, Canada
Posts: 6
ss9090 is an unknown quantity at this point
Re: Using the Logitech F510 Controller Help

Quote:
Originally Posted by WizenedEE View Post
That code will only be called once, since it's in the constructor. Assuming you construct everything in your main robot's constructor, that code will only get called once, and the robot will be disabled (so calling customTankDrive will have no effect).

Have you thought about using another method of output (like printf or smartdashboard) than your robot itself? If it prints out "Button A pressed" when you press button A, you have some valuable debugging info.
Well, I feel stupid now hehe. Thank you so much for your time. Although I do not have access to my robot at the moment for testing, I'm almost sure this is going to work once deployed. I'll keep you posted on the results.

I hadn't considered printf in this particular circumstance, however I'll sure as heck put it in now.

If anybody else has any other suggestions, they'd be welcomed too.
__________________
FRC 4736 Streetbots
2012 Streetsville Secondary's pioneering FRC team

Thanks to our mentor team, 1241 Theory6, for all of their help! I wish everybody there the best in their futures.

-Lead Programmer (Wind River C++)
-Lead Electrical
-Lead Controls
-Part-time Build

2012 - 17th seed (GTR West)
Reply With Quote
  #4   Spotlight this post!  
Unread 12-02-2012, 14:59
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Using the Logitech F510 Controller Help

I recommend looking at the GearsBot sample to see how to properly use buttons with the command based template. I fyou have specific questions after looking at it, feel free to ask.

As WizenedEE pointed out, your code will only run once. There are button classes that have been added for use with the command-based template.
Reply With Quote
  #5   Spotlight this post!  
Unread 13-02-2012, 16:23
ss9090 ss9090 is offline
Registered User
AKA: Stewart Smith
FRC #4367 (Streetbots)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: ON, Canada
Posts: 6
ss9090 is an unknown quantity at this point
Re: Using the Logitech F510 Controller Help

Quote:
Originally Posted by RufflesRidge View Post
I recommend looking at the GearsBot sample to see how to properly use buttons with the command based template. I fyou have specific questions after looking at it, feel free to ask.

As WizenedEE pointed out, your code will only run once. There are button classes that have been added for use with the command-based template.
I cannot seem to find where this sample project is, could you point me in the right direction?
__________________
FRC 4736 Streetbots
2012 Streetsville Secondary's pioneering FRC team

Thanks to our mentor team, 1241 Theory6, for all of their help! I wish everybody there the best in their futures.

-Lead Programmer (Wind River C++)
-Lead Electrical
-Lead Controls
-Part-time Build

2012 - 17th seed (GTR West)
Reply With Quote
  #6   Spotlight this post!  
Unread 13-02-2012, 16:37
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Using the Logitech F510 Controller Help

Quote:
Originally Posted by ss9090 View Post
I cannot seem to find where this sample project is, could you point me in the right direction?
Sorry about that, forgot that it wasn't bundled in in C++ like it is in Java. You can find it here: http://firstforge.wpi.edu/sf/frs/do/...sample_program
Reply With Quote
  #7   Spotlight this post!  
Unread 14-02-2012, 19:35
ss9090 ss9090 is offline
Registered User
AKA: Stewart Smith
FRC #4367 (Streetbots)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: ON, Canada
Posts: 6
ss9090 is an unknown quantity at this point
Re: Using the Logitech F510 Controller Help

Thank you very much. I managed to get the Buttons working, however my Drivetrain is now broken. Im thinking of rewriting the whole system.
__________________
FRC 4736 Streetbots
2012 Streetsville Secondary's pioneering FRC team

Thanks to our mentor team, 1241 Theory6, for all of their help! I wish everybody there the best in their futures.

-Lead Programmer (Wind River C++)
-Lead Electrical
-Lead Controls
-Part-time Build

2012 - 17th seed (GTR West)
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 17: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