Go to Post Thank you FIRST -- thank you, thank you, thank you -- I can't say that enough. We can't say that enough.... Its too bad that more of us don't try. - Aidan F. Browne [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 03-02-2016, 17:55
Lesafian Lesafian is offline
Registered User
AKA: Jeremy Styma
FRC #6077 (Wiking Kujon)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2016
Location: Posen, Michigan
Posts: 20
Lesafian is an unknown quantity at this point
Angry Code does not work, and there seems to be 0 issues.

I've written code for our robot, but it is not working. There are 0 errors in Eclipse, and 0 errors in the driver station. I'm not sure if it's an issue with the code or with our electric wiring. Here is the code, please let me know if there's anything wrong.

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

import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.TalonSRX;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class Robot extends SampleRobot {

        // RobotDrive Declaration
	RobotDrive drive;
	
	// Compressor Declaration
	Compressor compressor;
	
	// Solenoid Declaration
	DoubleSolenoid doublesolenoid;
	Solenoid solenoid;

	// Joystick Declaration
	Joystick xboxController;

	// Motor Controller Declaration
	TalonSRX armMotor;
	TalonSRX slideMotor;
	
	Victor drivemotor1;
	Victor drivemotor2;

	// Autonomous Names
	final String defaultAuto = "Default";
	final String customAuto = "Autonomous Choice 1";
	final String customAuto2 = "Autonomous Choice 2";
	final String customAuto3 = "Autonomous Choice 3";
	final String customAuto4 = "Autonomous Choice 4";
	final String customAuto5 = "Autonomous Choice 5";

	// Chooser
	SendableChooser chooser;

	public Robot() {
		
		//Change values later
		drivemotor1 = new Victor(0);
		drivemotor2 = new Victor(2);
		
		compressor = new Compressor(0);
		
		drive = new RobotDrive(drivemotor1, drivemotor2);
		drive.setExpiration(0.1);
		
		xboxController = new Joystick(0);
		
		armMotor = new TalonSRX(5);
		slideMotor = new TalonSRX(4);

		doublesolenoid = new DoubleSolenoid(0, 1);
		solenoid = new Solenoid(2);

		chooser = new SendableChooser();

	}

	public void robotInit() {
		compressor.setClosedLoopControl(true);
		chooser.addDefault("Default Auto", defaultAuto);
		chooser.addObject("Autonomous Choice 1", customAuto);
		chooser.addObject("Autonomous Choice 2", customAuto2);
		chooser.addObject("Autonomous Choice 3", customAuto3);
		chooser.addObject("Autonomous Choice 4", customAuto4);
		chooser.addObject("Autonomous Choice 5", customAuto5);
		SmartDashboard.putData("Autonomous Chooser", chooser);
	}

	public void autonomous() {
		compressor.getPressureSwitchValue();
		drive.setSafetyEnabled(false);
		String autoSelected = (String) chooser.getSelected();
		System.out.println("Autonomous Mode selected: " + autoSelected);

		switch (autoSelected) {

		case customAuto5:
			break;
		case customAuto4:
			break;
		case customAuto3:
			break;
		case customAuto2:
			break;
		case customAuto:
			break;
		case defaultAuto:
		default:
			break;
		}
		Scheduler.getInstance().run();
	}

	public void operatorControl() {
		compressor.getPressureSwitchValue();
		drive.setSafetyEnabled(true);
		while (isOperatorControl() && isEnabled()) {

			// Move robot using left and right joystick
			drive.tankDrive(xboxController.getRawAxis(2), xboxController.getRawAxis(5));

			// Lift and lower the arms using the right and left bumper.

			if (xboxController.getRawButton(5)) {
				armMotor.set(1);

			} else if (xboxController.getRawButton(4)) {
				armMotor.set(-1);
			}
			else {
				armMotor.set(0);
			}

			// Move sliding mechanism forwards and backwardss
			
			if (Math.abs(xboxController.getRawAxis(5)) > .1) {
     
				slideMotor.set(xboxController.getRawAxis(5));
			} 
			else {
				slideMotor.set(0);
                        }

			// Open and close the claw
			
			if (xboxController.getRawButton(2)) {
				doublesolenoid.set(DoubleSolenoid.Value.kForward);
			}
			else if (xboxController.getRawButton(1)) {
				doublesolenoid.set(DoubleSolenoid.Value.kReverse);
			}
		}
	}

	public void test() {
	}
}

Last edited by Lesafian : 03-02-2016 at 17:58.
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 04: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