|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
chaging values on an axis/toogle switch
is thier a way to change the values that an axis gives out. right now i am using this code
BeaterBars->Set(GetZ()); and it gives out values -1.0 to 1.0. and we have no need for our system to run backwards. how would i change it to values 0.0 to 1.0. also does anyone know how to program a toogle switch so we don't have to keep a button held down. |
|
#2
|
||||
|
||||
|
Re: chaging values on an axis/toogle switch
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); Last edited by Sentient : 11-02-2009 at 20:42. |
|
#3
|
|||
|
|||
|
Re: chaging values on an axis/toogle switch
Quote:
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. Last edited by Alex_2487 : 11-02-2009 at 21:50. |
|
#4
|
||||
|
||||
|
Re: chaging values on an axis/toogle switch
Quote:
In this case you'll need to set a flag up. This will be in psuedocode but it will be something like: You need to set a flag when the button is pressed, the problem is that the button is in an endless loop so you'll have to make sure you only poll the Buttonflag once each time the button is held down, so you'll need another flag for that. Define a ButtonFirstflag Define a Button2flag Initialize the variables at the beginning: Button2flag=false; ButtonHeldflag = true; if (Button2) { if (ButtonFirstflag) { if (!Button2flag) { Button2flag = true; } else { Button2flag = false; } ButtonHeldflag = false; } ButtonHeldflag = true; If (Button2flag) { Motor = forward } else { Motor = stop } There maybe an easier means to do what you are asking, but this is what I use when I want to do what you are talking about. I hope I've helped. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Joystick values (?) | beefy1 | Programming | 1 | 23-12-2008 11:26 |
| Joystick axis values in new controller | koreabell | Programming | 7 | 17-12-2008 11:39 |
| penalties values??? | colin340 | Rules/Strategy | 4 | 08-03-2008 21:37 |
| Need Help Wiring Micro Switch/Limiting Switch | Windward | Electrical | 2 | 07-02-2006 18:26 |
| Servo Values | DanDon | Motors | 8 | 14-02-2005 15:49 |