View Single Post
  #3   Spotlight this post!  
Unread 11-02-2009, 20:55
Alex_2487 Alex_2487 is offline
Registered User
AKA: Alex Korpi
no team
Team Role: Alumni
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Sayville, New York
Posts: 31
Alex_2487 is an unknown quantity at this point
Send a message via AIM to Alex_2487
Re: chaging values on an axis/toogle switch

Quote:
Originally Posted by Sentient View Post
You can clamp the joystick values from the joystick pretty easily.

float inputZ = stick->GetZ();
if(inputZ < 0.0)
inputZ = 0.0;

motor->Set(inputZ);

As for the toggle switch, what exactly are you using it for? If you are wanting to use a toggle switch that you on the driver station digital IO, you can just check the driver station inputs with driverStation->GetDigitalInput(channel);

EDIT: The above method for clamping would disregard anything below 0. If you want -1 to equal 0, 0.0 to equal 0.5, and 1.0 to equal 1.0, you can do this (although it would be very unintuitive for the driver):

motor->Set((stick->GetZ()+1.0)/2);
we are using the throttle axis on the joystick so it will work program the second way


right now my code for a motor is this

if (Thirdjoystick->GetRawButton (2)==1 )
{
frontroller->set(-1.0);
}
else if (Thirdjoystick->GetRawButton (3)==1 )
{
frontroller->set(1.0)
}
esle
{
frontroller->set(0.0)
}

right now the motor is off when we turn on the robot and when we hold down button 2 it rruns backwards and button 3 runs forward. i want to be able to make it so the second driver doesnt need to hold down the button and can just press it to switch between forward and stop and on the other button switch between backward and stop.
__________________
Events
2009 SBPLI Long Island Regional
2008 Deer Park Invitational, Championships- Galileo Division, SBPLI Long Island Regional
Awards
2009 Long Island Semifinalists
2008 Deer Park Invitational Finalist (353,1546), Long Island Regional Champion (2010,102),Highest Rookie Seed, Rookie Inspiration, Best Website, Website Excellence Award
2009 Record(2487): 5-9-1
2008 Record(2487): 23-10-3
Overall Record(2487): 27-19-4
www.wbsts.com/gnomes.html

Last edited by Alex_2487 : 11-02-2009 at 21:50.
Reply With Quote