Quote:
Originally Posted by BL0X3R
I hope you aren't suggesting that this team completely rewrites their robot code to work in a new style a few weeks before the competition. "Don't use iterative" is a pretty overgeneralized statement to make: Plenty of teams use it, some to great success.
The main difference between Iterative and Command based besides structure and style is that Iterative is continuous and periodic, while Command based is built around being asynchronous. While it is also true that the Command based model does use more of the features of object oriented programming, that does not necessarily always make it better in this environment.
|
actually command based is also periodic, each subsystem runs the command about every 20ms...but as for a code rewrite it wouldn't necessarily be wise but it wouldn't be impossible.
Quote:
Originally Posted by BL0X3R
This would work for a command based robot, but because of the periodic nature of Iterative robot, this code gets run about 50 times a second. Therefore, if the driver holds the button for more than 20ms, the toggle variable will flip more than once.
One solution is to only flip the variable on the rising edge of the button press - to check if the button is pressed, but was not pressed earlier. Example below.
|
well, the toggle can work both ways on down and up. IF it runs for 20ms loops and the user holds the button down for 100ms that is 5 loops it runs through before the code reacts, so I would suggest making it on the downstroke instead of the upstroke