Go to Post What language does your programming mentor have the most experience with? That's the language you should use. - Rosiebotboss [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
  #31   Spotlight this post!  
Unread 22-01-2015, 10:23
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 Ether View Post
The E4P-250-250-N-S-D-D-B has single-ended outputs, and according to the datasheet you should get a square wave on each of the 2 output signal channels (A & B).

As you manually rotate the encoder shaft (very very slowly), you should see the voltage going from ~5V to ~0.4V on each channel.


Alright I will give this a shot I'm not the best with electrical stuff but this sounds doable.
Reply With Quote
  #32   Spotlight this post!  
Unread 22-01-2015, 16:23
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

Okay we testing out the encoder with our multimeter the volts seem good we got .4 to 5v however I am still not getting a number on my smartdash and I am not stopping. Here's the whole program.

Code:
package org.usfirst.frc.team5033.robot;

import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.Gyro;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.CounterBase.EncodingType;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

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 encoder = new Encoder(0, 1, false, EncodingType.k4X);
       
         
         encoder.setDistancePerPulse(0.001);
       
         encoder.getDistance();
         

    }

   
    public void autonomousPeriodic() {

    	gyro1.reset();
		
    	while(isAutonomous() && isEnabled())  {
    		
    		double angle = gyro1.getAngle();
    		double distance = encoder.getDistance();
    		
    		SmartDashboard.putNumber("Angle", angle);
    		SmartDashboard.putNumber("Distance", distance);
    		
    		robot.drive(-0.25, 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.getDistance();
						
						SmartDashboard.putNumber("Distance", distance2);
						
						robot.drive(-0.20, -angle2 * Kp); 
					
						if(encoder.getDistance() < 10)  {
							robot.drive(0,0); 
							
							break;
						}
						Timer.delay(0.1);	
				}
				
    			}
    

    public void teleopPeriodic() {
    	
    	while (isOperatorControl() && isEnabled()) {
        	
	     	
        	SmartDashboard.putNumber("angle", gyro1.getAngle());
        	
        	stick.getThrottle();
            robot.arcadeDrive(stick.getY(), -stick.getX(), false);
            
            Timer.delay(0.1);
    	}
        
    }
    
    
    public void testPeriodic() {
    
    }
    
}
Reply With Quote
  #33   Spotlight this post!  
Unread 22-01-2015, 17:25
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
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,729
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 we testing out the encoder with our multimeter the volts seem good we got .4 to 5v however I am still not getting a number on my smartdash and I am not stopping. Here's the whole program.

Code:
package org.usfirst.frc.team5033.robot;

import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.Gyro;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.CounterBase.EncodingType;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

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 encoder = new Encoder(0, 1, false, EncodingType.k4X);
       
         
         encoder.setDistancePerPulse(0.001);
       
         encoder.getDistance();
         

    }

   
    public void autonomousPeriodic() {

    	gyro1.reset();
		
    	while(isAutonomous() && isEnabled())  {
    		
    		double angle = gyro1.getAngle();
    		double distance = encoder.getDistance();
    		
    		SmartDashboard.putNumber("Angle", angle);
    		SmartDashboard.putNumber("Distance", distance);
    		
    		robot.drive(-0.25, 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.getDistance();
						
						SmartDashboard.putNumber("Distance", distance2);
						
						robot.drive(-0.20, -angle2 * Kp); 
					
						if(encoder.getDistance() < 10)  {
							robot.drive(0,0); 
							
							break;
						}
						Timer.delay(0.1);	
				}
				
    			}
    

    public void teleopPeriodic() {
    	
    	while (isOperatorControl() && isEnabled()) {
        	
	     	
        	SmartDashboard.putNumber("angle", gyro1.getAngle());
        	
        	stick.getThrottle();
            robot.arcadeDrive(stick.getY(), -stick.getX(), false);
            
            Timer.delay(0.1);
    	}
        
    }
    
    
    public void testPeriodic() {
    
    }
    
}
Try setting the distance per pulse to 1.
Reply With Quote
  #34   Spotlight this post!  
Unread 22-01-2015, 17:57
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
Try setting the distance per pulse to 1.
I can try this tomorrow but do I need to maybe setup the dash board to display the distance or will it just appear?
Reply With Quote
  #35   Spotlight this post!  
Unread 22-01-2015, 18:01
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
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,729
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
I can try this tomorrow but do I need to maybe setup the dash board to display the distance or will it just appear?
It will just appear. You are bringing up the java dashboard not the default one right?
Reply With Quote
  #36   Spotlight this post!  
Unread 22-01-2015, 18:08
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
It will just appear. You are bringing up the java dashboard not the default one right?
Yeah what I do is switch my ds setting from remote to java and this opens my smart dashboard that I have setup with a camera and the angle reading.
Reply With Quote
  #37   Spotlight this post!  
Unread 23-01-2015, 09:44
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 curtis0gj View Post
Yeah what I do is switch my ds setting from remote to java and this opens my smart dashboard that I have setup with a camera and the angle reading.
Is there a better way to open smart dashboard for java?
Reply With Quote
  #38   Spotlight this post!  
Unread 23-01-2015, 09:47
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
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,729
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
Is there a better way to open smart dashboard for java?
That's the way we do it too. There a way to set the default to be the SmartDashboard, but I'd have to look into how to do that again.
Reply With Quote
  #39   Spotlight this post!  
Unread 23-01-2015, 09:49
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
That's the way we do it too. There a way to set the default to be the SmartDashboard, but I'd have to look into how to do that again.
So setting the pulse to 1 does not work is there anything else I can try?

Last edited by curtis0gj : 23-01-2015 at 09:51.
Reply With Quote
  #40   Spotlight this post!  
Unread 23-01-2015, 09:54
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
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,729
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
So setting the pulse to 1 does not work is there anything else I can try?
Try doing encoder.start() in robotInit() after you declare the encoder. This method used to exist in last year's API but I don't see it in the documentation right now.
Reply With Quote
  #41   Spotlight this post!  
Unread 23-01-2015, 09:57
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
Try doing encoder.start() in robotInit() after you declare the encoder. This method used to exist in last year's API but I don't see it in the documentation right now.
Yeah I have been encoder
start(); but it just gave me errors I guess there's no such thing this year.
Reply With Quote
  #42   Spotlight this post!  
Unread 23-01-2015, 09:59
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
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,729
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
Yeah I have been encoder
start(); but it just gave me errors I guess there's no such thing this year.
Can you try changing your getDistance() to just get().
Reply With Quote
  #43   Spotlight this post!  
Unread 23-01-2015, 10:01
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
Can you try changing your getDistance() to just get().
In the init?
Reply With Quote
  #44   Spotlight this post!  
Unread 23-01-2015, 10:03
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
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,729
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

Code:
double distance2 = encoder.get();
Reply With Quote
  #45   Spotlight this post!  
Unread 23-01-2015, 10:07
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
Code:
double distance2 = encoder.get();
How about double distance = encoder.get(); as well?
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 13:16.

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