Go to Post but you can rest assured: I have restored the balance by letting the GDC know that I know that they know that you know they have a pattern. -Leav - Leav [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
  #1   Spotlight this post!  
Unread 04-02-2015, 19:39
dash121 dash121 is offline
Registered User
FRC #4085
 
Join Date: Oct 2014
Location: Reynoldsburg Ohio
Posts: 23
dash121 is an unknown quantity at this point
Smile CAN Talon Encoder

Hey I am a programmer on 4085 and we are having a ton of struggle with the new encoders. We have an encoder hooked up directly to the pins on our Talon SR's. We are currently getting position and I have spent 3 hours working on a dry board trying to get it to move forward for 4' and stop. Simple right? But there's a catch! There is no reset encoder position command. So we have no way of making it "zero" at the beginning of autonomous. Now you understand why I had 3 hours at the dry board. Our "get encoder position" command returns a number that doesn't start a "zero". Our "get velocity" command returns a largely changing number so we are calling it "dead" and bugged. We do have the breakout board plugged into the encoders before we plug them into the Talon. What are you guise using this year? We want to know that the pin out on the speed controllers don't work before we just rewire it back to the analog ports. Can you help?

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

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;

import org.usfirst.frc.team4085.robot.commands.ExampleCommand;
import org.usfirst.frc.team4085.robot.subsystems.ExampleSubsystem;

import edu.wpi.first.wpilibj.SpeedController;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.CANTalon;
import edu.wpi.first.wpilibj.smartdashboard.*;
import edu.wpi.first.wpilibj.Encoder;


 
public class Robot extends IterativeRobot {
	
	CANTalon ldrive = new CANTalon(5);
	CANTalon rdrive = new CANTalon(6);
	Joystick lstick = new Joystick(1);
	Joystick rstick = new Joystick(0);
	RobotDrive moving = new RobotDrive(ldrive, rdrive);
	SmartDashboard smart = new SmartDashboard();
	int d;
	int y;
	int z;
	int b;
	Encoder lenc1 = new Encoder(2);
	
	
	
	
	

	public static final ExampleSubsystem exampleSubsystem = new ExampleSubsystem();
	public static OI oi;
	 
	

    Command autonomousCommand;

    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public void robotInit() {
		oi = new OI();
        // instantiate the command used for the autonomous period
        autonomousCommand = new ExampleCommand();
    
    }
	
	public void disabledPeriodic() {
		Scheduler.getInstance().run();
			
	}

    public void autonomousInit() {
        // schedule the autonomous command (example)
        if (autonomousCommand != null) autonomousCommand.start();
    }

    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {
        Scheduler.getInstance().run();
    }

    public void teleopInit() {
		// This makes sure that the autonomous stops running when
        // teleop starts running. If you want the autonomous to 
        // continue until interrupted by another command, remove
        // this line or comment it out.
        if (autonomousCommand != null) autonomousCommand.cancel();
        
        
        
      
    }

    /**
     * This function is called when the disabled button is hit.
     * You can use it to reset subsystems before shutting down.
     */
    public void disabledInit(){

    }

    /**
     * This function is called periodically during operator control
     */
    public void teleopPeriodic() {
        Scheduler.getInstance().run();
        moving.tankDrive(rstick,lstick);
      //  moving1.tankDrive(rstick, lstick)
        
        
      
        smart.putString("ldrive Position", Integer.toString(ldrive.getEncPosition()));
        smart.putString("rdrive Position", Integer.toString(rdrive.getEncPosition()));
                
        smart.putString("ldrive Velocity", Integer.toString(ldrive.getEncVelocity()));
        smart.putString("rdrive Velocity", Integer.toString(rdrive.getEncVelocity()));
       
        

             
     
    }
 
    public void testPeriodic() {
    	
    }
}
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 22:30.

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