Go to Post And yes. The Super Bowl is on, and I'm replying to a thread on Chief Delphi... - BobbyVanNess [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
  #76   Spotlight this post!  
Unread 23-01-2015, 13:24
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is online now
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,728
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Autonomous Help

Quote:
Originally Posted by curtis0gj View Post
None in the ds error box but I don't know how to check the roborio error log.
The riolog is in eclipse. IF you don't see it as a tab near the bottom then go yo Window -> Show View -> Riolog.
Reply With Quote
  #77   Spotlight this post!  
Unread 23-01-2015, 13:40
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Autonomous Help

Quote:
Originally Posted by notmattlythgoe View Post
The riolog is in eclipse. IF you don't see it as a tab near the bottom then go yo Window -> Show View -> Riolog.
I don't see anything bad in the riolog or ds log so idk whats going on with that.
Reply With Quote
  #78   Spotlight this post!  
Unread 23-01-2015, 15:47
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Autonomous Help

Hey guys I finally got the encoder going, my electrical guy said it was grounding on something. Anyway I am getting a nice reading on smart db however, when I run autonomous mode the robot turns about 180 stops and turns again and this never ends. I think I am stuck in an if loop and it's not entering the straight driving portion of the program...

Code:
public class Robot extends IterativeRobot {
	
	RobotDrive robot;
    Joystick stick;
    Encoder encoder;	
    Gyro gyro1;
    
    static final double Kp = 0.05;
    
    public void robotInit() {
    	
    	 robot = new RobotDrive(0, 1);
         stick = new Joystick(0);
         gyro1 = new Gyro(0);
         gyro1.reset();
         gyro1.initGyro();
         encoder = new Encoder(0, 1, false, EncodingType.k4X);
       
         
         encoder.setDistancePerPulse(1);
       
         encoder.getDistance();
         

    }

   
    public void autonomousPeriodic() {

    	gyro1.reset();
		
    	while(isAutonomous() && isEnabled())  {
    		
    		double angle = gyro1.getAngle();
    		double distance = encoder.get();
    		
    		SmartDashboard.putNumber("angle", angle);
    		SmartDashboard.putNumber("distance", distance);
    		
    		robot.drive(-0.15, -1);
    		
    		if(angle > 150) {
    			
    			robot.drive(0,0);
    			gyro1.reset();
    			encoder.reset();
    			
    			Timer.delay(0.5);

    			break;
    			
    			}
    		
    			Timer.delay(0.1);
    	}
    	
				while (isAutonomous() && isEnabled()) {

						double angle2 = gyro1.getAngle(); 
						double distance2 = encoder.get();
						
						SmartDashboard.putNumber("distance", distance2);
						SmartDashboard.putNumber("angle", angle2);
						
						robot.drive(-0.20, -angle2 * Kp); 
					
						if(encoder.getDistance() < 100)  {
							robot.drive(0,-0); 
							
							break;
						}
						Timer.delay(0.1);	
				}
				
    			}
Reply With Quote
  #79   Spotlight this post!  
Unread 23-01-2015, 15:53
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is online now
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,728
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Autonomous Help

Quote:
Originally Posted by curtis0gj View Post
Hey guys I finally got the encoder going, my electrical guy said it was grounding on something. Anyway I am getting a nice reading on smart db however, when I run autonomous mode the robot turns about 180 stops and turns again and this never ends. I think I am stuck in an if loop and it's not entering the straight driving portion of the program...

Code:
public class Robot extends IterativeRobot {
	
	RobotDrive robot;
    Joystick stick;
    Encoder encoder;	
    Gyro gyro1;
    
    static final double Kp = 0.05;
    
