Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Getting Familiar with Programming in WindRiver (http://www.chiefdelphi.com/forums/showthread.php?t=70839)

kyungjin 29-12-2008 14:15

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?

koreabell 29-12-2008 15:28

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

kyungjin 31-12-2008 14:29

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?

koreabell 31-12-2008 14:51

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)

kyungjin 06-01-2009 09:33

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...

wireties 06-01-2009 16:40

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.

kyungjin 07-01-2009 11:25

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?

erikstotle 07-01-2009 11:41

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 :).

kyungjin 07-01-2009 15:41

Re: Getting Familiar with Programming in WindRiver
 
Thanks for clarifying that up for me.

dnrobotics11 07-01-2009 17:22

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.

gvarndell 07-01-2009 19:34

Re: How do you open a new C++ file with WindRiver?
 
Quote:

Originally Posted by dnrobotics11 (Post 795095)
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?

dnrobotics11 07-01-2009 20:08

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

kyungjin 07-01-2009 20:19

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.

dnrobotics11 07-01-2009 20:22

Oh ok thanks

gvarndell 07-01-2009 20:32

Re: Getting Familiar with Programming in WindRiver
 
Quote:

Originally Posted by dnrobotics11 (Post 795219)
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.


All times are GMT -5. The time now is 12:25.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi