Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Java Conditional Command (http://www.chiefdelphi.com/forums/showthread.php?t=139247)

SamCarlberg 16-11-2015 11:39

Re: Java Conditional Command
 
Quote:

Originally Posted by notmattlythgoe (Post 1505599)
Yeah, I doubted anything additional would make it in this year. I meant more for future years.

Maybe. It doesn't seem like a huge project but it might not be a priority for next year

SamCarlberg 16-11-2015 11:48

Re: Java Conditional Command
 
Quote:

Originally Posted by Joe Ross (Post 1505397)
In this particular case of the example, I think it would be easier to build the logic into a single command.

However, the pattern is definitely useful. We had cases last year where we wanted to start a parallel command halfway through another command (for a different subsytem). We sequenced them with waits, but a way to generically peek at the progress of the first command would be much better.

If you just want a rising/falling edge trigger, you could just poll the isFinished() method of the previous command, though that would break the CommandGroup paradigm a little

notmattlythgoe 16-11-2015 12:00

Re: Java Conditional Command
 
Quote:

Originally Posted by SamCarlberg (Post 1505603)
If you just want a rising/falling edge trigger, you could just poll the isFinished() method of the previous command, though that would break the CommandGroup paradigm a little

I've written one off wait for specific value commands that basically do the same thing the initial thread was started about. Things like having the robot move at a certain speed and when it reaches certain distances fire off certain commands. Think 7 disc auto in 2013. Never needed to stop, but as you reached the certain distances you could activate a certain chain of events.

What is the CommandGroup paradigm for doing down a different command path based on a decision from a previous step? Think hot goals in 2014.

SamCarlberg 16-11-2015 12:11

Re: Java Conditional Command
 
Quote:

Originally Posted by notmattlythgoe (Post 1505605)
I've written one off wait for specific value commands that basically do the same thing the initial thread was started about. Things like having the robot move at a certain speed and when it reaches certain distances fire off certain commands. Think 7 disc auto in 2013. Never needed to stop, but as you reached the certain distances you could activate a certain chain of events.

What is the CommandGroup paradigm for doing down a different command path based on a decision from a previous step? Think hot goals in 2014.

Sounds a lot like an event/listener model.

That's not how CommandGroups were intended to be used, which is why it breaks the paradigm.

randallh 16-11-2015 17:45

Re: Java Conditional Command
 
Quote:

Originally Posted by notmattlythgoe (Post 1505429)
Yeah, I should have set the first command as parallel not sequential. I like the lambda ideas. Going to have to play around with them.

If you've not already seen Strongback, you may want to take a look since its command framework (which we think is improved over WPILib's) uses lambdas throughout. In fact, it uses lambdas throughout the whole API.

See the announcement on CD, and the Using Strongback online book.

Best regards

MrRoboSteve 16-11-2015 17:56

Re: Java Conditional Command
 
Quote:

Originally Posted by notmattlythgoe (Post 1505337)
Code:

            addSequential(new DriveCommand(0.5));
        addSequential(waitUntil(drivetrain.getDistance(), GREATER_THAN, 50));
        addSequential(new DriveCommand(0));


How do I describe what the robot should do if the distance never exceeds 50?

notmattlythgoe 16-11-2015 19:21

Re: Java Conditional Command
 
Quote:

Originally Posted by MrRoboSteve (Post 1505677)
How do I describe what the robot should do if the distance never exceeds 50?

If you're expecting it to timeout you could just call the addSequential() that takes a timeout parameter also.


All times are GMT -5. The time now is 11:52.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi