Go to Post We are reluctant to deprive you of the experience of learning how to do your own research. - Alan Anderson [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
  #3   Spotlight this post!  
Unread 01-10-2015, 17:30
xcountry413 xcountry413 is offline
Registered User
FRC #2022
 
Join Date: Oct 2015
Location: Aurora
Posts: 2
xcountry413 is an unknown quantity at this point
Re: Code Not Uploading to Bot

It's actually the constructor of the class. Here's the code:
Code:
package org.usfirst.frc.team2022.robot.subsystems;


import org.usfirst.frc.team2022.robot.RobotMap;
import org.usfirst.frc.team2022.robot.commands.TankDriveCommand;

import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.command.Subsystem;

/**
 *
 */
public class TankDriveSubsystem extends Subsystem {
	private final Talon frontLeft, frontRight, rearLeft, rearRight;
	private double leftSpeed, rightSpeed;
	private boolean inverted;
	private long lastTime;
	private Encoder encoder;

	public TankDriveSubsystem(){
		// SmartDashboard.putString("TankDrive", "SUBSYSTEM_INIT"); //Will
		// crash. TODO: fix?
            frontLeft = new Talon(RobotMap.leftMotorFront);
            frontRight = new Talon(RobotMap.rightMotorFront);
            rearLeft = new Talon(RobotMap.leftMotorBack);
            rearRight = new Talon(RobotMap.rightMotorBack);

            inverted = false;
            lastTime = System.currentTimeMillis();
		
//		encoder = new Encoder(RobotMap.encoder1, RobotMap.encoder2, false);
//		encoder.setDistancePerPulse(4.7);
//		encoder.setDistancePerPulse((6 * Math.PI) / 360); //No idea if this is right, diameter * pi / pulses per revolution. Change to correct measurements
//		
//		encoder.reset();
		
	}
	
	public double getEncoderDistance(){
		return encoder.getDistance();
	}
	
	public void resetEncoder(){
		encoder.reset();
	}

	@Override	
	// this is important for WPILib.
	public void initDefaultCommand() {
		setDefaultCommand(new TankDriveCommand());

	}

	// Speed Manipulation Methods-these are more fine grained
	public double getLeftSpeed() {
		return leftSpeed;
	}

	public double getRightSpeed() {
		return rightSpeed;
	}

	public void setLeftSpeed(double ls) {
		leftSpeed = ls;
		frontLeft.set(ls);
		rearLeft.set(ls);
	}

	public void setRightSpeed(double rs) {
		rightSpeed = rs;
		frontRight.set(rs);
		rearRight.set(rs);
	}

	// Inversion
	public boolean isInverted() {
		return inverted;
	}

	public void toggleInversion() {
		if (System.currentTimeMillis() > lastTime + 250) {
			lastTime = System.currentTimeMillis();
			inverted = !inverted;
			leftSpeed *= -1;
			rightSpeed *= -1;
		}
	}

	// Forwards and Reverse Control for each side.
	public void stop() {
		frontRight.set(0);
		frontLeft.set(0);
		rearRight.set(0);
		rearLeft.set(0);
		rightSpeed = 0;
		leftSpeed = 0;
	}
}
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: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