    public void robotInit() {
    	
    	 robot = new RobotDrive(0, 1);
         stick = new Joystick(0);
         gyro1 = new Gyro(0);
         gyro1.reset();
         gyro1.initGyro();
         encoder = new Encoder(0, 1, false, EncodingType.k4X);
       
         
         encoder.setDistancePerPulse(1);
       
         encoder.getDistance();
         

    }

   
    public void autonomousPeriodic() {

    	gyro1.reset();
		
    	while(isAutonomous() && isEnabled())  {
    		
    		double angle = gyro1.getAngle();
    		double distance = encoder.get();
    		
    		SmartDashboard.putNumber("angle", angle);
    		SmartDashboard.putNumber("distance", distance);
    		
    		robot.drive(-0.15, -1);
    		
    		if(angle > 150) {
    			
    			robot.drive(0,0);
    			gyro1.reset();
    			encoder.reset();
    			
    			Timer.delay(0.5);

    			break;
    			
    			}
    		
    			Timer.delay(0.1);
    	}
    	
				while (isAutonomous() && isEnabled()) {

						double angle2 = gyro1.getAngle(); 
						double distance2 = encoder.get();
						
						SmartDashboard.putNumber("distance", distance2);
						SmartDashboard.putNumber("angle", angle2);
						
						robot.drive(-0.20, -angle2 * Kp); 
					
						if(encoder.getDistance() < 100)  {
							robot.drive(0,-0); 
							
							break;
						}
						Timer.delay(0.1);	
				}
				
    			}
What is the reported angle during the second part of the autonomous routine? My guess is that it is not scaled enough and it is correcting it in the wrong direction.
Reply With Quote
  #80   Spotlight this post!  
Unread 23-01-2015, 16:04
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Autonomous Help

Quote:
Originally Posted by notmattlythgoe View Post
What is the reported angle during the second part of the autonomous routine? My guess is that it is not scaled enough and it is correcting it in the wrong direction.
Unfortunatly, I can't check what angle it's reading until monday. However I can fix the correcting in the wrong direction would that just be a different < or change my -1 to 1?
Reply With Quote
  #81   Spotlight this post!  
Unread 23-01-2015, 16:09
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Autonomous Help

Quote:
Originally Posted by curtis0gj View Post
Hey guys I finally got the encoder going, my electrical guy said it was grounding on something.
That's why you should turn the encoder shaft slowly and observe the hi/lo quadrature behavior of A & B when testing with a multimeter...


Reply With Quote
  #82   Spotlight this post!  
Unread 23-01-2015, 16:14
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is online now
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,728
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Autonomous Help

Quote:
Originally Posted by curtis0gj View Post
Unfortunatly, I can't check what angle it's reading until monday. However I can fix the correcting in the wrong direction would that just be a different < or change my -1 to 1?
I'm guessing you need to change it to positive, but that will all depend on the angle value.
Reply With Quote
  #83   Spotlight this post!  
Unread 23-01-2015, 16:37
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Autonomous Help

Quote:
Originally Posted by notmattlythgoe View Post
I'm guessing you need to change it to positive, but that will all depend on the angle value.
Okay will this fix the issue where it's not driving straight?
Reply With Quote
  #84   Spotlight this post!  
Unread 23-01-2015, 16:40
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is online now
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,728
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Autonomous Help

Quote:
Originally Posted by curtis0gj View Post
Okay will this fix the issue where it's not driving straight?
I don't know. I need to know what the reported angle values are to answer that.
Reply With Quote
  #85   Spotlight this post!  
Unread 23-01-2015, 16:47
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Autonomous Help

Quote:
Originally Posted by notmattlythgoe View Post
I don't know. I need to know what the reported angle values are to answer that.
Okay I will figure this out on Monday thanks so much for the help with everything, it's really helped our team a tremendous amount.
Reply With Quote
  #86   Spotlight this post!  
Unread 23-01-2015, 17:31
mmaunu's Avatar
mmaunu mmaunu is offline
Registered User
FRC #2485 (W.A.R. Lords)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2010
Location: San Diego, CA
Posts: 89
mmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the rough
Re: Autonomous Help

Quote:
Originally Posted by curtis0gj View Post
Hey guys I finally got the encoder going, my electrical guy said it was grounding on something. Anyway I am getting a nice reading on smart db however, when I run autonomous mode the robot turns about 180 stops and turns again and this never ends. I think I am stuck in an if loop and it's not entering the straight driving portion of the program...

Code:
public class Robot extends IterativeRobot {
	
	RobotDrive robot;
    Joystick stick;
    Encoder encoder;	
    Gyro gyro1;
    
    static final double Kp = 0.05;
    
