Go to Post How well does peanut butter transmit heat? - Lil' Lavery [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
  #6   Spotlight this post!  
Unread 03-14-2015, 08:59 PM
cstelter cstelter is offline
Programming Mentor
AKA: Craig Stelter
FRC #3018 (Nordic Storm)
Team Role: Mentor
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Mankato, MN
Posts: 77
cstelter will become famous soon enough
Re: arcade drive

Quote:
Originally Posted by SirGibbs View Post
At option 2 is it not driving and the pneumatic's aren't working also but I thought that it would be he exact copy of the example but the code is getting permanently deployed at the roborio.


option 2:

Code:
  public void teleopPeriodic() {
        	
	  while (isOperatorControl() && isEnabled()) {
        	myRobot.arcadeDrive(stick);
            Timer.delay(0.01);		
        }
	  
    	Piston = new DoubleSolenoid (0,1);
        ...
The reason you see the symptom of your pneumatics not running is that telopPeriodic is *only* called when isOperatorControl() and isEnabled() are both true. So the first time through telopPeriodic() (which is supposed to be called every 20ms), you enter the while loop that is always true until you disable. You never leave the first call to teleopPeriodic() with this method.

You are mixing two paradigms-- this construct you would use for SampleRobot:

Code:
public class Robot extends SampleRobot {
    . . .
    void operatorControl() {
	  while (isOperatorControl() && isEnabled()) {
        	myRobot.arcadeDrive(stick);
            Timer.delay(0.01);		
        }
    }
In SampleRobot operatorControl is called only once when the Teleop begins.

This is the style to use in IterativeRobot:

Code:
public class Robot extends IterativeRobot {
     ...
     public void teleopPeriodic() {
        	myRobot.arcadeDrive(stick);
        }
Up higher in the IterativeRobot base class there is something similar to

Code:
    	  while (isOperatorControl() && isEnabled()) {

        	teleopPeriodic()

            Timer.delay(0.02);		
        }
It's actually much different, but the effect is the same-- Iterative robot will call teleopPeriodic() every 20ms as long as we're enabled in Teleop mode.

The net effect is in your option 2, your piston code will only be called once (maybe) only when isOperatorControl() goes false or isEnabled() goes false. I say maybe because it wouldn't surprise me if the teleopPeriodic call was on a thread that is terminated when either of these values go false.

But this explains the symptom you found.

Stick with Option 1 and take Matt's advice and you should get up and running quickly
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 08:04 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