|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
Re: Java Conditional Command
Quote:
That suggests to me that you would want to have polymorphic forms of the command, including one which allows both operands to be objects. This could then be used to do things like (for example) returning the original drive direction by driving faster with the left wheel than the right, then equalizing after a Code:
waitUntil(leftAxle.getDistance(), GREATER_THAN_EQUAL, rightAxle.getDistance()) |
|
#2
|
|||||
|
|||||
|
Re: Java Conditional Command
Quote:
|
|
#3
|
|||||
|
|||||
|
Re: Java Conditional Command
Ease of debugging. An exception that tells you that one of the operands ought to be an object is more informative than a no such method error at compile. It can also be caught and allowed to run if that's what the programmer really wants. Sort of like a "do you really want to delete this? dialog.
|
|
#4
|
|||||
|
|||||
|
Re: Java Conditional Command
Quote:
|
|
#5
|
|||||
|
|||||
|
Re: Java Conditional Command
Seeing the syntax error, the normal reaction (at least on my team) would be to check for a typo of a failed import, because these are the usual causes of our syntax errors after punctuation. It would take a longer time to figure out a syntax error than a "NeitherOperandIsObject" exception.
|
|
#6
|
|||||
|
|||||
|
Re: Java Conditional Command
Quote:
Code:
The method waitUntil(IProvidesValue, Operation, IProvidesValue) in the type ConditionalWaitCommand is not applicable for the arguments (double, Operation, double) |
|
#7
|
||||
|
||||
|
Re: Java Conditional Command
Quote:
Code:
addSequential(waitUntil(driveTrain::getDistance, GREATER_THAN, 50)); Quote:
Code:
public static <T, U> ConditionalCommand waitUntil(Supplier<T> left, BiPredicate<T, U> tester, Supplier<U> right)
public static <T, U> ConditionalCommand waitUntil(Supplier<T> left, BiPredicate<T, U> tester, U right)
Code:
waitUntil(driveTrain::getDistance, GREATER_THAN, 50); Code:
GREATER_THAN = (left, right) -> left > right |
|
#8
|
|||||
|
|||||
|
Re: Java Conditional Command
Sam,
Any chance of getting some of these types of concepts into the WPILib at some point? I'm really liking the method reference strategy. Last edited by notmattlythgoe : 16-11-2015 at 11:22. |
|
#9
|
||||
|
||||
|
Re: Java Conditional Command
I would be surprised if it made it in this year with kickoff so close.
It would also need to look similar in C++ with whatever it uses for lambdas and method references |
|
#10
|
|||||
|
|||||
|
Re: Java Conditional Command
Yeah, I doubted anything additional would make it in this year. I meant more for future years.
|
|
#11
|
||||
|
||||
|
Re: Java Conditional Command
Maybe. It doesn't seem like a huge project but it might not be a priority for next year
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|