|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
I've searched, and searched but I just frustrate myself more. I can't see to find out how to do a few basic things I was able to do in MpLab on the old control system. I don't know how to use WPILib to my advantage just yet, and through all this complexity I just need to know how to do a few simple things!
First off, how would I go about writing code for a joystick in which an axis controls the speed of the motor? how would assign a joystick to a pwm? (Same as above pretty much) how would I invert a motor in code? where can I find out what variables I can use for C++ in Windriver? How do I program a button? In most posts people have been directed to the FRC control systems page, but I don't see anything helpful. Maybe i'm missing something, but if anyone could show me some sample code or pass some links to show me the right direction I would be eternally grateful. And if you're really in the mood to help, maybe you everyone could throw in some extra bit with other "simple" functions that people could reference from this post. Thanks in advance! -Rameez |
|
#2
|
|||||
|
|||||
|
Re: Basic functions in windriver
|
|
#3
|
||||
|
||||
|
Re: Basic functions in windriver
there's too much information to grab from that, and I honestly haven't be able to grab too much use from it...
|
|
#4
|
|||
|
|||
|
Re: Basic functions in windriver
Why has WPI not released proper documentation yet? That PDF is from October, it still has the DRAFT watermark, and is littered with incomplete examples and napkin CAD, which is extremely frustrating when adjusting to the new API.
Looking at the internal source code has helped some, but many things are still unclear, and the manual could use a glossary for terms related to the cRIO and its new modules.. Don't get me wrong, i highly appreciate what they are doing and they've done quite a bit in a (relatively) small amount of time, but it all feels rather rough around the edges. |
|
#5
|
||||
|
||||
|
Re: Basic functions in windriver
I feel the same exact thing. Every time I get to something that could possibly help me, it's still incomplete. I either need that manual complete, or some nice person to post lines of example code that is specific to what I'm asking for. ...
I spent a few hours reading through code and testing random things, and I taught myself something that someone could've showed me in two minutes.. Can anyone please help me/us out? -Rameez |
|
#6
|
||||
|
||||
|
Re: Basic functions in windriver
Have you looked at the example template things that they have in windriver? They show a couple of decent examples.
I haven't been able to actual put code on our controller yet, but I have been playing with the code a bit (I don't know if what I wrote works yet ) so I can't help too much yetFrom what I have looked at it looks like there are a couple of ways to go about the basic drive functions. You need to create your joystick objects Code:
Joystick LeftStick(1); Joystick RightStick(2); Code:
Jaguar LeftMotor(1); Jaguar RightMotor(2); then set the speed to the joystick Code:
LeftMotor.Set( LeftStick.GetY() ); RightMotor.Set( RightStick.GetY() ); Hope that helps |
|
#7
|
||||
|
||||
|
Re: Basic functions in windriver
The Joysticks do return a value from -1 to 1, so you can put the values directly into the Jaguars.
If you were looking for a drive system off of one joystick you would use something like this. This could basically is a copy of the old code just usable on the new brain. NOTE: In the code this year it seems to be easier to just declare all the variables you are going to be using as pointers. This code has also not been completely tested but it should work. For global variables Code:
Joystick *controller; Jaguar *LeftMotor, *RightMotor; Code:
//This creates a new joystick object to usb1 from the drive station controller = new Joystick(1); //Sets the left motor the pwm out 1 and right to pwm out 2 LeftMotor = new Jaguar(1); RightMotor = new Jaguar(2); Code:
float valid_value(float value)
{
if(value > 1)
return 1;
if(value < -1)
return -1;
return value;
}
Code:
LeftMotor->Set(valid_value(controller->GetX() - controller->GetY()); RightMotor->Set(valid_value(controller->GetX() + controller->GetY()); Now, if you want to grab button states from the joystick there are two ways to do this. In terms of this example i will use the controller variable declared above. Code:
controller->GetRawButton(4); controller->GetButton(Joystick::kTriggerButton) The first example though returns the state of the button on the controller labeled 4. The second one shows how to use the GetButton function using the constants from the Joystick class. If you would like to see all the classes in the new code with your project open in windriver look for the project explorer. Inside the project explorer hit the plus next to includes, then look at the files that appear then click the plus next to the one named C:\windriver\vcworks-6.3/target/h/WPIlib Hopefully that cleared up alot. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Debug Windriver issue..... | programmr | C/C++ | 12 | 02-06-2011 01:47 PM |
| Windriver LAC | McGurky | C/C++ | 12 | 02-25-2009 06:38 PM |
| compiling in windriver | koreabell | Programming | 4 | 01-05-2009 03:32 PM |
| windriver projects | nickmagus | Programming | 4 | 12-01-2008 11:29 PM |