Go to Post Teaching students should take place in the offseason. Applying the skills learned is what the real season is for. - [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
  #14   Spotlight this post!  
Unread 28-02-2014, 23:56
miw14 miw14 is offline
Registered User
FRC #4840
 
Join Date: Feb 2014
Location: Michigan
Posts: 19
miw14 is an unknown quantity at this point
Re: URGENT:Auto Problem trying to fix before tomorrow

Quote:
Originally Posted by lineskier View Post
Ideally you wouldn't disable the safety enable. Now, given that you're at comp, i'm not going to suggest enabling it at this point. However, we can rearrange your code to ensure that the drive is updated enough.

Time is in milliseconds. Unlike other programming platforms, the crio really does not like long delays. Thus it's better for you to manage time, and adjust your motor outputs based on time.

Code:
public void autonomous() { 
        myDrive.setSafetyEnabled(false); 
        
        long startTime = System.currentTimeMillis();
        
        while(isAutonomous() && isEnabled()){
            long timePassed = System.currentTimeMillis() - startTime;
            if(timePassed < 3500){
                myDrive.drive(-.5, 0.0);
            }else if (timePassed < 5000){
                myDrive.stopMotor();
            }else if (timePassed < 8500){
                startRaisingLauncher();
            }else{
                stopMovingLauncher();
                //stopAll();
            }
            Timer.delay(0.01); 
        }
        
        stopAll();
    }
Thank you! I am a little bit confused though. You said time is in miliseconds, but it seemed like the Timer.delay worked fine with seconds with the mydrive.

Another question about the code. For the time conditions in the else statements, are the last two statements supposed to be greater than signs instead of less than signs? *Nevermind, I believe I understand this now.

Lastly, what do you think was the problem with the original code?

Last edited by miw14 : 01-03-2014 at 00:17.
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 11:29.

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