View Single Post
  #4   Spotlight this post!  
Unread 03-06-2015, 00:09
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,574
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
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])".
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote