![]() |
Why isn't my slowdown working?
Okay. I have this code to add joystick sensitivity(it seems to work):
void joystickSanatizer(float*x, float*y){ //Pointers All the Way!!! #starmaster if(*x<0){ *x*=*x; *x*=0-1; } else *x*=*x; if(*y<0){ *y*=*y; *y*=0-1; } else *y*=*y; } in TeleopPeriodic: float joyx=stick->GetRawAxis(0); float joyy=stick->GetRawAxis(1); joystickSanatizer(&joyx, &joyy); if(stick->GetRawButton(10)){ multiplier=0.4; } else multiplier=1; and then, after some unrelated code: rBot->ArcadeDrive(joyy*multiplier, joyx*multiplier); Where stick is an XBox 360 controller and rBot is a a RobotDrive object The point of this code is to slow down the robot... but it doesn't. Can someone help me fix this code or give me another way to slow down the robot. |
Re: Why isn't my slowdown working?
Have you added debug print statements for you code to see if your inputs and outputs make sense?
THat might help you get a quick sanity check of where your code is going wrong. Is there's a reason you don't want to do something a little simpler? Code:
float joyx = stick->GetRawAxis(0);It doesn't give you X^2 scaling, but not sure you need that. Keeping the x^2 implementation: Code:
float joyx = stick->GetRawAxis(0); |
Re: Why isn't my slowdown working?
Or even simpler, with squaring:
Code:
float joyx=stick->GetRawAxis(0); |
Re: Why isn't my slowdown working?
Well, there's another portion of my code affected by the slowdown (the tote pickup motor) that is affected by the slowdown:
outside TeleopPeriodic: float motorpower; inside: if(stick->GetRawButton(10)) motorpower=0.4; else motorpower=1; later in TeleopPeriodic(where vmc is a talon object): vmc->Set(motorpower); and that does not work. any thoughts? |
Re: Why isn't my slowdown working?
Can you share an actual excerpt from your code?
Can you elaborate on "doesn't work"? What action are you performing and how is the robot responding that leads you to the conclusion that it's not doing what you want? The 'code' looks reasonable, but you haven't really described what is happening, just that what happened isn't want you expected. |
Re: Why isn't my slowdown working?
Quote:
|
Re: Why isn't my slowdown working?
Are you sure you're pushing "Button #10"?
|
| All times are GMT -5. The time now is 10:30 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi