![]() |
How simple should commands be? And how should they be structured?
Hello everyone,
I was wondering how other people structured or put together commands in their command-based robots. I am always struggling with myself on how to structure them and how simple they should be. For example, lets say I want to open and close a solenoid. Should I make a command that opens it, and a command that closes it, or just have a single command that gets passed a value to tell which valve I want to open? I think the first way of doing that is way too "separated", so in my code I use the second method. However, one issue I always run into is when I want to use "axis" values on a joystick in a command. For example, on our shooter, we use the right trigger on the xbox 360 controller for spinning up our shooter, but that leads to a weird situation where I had to write a special condition where if the time parameter passed in was exactly 0, it would assume it was in teleoperated mode. Here is what I am talking about: Code:
Thanks, Drew |
Re: How simple should commands be? And how should they be structured?
When I needed to activate something via the Xbox 360 controller, I used the wpilib triggers functionality.
My GetTrigger.h (C++) Code:
#ifndef GetTrigger_HCode:
#include "GetTrigger.h" |
Re: How simple should commands be? And how should they be structured?
Oh wow! I didn't even know that existed! Thanks!
I still would like to keep this thread up for discussion on how people use the command based framework. I find it very intresting how people structure their code. |
Re: How simple should commands be? And how should they be structured?
Quote:
Code:
class SomethingToggleCommand: CommandBase { |
Re: How simple should commands be? And how should they be structured?
As far as I am aware, none of our commands take arguments.
As an example, for our ball pickup, we have four separate commands:
|
| All times are GMT -5. The time now is 09:24. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi