Go to Post Welcome to FIRST! It's in your blood now... - AmyPrib [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 02-19-2016, 02:46 PM
gofmannir gofmannir is offline
Registered User
AKA: Nir Gofman
FRC #2096 (RoboActive)
Team Role: Programmer
 
Join Date: Nov 2015
Rookie Year: 2015
Location: Israel
Posts: 11
gofmannir is an unknown quantity at this point
How to do automatic action in the teleop?

Hello
I'm trying to implement that when I'm press a button on the joystick the robot starting an automatic actions (in the teleop periodic)...
for example when pressing a button 3 it will called a custom method:

Code:
if(stick.getRawButton(3)){
     startAutoMoving();
}
But I'm still want the all the other statements and the other action still will work - which means the I cant use here the delay() method...

Any ideas?
Reply With Quote
  #2   Spotlight this post!  
Unread 02-19-2016, 05:07 PM
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: How to do automatic action in the teleop?

Sure. Your autonomous action should be implemented using a state machine. The state machine should have a START state and a DONE state. In your teleop periodic, you check for a button and then start the state machine. You also add a statement to execute the state machine in your teleop periodic code. Something like this (this is pseudocode so it is not syntactically correct):
Code:
private int autoActionState = 0;  // 0 is the DONE state.

private void runAutoAction()
{
    switch (autoActionState)
    {
        case 1:
            // do step 1
            break;

        case 2:
            // do step 2
            break;
        ....
        ....
        default:
        case 0:
            // We are done, don't do anything.
            break;
    }
}

public void teleOp_Periodic()
{
    if (button 1 is pressed)
    {
        // Start the state machine.
        autoActionState = 1;
    }

    // doing other things.
    ....
    ....

    runAutoAction();
}
__________________
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:59 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