    public void robotInit() {
    	
    	 robot = new RobotDrive(0, 1);
         stick = new Joystick(0);
         gyro1 = new Gyro(0);
         gyro1.reset();
         gyro1.initGyro();
         encoder = new Encoder(0, 1, false, EncodingType.k4X);
       
         
         encoder.setDistancePerPulse(1);
       
         encoder.getDistance();
         

    }

   
    public void autonomousPeriodic() {

    	gyro1.reset();
		
    	while(isAutonomous() && isEnabled())  {
    		
    		double angle = gyro1.getAngle();
    		double distance = encoder.get();
    		
    		SmartDashboard.putNumber("angle", angle);
    		SmartDashboard.putNumber("distance", distance);
    		
    		robot.drive(-0.15, -1);
    		
    		if(angle > 150) {
    			
    			robot.drive(0,0);
    			gyro1.reset();
    			encoder.reset();
    			
    			Timer.delay(0.5);

    			break;
    			
    			}
    		
    			Timer.delay(0.1);
    	}
    	
				while (isAutonomous() && isEnabled()) {

						double angle2 = gyro1.getAngle(); 
						double distance2 = encoder.get();
						
						SmartDashboard.putNumber("distance", distance2);
						SmartDashboard.putNumber("angle", angle2);
						
						robot.drive(-0.20, -angle2 * Kp); 
					
						if(encoder.getDistance() < 100)  {
							robot.drive(0,-0); 
							
							break;
						}
						Timer.delay(0.1);	
				}
				
    			}

I hope that it is ok to jump in here...

It looks like you started off with a Robot that extended SampleRobot and have now migrated to a class that extends IterativeRobot. The way that your autonomous code will be executed is very different in these two cases.

SampleRobot
When you extend SampleRobot, your autonomous method will get called for you once. You need to write loops in your code that keep running until you have completed your task. This is why you have the while loop:
while( isAutonomous() and isEnabled() )
{
//stuff
}
You also put your own calls to Timer.delay() in this type of robot because nothing is pausing your code (nothing is creating a timed structure for you).

IterativeRobot
When you extend IterativeRobot, your autonomousPeriodic() method will be called every 20 ms. If you put a loop in this method that runs for longer than 20 ms...well, that is bad. You also don't want to put calls to Timer.delay() in here as this will slow down the execution cycle. Since the code in autonomousPeriodic() is being executed every 20 ms, you want to avoid loops. Put the body of your loops in the method; since it is being executed every 20 ms, it is being looped for you. Also, be careful about resetting values in autonomousPeriodic() without checking a condition. Since the code gets executed repeatedly, you will be continuously resetting the value (e.g. the call to reset the gyro at the top of the method is constantly resetting the gyro).

Proposed new method:

Code:
//a new instance variable for the class...true until the initial turn is done...only false when you want to drive straight
boolean doingInitialTurn;

public void autonomousInit() {
    gyro1.reset();
    doingInitialTurn = true;
}

public void autonomousPeriodic() {
	
    		double angle = gyro1.getAngle();
    		double distance = encoder.getDistance();                     //NOTE: changed to getDistance()
    		
    		SmartDashboard.putNumber("angle", angle);
    		SmartDashboard.putNumber("distance", distance);
    		
               // if you are just starting and doing the first turn...turn code
                if( angle <= 150 && doingInitialTurn )
    		       robot.drive(-0.15, -1);
    		
                // otherwise, if the angle is now greater than 150 but you are just finishing the turn...stop turning
    		else if( doingInitialTurn ) { 
    			
    			robot.drive(0,0);
                        doingInitialTurn = false;
    			gyro1.reset();
    			encoder.reset();
    			

    		}
    		
    	        // if you are completely done with the turn...drive forward instead
                else 
                {
                        // you can reuse the original angle and distance values from the top of the method...
                        // they get updated every 20 ms
			//double angle2 = gyro1.getAngle(); 
			//double distance2 = encoder.getDistance();
			
                        // You also don't need to put them to the SmartDashboard again since the lines at the
                        // top of the method do that for you every 20 ms			
			//SmartDashboard.putNumber("distance", distance);
			//SmartDashboard.putNumber("angle", angle);
			
			
			robot.drive(-0.20, -angle * Kp); 
					
			if(distance > 100)
				robot.drive(0,-0); 
							
							
		}
				
}
Also, the line of code that checks for when to stop driving forward had reversed logic; if the distance traveled was less than 100, you stopped driving. You want to stop driving only after the distance traveled is greater than 100. You had:
Quote:
Code:
if(encoder.getDistance() < 100)  {
	robot.drive(0,-0); 
							
	break;
}
Lastly, you do not want to set the distance per pulse to be 1. The distance per pulse is the number of inches (or other unit) that the robot actually moves every time the encoder registers a "pulse", which is 250 times per revolution of the encoder (or 1000 times per revolution if you are using 4x encoding?). The Encoder's get() method returns the count (the same as the number of pulses?) since the last call to reset. The getDistance() method returns the count multiplied by the number specified in setDistancePerPulse(). If you set the distance per pulse to 1, then you will need to travel a great "distance" in your code.

To find the correct value for setDistancePerPulse(), we typically:
  1. Reset the encoder in teleopInit(). This code will only run when you first enable teleop.
  2. In teleopPeriodic(), get the count with encoder.get() and print it or put it up on the SmartDashboard. This code will run every 20 ms when teleop mode is enabled.
  3. Manually move the robot forward 10 feet (as close to 120 inches as you can).
  4. Divide 120 inches by the count from the encoder...that is your distance per pulse.

Good luck and let me know if this did or didn't work...unfortunately, I didn't test the code
__________________
2014 Las Vegas (Winners with 987, 2478; Excellence in Engineering)
2014 San Diego (Finalists with 987, 3250; Quality Award)
2013 Inland Empire (Winners with 1538, 968; Excellence in Engineering Award)
2013 San Diego (Finalists with 2984, 4322; Creativity Award)
2012 Las Vegas (Finalists with 2034, 3187; Quality Award)
Reply With Quote
  #87   Spotlight this post!  
Unread 23-01-2015, 18:04
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Autonomous Help

Quote:
Originally Posted by mmaunu View Post
I hope that it is ok to jump in here...

It looks like you started off with a Robot that extended SampleRobot and have now migrated to a class that extends IterativeRobot. The way that your autonomous code will be executed is very different in these two cases.

SampleRobot
When you extend SampleRobot, your autonomous method will get called for you once. You need to write loops in your code that keep running until you have completed your task. This is why you have the while loop:
while( isAutonomous() and isEnabled() )
{
//stuff
}
You also put your own calls to Timer.delay() in this type of robot because nothing is pausing your code (nothing is creating a timed structure for you).

IterativeRobot
When you extend IterativeRobot, your autonomousPeriodic() method will be called every 20 ms. If you put a loop in this method that runs for longer than 20 ms...well, that is bad. You also don't want to put calls to Timer.delay() in here as this will slow down the execution cycle. Since the code in autonomousPeriodic() is being executed every 20 ms, you want to avoid loops. Put the body of your loops in the method; since it is being executed every 20 ms, it is being looped for you. Also, be careful about resetting values in autonomousPeriodic() without checking a condition. Since the code gets executed repeatedly, you will be continuously resetting the value (e.g. the call to reset the gyro at the top of the method is constantly resetting the gyro).

Proposed new method:

Code:
//a new instance variable for the class...true until the initial turn is done...only false when you want to drive straight
boolean doingInitialTurn;

public void autonomousInit() {
    gyro1.reset();
    doingInitialTurn = true;
}

public void autonomousPeriodic() {
	
    		double angle = gyro1.getAngle();
    		double distance = encoder.getDistance();                     //NOTE: changed to getDistance()
    		
    		SmartDashboard.putNumber("angle", angle);
    		SmartDashboard.putNumber("distance", distance);
    		
               // if you are just starting and doing the first turn...turn code
                if( angle <= 150 && doingInitialTurn )
    		       robot.drive(-0.15, -1);
    		
                // otherwise, if the angle is now greater than 150 but you are just finishing the turn...stop turning
    		else if( doingInitialTurn ) { 
    			
    			robot.drive(0,0);
                        doingInitialTurn = false;
    			gyro1.reset();
    			encoder.reset();
    			

    		}
    		
    	        // if you are completely done with the turn...drive forward instead
                else 
                {
                        // you can reuse the original angle and distance values from the top of the method...
                        // they get updated every 20 ms
			//double angle2 = gyro1.getAngle(); 
			//double distance2 = encoder.getDistance();
			
                        // You also don't need to put them to the SmartDashboard again since the lines at the
                        // top of the method do that for you every 20 ms			
			//SmartDashboard.putNumber("distance", distance);
			//SmartDashboard.putNumber("angle", angle);
			
			
			robot.drive(-0.20, -angle * Kp); 
					
			if(distance > 100)
				robot.drive(0,-0); 
							
							
		}
				
}
Also, the line of code that checks for when to stop driving forward had reversed logic; if the distance traveled was less than 100, you stopped driving. You want to stop driving only after the distance traveled is greater than 100. You had:


Lastly, you do not want to set the distance per pulse to be 1. The distance per pulse is the number of inches (or other unit) that the robot actually moves every time the encoder registers a "pulse", which is 250 times per revolution of the encoder (or 1000 times per revolution if you are using 4x encoding?). The Encoder's get() method returns the count (the same as the number of pulses?) since the last call to reset. The getDistance() method returns the count multiplied by the number specified in setDistancePerPulse(). If you set the distance per pulse to 1, then you will need to travel a great "distance" in your code.

To find the correct value for setDistancePerPulse(), we typically:
  1. Reset the encoder in teleopInit(). This code will only run when you first enable teleop.
  2. In teleopPeriodic(), get the count with encoder.get() and print it or put it up on the SmartDashboard. This code will run every 20 ms when teleop mode is enabled.
  3. Manually move the robot forward 10 feet (as close to 120 inches as you can).
  4. Divide 120 inches by the count from the encoder...that is your distance per pulse.

Good luck and let me know if this did or didn't work...unfortunately, I didn't test the code
Thanks for the feed back! I have been receiving so much positive feed back it's wonderful. Any who, the reason I switch from SampleRobot to IterativeRobot is because I made a new project later on just to try different autonomous programs so I did not muck up my original project (Also because when I made a new project I did not know what the difference was between the two...). However, now that I have a good idea of what my autonomous is going to be should I switch back to SampleRobot? I would like to keep the loops so I am guessing I need to switch, let me know what you think. Also thanks for the setDistanceperPulse tuning I will do that on Monday to get it nice and tuned.
Reply With Quote
  #88   Spotlight this post!  
Unread 23-01-2015, 18:38
mmaunu's Avatar
mmaunu mmaunu is offline
Registered User
FRC #2485 (W.A.R. Lords)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2010
Location: San Diego, CA
Posts: 89
mmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the rough
Re: Autonomous Help

Quote:
Originally Posted by curtis0gj View Post
Thanks for the feed back! I have been receiving so much positive feed back it's wonderful. Any who, the reason I switch from SampleRobot to IterativeRobot is because I made a new project later on just to try different autonomous programs so I did not muck up my original project (Also because when I made a new project I did not know what the difference was between the two...). However, now that I have a good idea of what my autonomous is going to be should I switch back to SampleRobot? I would like to keep the loops so I am guessing I need to switch, let me know what you think. Also thanks for the setDistanceperPulse tuning I will do that on Monday to get it nice and tuned.
As for which template to use (Sample or Iterative), that is up to you. The SampleRobot template gets complicated quickly if you add any complexity to your code. If you like the loops, then you will need to use SampleRobot.

If the code above makes sense, though, I would encourage you to explore the IterativeRobot template. The teleop code works in a similar fashion: teleopInit() gets called once when teleop is enabled and teleopPeriodic() gets called every 20 ms for you (so avoid loops that don't exit quickly and do not use Timer.delay() to pause your code). Also, the 20 ms is just a great approximation...the loop timing is reallllly close to every 20 ms (certainly close enough for what we're doing).

If you do switch back to SampleRobot, then you will need the loops and the calls to Timer.delay().

Keep plugging away at it and keep asking questions. ChiefDelphi is full of people that want to help
__________________
2014 Las Vegas (Winners with 987, 2478; Excellence in Engineering)
2014 San Diego (Finalists with 987, 3250; Quality Award)
2013 Inland Empire (Winners with 1538, 968; Excellence in Engineering Award)
2013 San Diego (Finalists with 2984, 4322; Creativity Award)
2012 Las Vegas (Finalists with 2034, 3187; Quality Award)
Reply With Quote
  #89   Spotlight this post!  
Unread 23-01-2015, 23:28
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Autonomous Help

Quote:
Originally Posted by mmaunu View Post
As for which template to use (Sample or Iterative), that is up to you. The SampleRobot template gets complicated quickly if you add any complexity to your code. If you like the loops, then you will need to use SampleRobot.

If the code above makes sense, though, I would encourage you to explore the IterativeRobot template. The teleop code works in a similar fashion: teleopInit() gets called once when teleop is enabled and teleopPeriodic() gets called every 20 ms for you (so avoid loops that don't exit quickly and do not use Timer.delay() to pause your code). Also, the 20 ms is just a great approximation...the loop timing is reallllly close to every 20 ms (certainly close enough for what we're doing).

If you do switch back to SampleRobot, then you will need the loops and the calls to Timer.delay().

Keep plugging away at it and keep asking questions. ChiefDelphi is full of people that want to help
Sweet maybe after the build season I will explore the Iterative robot but I would like to try and keep it basic this year seeing as I am new to this whole thing.
Reply With Quote
  #90   Spotlight this post!  
Unread 24-01-2015, 01:49
Fauge7 Fauge7 is offline
Head programmer
FRC #3019 (firebird robotics)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Scottsdale
Posts: 195
Fauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to allFauge7 is a name known to all
Re: Autonomous Help

Quote:
Originally Posted by curtis0gj View Post
Sweet maybe after the build season I will explore the Iterative robot but I would like to try and keep it basic this year seeing as I am new to this whole thing.
Honestly your better off with the command based structure, its easier to manage, more people use it, and its logically broken out into easier to find places. Need a constant? RobotMap...Need a joystick? OI, need a command for autonomous? Autonomous command Group, need a motor? SubsystemA...if you need help with it I am willing to Skype you and mentor you through converting it from a sample Robot to a command based robot. Send me a pm! This applies to anybody having trouble with any of the templates!
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 12:59.

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