Go to Post Dave doesn't predict the future. He creates it. - Alan Anderson [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Spotlight this post!  
Unread 28-08-2016, 23:21
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 361
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Cancel a command

Whoops, didn't see that section of the docs

There's an easy way to do what you want in your situation though.

Code:
public class ScissorToPosition extends Command {
  // ...
  
  boolean isUnsafe = false;

  public void initialize() {
    if(m_setpoint > 70 && Robot.wristPID.getSetpoint() > 30) { 
      System.out.println("Scissor canceled since wrist > 30"); 
      
      isUnsafe = true;
    } else {
      isUnsafe = false;
      
      // init as usual
    }
  }

  // ...

  public void execute() {
    if(isUnsafe) {
      return;
      // IMPORTANT. execute() will be called once regardless of isFinished() status
    }
    
    // execute as usual
  }

  public void isFinished() {
    if(isUnsafe) {
      return true;
    }
    
    return Robot.scissorPID.onTarget();
  }
}
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:30.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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