Go to Post My nephew...loves FIRST. He wants to be an X-Cat but since he lives in Atlanta and that's a heck of a long commute for meetings I told him he probably should strive to be the next best thing: a CircuitRunner. - Koko Ed [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
  #16   Spotlight this post!  
Unread 29-12-2008, 14:15
kyungjin kyungjin is offline
Software Specialist
AKA: Daniel
VRC #0646
Team Role: Programmer
 
Join Date: Aug 2008
Rookie Year: 2009
Location: Honolulu, Hawaii
Posts: 65
kyungjin is an unknown quantity at this point
Send a message via AIM to kyungjin Send a message via MSN to kyungjin
Re: Getting Familiar with Programming in WindRiver

Thanks both for the replies.

So in order to pull information from the HID joysticks, it has to be pure P&P that doesn't require any drivers whatsoever? So, if we find such as device, everything else should be preconfigured? For example, for a steering wheel, the wheel provides x-values, and the pedals provide the y-values? Or is there anyway to preset specific functions to specific buttons or features of the joystick?
Reply With Quote
  #17   Spotlight this post!  
Unread 29-12-2008, 15:28
koreabell koreabell is offline
Team 956 Safety Captain
FRC #0956 (Eagles)
Team Role: Programmer
 
Join Date: Sep 2008
Rookie Year: 2007
Location: Oregon
Posts: 24
koreabell is an unknown quantity at this point
Re: Getting Familiar with Programming in WindRiver

most of joysticks come with drivers when you buy, but that doesn't mean you necessarily need that driver.

if you plug the joystick into the driver station, it'll most likely recognize the device without driver(unless the joystick really need driver).

you'll need WPILib to get information of joystick status, which can be interpreted as it is preconfigured.

you can assign specific functions to corresponding buttons by making if or switch case statements.

for example
Code:
	int button[13]; // find which button is pushed
	int a = 0; //how many buttons are pushed?
	
	for(int i = 0; i < 12; i++){  //Get what button(s) is/are pushed and save it in array variable
		if(Joystick::GetRawButton((i+1)) == TRUE){
			button[a] = i;
			a++;
		}
	}

	for(int i = 0; i < a; i++){
		switch(button[i+1]){
			case 0:  //if nothing is pushed
				break;
			case 1:  //if button1 is pushed
				DoThis();
				break;
			case 2:  //if button2 is pushed
				DoThat();
				break;
			case 3:  //if button3 is pushed
				DoThese();
				break;
			case 4:  //if button4 is pushed
				DoThose();
				break;
			case 5:  //if button5 is pushed
				DoIt();
				break;
			case 6:  //if button6 is pushed
				GoThere();
				break;
			case 7:  //if button7 is pushed
				ComeHere();
				break;
			case 8:  //if button 8 is pushed
				Shoot();
				break;
			case 9:  //if button 9 is pushed
				RunAway();
				break;
			case 10:  //if button 10 is pushed
				Stop();
				break;
			case 11:  //if button 11 is pushed
				DisableYourself();
				break;
			case 12:  //if button 12 is pushed
				AbortAndCatchOnFire();
				break;
		}
	}
	a = 0;
	for(int i = 0; i < 12; i++){  //reset
		button[i] = 0;
	}
i think you can have up to 12 buttons and i doubt you'll assign all 12 buttons to its corresponding functions but that's one way to do it.

the other way is having a lot(depends on how many buttons you'll be assigning specific functions to) of if and else if statements

there might be other ways but I can't think of it at the moment

Last edited by koreabell : 29-12-2008 at 15:34.
Reply With Quote
  #18   Spotlight this post!  
Unread 31-12-2008, 14:29
kyungjin kyungjin is offline
Software Specialist
AKA: Daniel
VRC #0646
Team Role: Programmer
 
Join Date: Aug 2008
Rookie Year: 2009
Location: Honolulu, Hawaii
Posts: 65
kyungjin is an unknown quantity at this point
Send a message via AIM to kyungjin Send a message via MSN to kyungjin
Re: Getting Familiar with Programming in WindRiver

I see... Since there are 12 programmable buttons, I'm guessing that either the standard joystick is labeled or there's a diagram showing what button corresponds to what... But what if we use a different joystick? Do we have to test which buttons match which input source?
Reply With Quote
  #19   Spotlight this post!  
Unread 31-12-2008, 14:51
koreabell koreabell is offline
Team 956 Safety Captain
FRC #0956 (Eagles)
Team Role: Programmer
 
Join Date: Sep 2008
Rookie Year: 2007
Location: Oregon
Posts: 24
koreabell is an unknown quantity at this point
Re: Getting Familiar with Programming in WindRiver

most of the joysticks have number on each button, maybe except for trigger button and, if you're using logitech joystick and cannot figure out which button is which, install logitech gaming software that came with the joystick(to computer), execute it with joystick plugged in to one of the computer's usb ports, and start pressing buttons. the program will tell you what button you're pressing.

i don't know if other companies support those kind of software or not, but if you have logitech joystick, you can figure out that way

if you're making your own usb joystick, then you'll have to label it as you make it, but if you're buying joystick, then i wouldn't worry too much about not knowing which button is which

btw, if you want to test without robot or drivestation, run joystick-playable game and go to key configuration(or something like that), and try changing joystick key. it'll show you which button you pushed after you assign a key (for most games)

Last edited by koreabell : 31-12-2008 at 14:56.
Reply With Quote
  #20   Spotlight this post!  
Unread 06-01-2009, 09:33
kyungjin kyungjin is offline
Software Specialist
AKA: Daniel
VRC #0646
Team Role: Programmer
 
Join Date: Aug 2008
Rookie Year: 2009
Location: Honolulu, Hawaii
Posts: 65
kyungjin is an unknown quantity at this point
Send a message via AIM to kyungjin Send a message via MSN to kyungjin
Re: Getting Familiar with Programming in WindRiver

Thanks for the reply. You've been really helpful ever since I posted this thread.

After much thinking (upon watching the game), I think we've made the decision to go with the USB joysticks that we're given standard to our team (Logitech ATK3).

Right now though... I have another problem that has been giving me major problems. Aside from not being able to get our camera correctly connected and configured when it's plugged into the cRIO... I'm not quite sure how I'm supposed to program it to track colors or shapes in WindRiver. Do I do so with pure code or is there another utility that helps monitor that? And of course... How am I supposed to implement that into the code.

Secondly... Right now, the only way I've gotten the motors to move is through the RobotBase class. Is there any other way to control a specific motor (whether it be Jaguars or Victors) a specific speed? The functions in WPIlib.h only tells you what speed you want to set it to... but there are no parameters that reference the PWM port the motor is plugged into...
Reply With Quote
  #21   Spotlight this post!  
Unread 06-01-2009, 16:40
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Getting Familiar with Programming in WindRiver

The PWM port is specified as a parameter to the constructor.

I think I read where the WPI guys are putting out an update to the camera classes (in the next few days) that works. How to use the data from the camera to guide your robot or dummper (or whatever) is up to you.
Reply With Quote
  #22   Spotlight this post!  
Unread 07-01-2009, 11:25
kyungjin kyungjin is offline
Software Specialist
AKA: Daniel
VRC #0646
Team Role: Programmer
 
Join Date: Aug 2008
Rookie Year: 2009
Location: Honolulu, Hawaii
Posts: 65
kyungjin is an unknown quantity at this point
Send a message via AIM to kyungjin Send a message via MSN to kyungjin
Re: Getting Familiar with Programming in WindRiver

Mmkay... I think I kinda get what you're saying... But just to clarify... How would you get a motor on PWM1 to go half speed for 2 seconds and PWM2 to go full speed for 3 seconds?

As for the camera classes... Do we check back on the FIRST website or the WPI site?
Reply With Quote
  #23   Spotlight this post!  
Unread 07-01-2009, 11:41
erikstotle's Avatar
erikstotle erikstotle is offline
Quendi
AKA: Erik
FRC #0107
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Zeeland, MI
Posts: 8
erikstotle is an unknown quantity at this point
Send a message via MSN to erikstotle
Re: Getting Familiar with Programming in WindRiver

Btw, in c++, you use -> to access elements of a class by pointer, and . to reference elements by refrence. I remember that concept always confusing me when I started out with OOP...luckily Visual Studio's Intellisense complains at you when you use the wrong one, so I learned quick enough .
Reply With Quote
  #24   Spotlight this post!  
Unread 07-01-2009, 15:41
kyungjin kyungjin is offline
Software Specialist
AKA: Daniel
VRC #0646
Team Role: Programmer
 
Join Date: Aug 2008
Rookie Year: 2009
Location: Honolulu, Hawaii
Posts: 65
kyungjin is an unknown quantity at this point
Send a message via AIM to kyungjin Send a message via MSN to kyungjin
Re: Getting Familiar with Programming in WindRiver

Thanks for clarifying that up for me.
Reply With Quote
  #25   Spotlight this post!  
Unread 07-01-2009, 17:22
dnrobotics11 dnrobotics11 is offline
Registered User
FRC #2589
 
Join Date: Mar 2008
Location: Massachusetts
Posts: 55
dnrobotics11 is an unknown quantity at this point
How do you open a new C++ file with WindRiver?

How do you open a new C++ file with WindRiver? I've already downloaded the FIRST version and it is working but I do not know how to actually make a new program. Thanks for the help.
Reply With Quote
  #26   Spotlight this post!  
Unread 07-01-2009, 19:34
gvarndell's Avatar
gvarndell gvarndell is offline
Software Engineer
AKA: Addi's and Georgie's Dad
FRC #1629 (GaCo)
Team Role: Parent
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Grantsville, Maryland
Posts: 350
gvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond repute
Re: How do you open a new C++ file with WindRiver?

Quote:
Originally Posted by dnrobotics11 View Post
How do you open a new C++ file with WindRiver? I've already downloaded the FIRST version and it is working but I do not know how to actually make a new program. Thanks for the help.
Do you mean to ask how to create a new source file in an existing project?
Or did you mean to ask how to create a new project?
Reply With Quote
  #27   Spotlight this post!  
Unread 07-01-2009, 20:08
dnrobotics11 dnrobotics11 is offline
Registered User
FRC #2589
 
Join Date: Mar 2008
Location: Massachusetts
Posts: 55
dnrobotics11 is an unknown quantity at this point
Re: Getting Familiar with Programming in WindRiver

I have already set up WindRiver and the "MyRobot" template is set up but I don't know how to set up new source code files for my own robot code. I can't find it in the directions and I don't know what to do. Thanks

Last edited by dnrobotics11 : 07-01-2009 at 20:20.
Reply With Quote
  #28   Spotlight this post!  
Unread 07-01-2009, 20:19
kyungjin kyungjin is offline
Software Specialist
AKA: Daniel
VRC #0646
Team Role: Programmer
 
Join Date: Aug 2008
Rookie Year: 2009
Location: Honolulu, Hawaii
Posts: 65
kyungjin is an unknown quantity at this point
Send a message via AIM to kyungjin Send a message via MSN to kyungjin
Re: Getting Familiar with Programming in WindRiver

Err... To do this go to File -> New...

And then select the project that you want. From there on the bottom there's a textbox where you type your file name WITH the extension. For example... If you want a C++ source file named test... then type in test.cpp. If you want a header file... for example, testlib... then type in testlib.h.

It should automatically create a file in the project that you selected.
Reply With Quote
  #29   Spotlight this post!  
Unread 07-01-2009, 20:22
dnrobotics11 dnrobotics11 is offline
Registered User
FRC #2589
 
Join Date: Mar 2008
Location: Massachusetts
Posts: 55
dnrobotics11 is an unknown quantity at this point
Oh ok thanks
Reply With Quote
  #30   Spotlight this post!  
Unread 07-01-2009, 20:32
gvarndell's Avatar
gvarndell gvarndell is offline
Software Engineer
AKA: Addi's and Georgie's Dad
FRC #1629 (GaCo)
Team Role: Parent
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Grantsville, Maryland
Posts: 350
gvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond repute
Re: Getting Familiar with Programming in WindRiver

Quote:
Originally Posted by dnrobotics11 View Post
I have already set up WindRiver and the "MyRobot" template is set up but I don't know how to set up new source code files for my own robot code. I can't find it in the directions and I don't know what to do. Thanks
Right-click on the project to which you want to add the new file.
Select New->File from Template.
The New File dialog will appear.
Type in the new file's name.
Click the Change... button.
A Preferences dialog will appear -- here you'll select 'cpp_template'.
Click OK in the Preferences dialog.
Click Finish in the New File dialog.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming - Getting Started Mark McLeod Programming 80 16-04-2008 23:37
Help Getting Started with VEX programming. Joe Johnson VEX 5 16-04-2007 09:01
pic: Mobot with familiar parts jgannon Extra Discussion 11 24-04-2006 18:55
programming motors with programming kit BorisTheBlade FIRST Tech Challenge 4 01-11-2005 19:03
Programming and Electronics — Getting Started Sidney San Martín Technical Discussion 7 12-01-2005 15:25


All times are GMT -5. The time now is 14:19.

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