![]() |
Testing commands with parameters on SmartDashboard
Greetings Folks,
We are working with the Command Based robot setup and find ourselves wondering if it is possible the run commands which take parameters to their constructor on the smart dashboard. Ofcourse we have added buttons with Code:
SmartDashboard.putData("command", new LiftUp());Code:
SmartDashboard.putData("command", new Move(1.25));http://wpilib.screenstepslive.com/s/...sting-commands |
Re: Testing commands with parameters on SmartDashboard
I have not found a way to do this, but you are right it would be very nice to be able to do this.
You could always write a command that reads a value from the SmartDashboard in the initialize() method. But now you're adding additional functionality to your command that you probably don't want in the end. |
Re: Testing commands with parameters on SmartDashboard
Quote:
You could write a separate command called CreateCommand. Have this present itself on SmartDashboard along with the arguments. In your case Distance. then something like: Code:
public class CreateCommand extends Command {Expanding on that idea you could take it a step futher with Code:
public class CreateCommand extends Command {Extending this idea even further, two years ago our team created the ability to associate a keyword with each command and add in a parse entry that would receive all the passed args. This allowed us to do things like D(0.5,4);DP(0.9,120);X;P_L;D(-0.5,2) which would be parsed into a command group effectively doing addSequential(new DriveForTime(0.5,4)); addSequential(new DriveToPosition(0.9,120)); addSequential(new ShootSequence()); addParallel(new ReloadSequenc()); addSequential(new DriveForTime(-0.5,2); During disabledPeriodic we would monitor the string value from SmartDashboard and rebuild the autonomous command any time it changed. So tuning an autonomous sequence never required a recompile-- just change the string while disabled and then start autonomous again. We'd head into a tournament with quite a few canned sequences for various situations, or we could quickly write a brand new one if we had to do something unexpected. Once the robot was on out on the field we could paste the sequence we needed into the smart dashboard and look for feedback in the drive station log that it was accepted and we were good to go for autonomous. Our lead programmer who wrote all this code is gone this year, and the code package he published relies on CommandBase base class. But this year we have generics (which I know nothing about but I understand they are like C++ templates) so I think that might greatly simplify the code needed to accomplish this. That along with a full java with a full complement of parsing functionality we may get there yet this year. You're starting down a path that leads to much happiness IMO. |
| All times are GMT -5. The time now is 10:53. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi