![]() |
Using Coniditionals to Build Custom Command Groups
What is the proper way to build a custom command group based on a runtime change?
Example: Program will look at smartdashboard and get the number of blobs seen. Based on the number it will either drive straight and shot or turn, drive straight and shoot. I tied the following code in the command group constructor. Code:
if (blobs < 2.0) {I want it to run After autonomous is started. |
Re: Using Coniditionals to Build Custom Command Groups
Why not have two command groups built, and then decide which to run at the beginning of Autonomous? This is what we've done in the past.
Alternately, you would build the Command Group in your autonomousInit, rather then in the constructor of the Command Group. |
Re: Using Coniditionals to Build Custom Command Groups
The addsequential method does not work in a command for me?
It says that it is not defined. I think that only works in a command group? |
Re: Using Coniditionals to Build Custom Command Groups
Quote:
|
Re: Using Coniditionals to Build Custom Command Groups
One thing we did, was stored the hot value in the Robot variable to reference later.
Here is an example of how we did that: DriveForwardAndWatch: -drives forward for n seconds -watches while doing it -if it determines the goal is hot, writes to the Robot hot variable. WaitForShot: -checks to see whether or not the first command saw hot through the Robot hot variable -if it saw hot, finish -if it didn't wait for n seconds Shoot: - Not exactly what you were looking for, but may be good enough. I for one wish there was a better way to do conditional commands, to support more complex state machines (i.e. firing different commands on success, failure, and timeout). However, I've never really been able to get this to work with the wpilib command structure. |
Re: Using Coniditionals to Build Custom Command Groups
Quote:
If you move this statement down into autoInit() you should get what you're asking for, no? Code:
public void autonomousInit() { |
Re: Using Coniditionals to Build Custom Command Groups
My team created a class just for this purpose here. To use it:
Code:
addSequential(new Conditional(<Command for true>,<Command for false>) { |
Re: Using Coniditionals to Build Custom Command Groups
Quote:
|
Re: Using Coniditionals to Build Custom Command Groups
Quote:
|
Re: Using Coniditionals to Build Custom Command Groups
Quote:
|
Re: Using Coniditionals to Build Custom Command Groups
Quote:
Anyway, I'll be interested to see what solution you come up with! |
Re: Using Coniditionals to Build Custom Command Groups
We will not be testing this until later today, but I wanted to share my expected solution to Conditional cancelling itself. It requires an extra class, edu.wpi.first.wpilibj.command.PublicCommand, which just exposes a number of Command's methods that are protected or package-private normally:
Code:
package edu.wpi.first.wpilibj.command;Code:
package storm2014.commands.control; |
| All times are GMT -5. The time now is 11:20. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi