Go to Post I'll try to sum up the icon and compile thing quickly so as not to interrupt the design of SkyNet. - Greg McKaskle [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-16-2016, 11:10 PM
Mikey Richards's Avatar
Mikey Richards Mikey Richards is offline
Registered User
FRC #3812 (Bits and Bots)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: Kelso, WA
Posts: 14
Mikey Richards is an unknown quantity at this point
Disable Robot in Code

Our team is trying to add a button to our joystick that disables the robot. Right now we are using java's System.exit(0), but this also loses the robot code. Is there a way to disable the robot, but not lose robot code.
Reply With Quote
  #2   Spotlight this post!  
Unread 06-16-2016, 11:23 PM
cgmv123's Avatar
cgmv123 cgmv123 is offline
FRC RI/FLL Field Manager
AKA: Max Vrany
FRC #1306 (BadgerBOTS)
Team Role: College Student
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Madison, WI
Posts: 2,069
cgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond repute
Re: Disable Robot in Code

Pseudo(ish)code:
Code:
boolean disabled = false;
if (button pressed)
disabled  = !disabled;
if (disabled)
all motors set at 0
else
normal code executes
This needs to go in the main control loop.
__________________
BadgerBOTS Robotics|@team1306|Facebook: BadgerBOTS
2016 FIRST Championship Tesla Division | 2016 Wisconsin Regional Engineering Inspiration Award

2015 FIRST Championship Carson Division | 2015 Wisconsin Regional Chairman's Award

2013 FIRST Championship Curie Division | 2013 Wisconsin Regional Chairman's Award

2012 FIRST Championship Archimedes Division | 2012 Wisconsin Regional Engineering Inspiration Award, Woodie Flowers Finalist Award (Lead Mentor Ben Senson)

Reply With Quote
  #3   Spotlight this post!  
Unread 06-17-2016, 08:15 AM
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 429
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
If you're using a command based project the above code may be difficult to integrate.

Instead you could just stop the scheduler from running (preventing your commands from executing) by calling Scheduler.getInstance().disable();

When you want to enable the scheduler again call Scheduler.getInstance().enable();

Note that depending on how you output values to your motor controllers, they could latch on the last command they received before you pressed the button. Test your code out with the robot on blocks and with a mechanism that can't stall out and break itself before you use it for anything safety related.

Note that the robot is still "enabled" so it's possible for things to move of they are commanded to do so (if you have code that sets outputs that's not run within a command).

Sent from my LGLS751 using Tapatalk
__________________
http://team2168.org
Reply With Quote
  #4   Spotlight this post!  
Unread 06-17-2016, 09:44 AM
FrankJ's Avatar
FrankJ FrankJ is offline
Robot Mentor
FRC #2974 (WALT)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: Marietta GA
Posts: 1,886
FrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond repute
Re: Disable Robot in Code

Put something on the DS that sends a [enter] keyboard command when the button is pressed? We tested this at one time on our teeshirt cannon. We haven't actually implemented it yet though.
__________________
If you don't know what you should hook up then you should read a data sheet
Reply With Quote
  #5   Spotlight this post!  
Unread 06-17-2016, 01:23 PM
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: 298
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: Disable Robot in Code

Edit: DriverStation has a function called InDisabled(boolean)

Try calling that with true; it might work.

---

You can override isDisabled() in your robot class like this:

Code:
public boolean isDisabled() {
    return super.isDisabled() || myDisableFlag;
}
This should work whether you extend RobotBase or IterativeRobot

Two things:
- The Driver Station won't recognize that you are disabled when you set the flag
- You'll need to make sure to clear the flag yourself when you want to enable again

Last edited by euhlmann : 06-17-2016 at 01:28 PM.
Reply With Quote
Reply


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 08:19 AM.

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