Go to Post Part of FRC and design/engineering is perseverance. Keep your chin up, your thoughts positive, and have respect for your work and the work of your teammates. - Nathan_Fraser [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Spotlight this post!  
Unread 08-01-2009, 07:43
CyDrive's Avatar
CyDrive CyDrive is offline
Registered User
FRC #1203 (pandemonium)
Team Role: Mentor
 
Join Date: Apr 2007
Rookie Year: 2007
Location: West Babylon
Posts: 26
CyDrive is an unknown quantity at this point
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;
In your constructor
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);
You will need to put this function in the code. All it does is makes sure that the values given to the Jaguars are valid;
Code:
float valid_value(float value)
{
	if(value > 1)
		return 1;
	if(value < -1)
		return -1;
	return value;
}
Then finally in the teleoperated function you would use
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)
Both lines return a simple bool state
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
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
Debug Windriver issue..... programmr C/C++ 12 06-02-2011 13:47
Windriver LAC McGurky C/C++ 12 25-02-2009 18:38
compiling in windriver koreabell Programming 4 05-01-2009 15:32
windriver projects nickmagus Programming 4 01-12-2008 23:29


All times are GMT -5. The time now is 15:08.

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