![]() |
Capping Speed in Java
Hello all,
I thought I posted this topic here yesterday but I don't see it. Forgive me if I actually did post it somewhere else and am now repeating myself. Our team is going to be doing a demonstration at a local elementary school and we are going to let the students drive our robot for a while. Is it possible to cap the speed of the robot via programming (for a quick fix) via Java. Thank you! |
Re: Capping Speed in Java
Yes. If you're using tank or arcade, just make it so the output of the drive motors is hapf, or whatever you need the max to be, of the joysticks' x and y values. If you need further explication or an example, just ask and I can pm this or or post it here.
|
Re: Capping Speed in Java
dividing the speed in half also works for mechanum
|
Re: Capping Speed in Java
If you want to be really slick, leverage object orientation to the fullest, and reduce the number of places you'll have to modify code, you could create a new class called (for example) "limited_controller" that extends your current motor controller class. The code for this class basically recreates all of the methods of the superclass through use of super, and modifies only the "set" method to enforce the top limit, or divide by 2, or whatever. Then, when you initialize your motor controllers, use "new limited_controller([args])" rather than (for example) "new Talon([args])".
|
Re: Capping Speed in Java
Dividing mechanism may that help you.
|
Re: Capping Speed in Java
I'll also leave this code here. Just initialize this class with the joystick port you desire and any button on that controller (or left/right trigger for xbox controllers, axes drifted too much) and the robot stops until you release said button. (To do this, call pollForPressed() than if(!good()){kill robot})
Code:
/* |
| All times are GMT -5. The time now is 10:21. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi