Go to Post Now Dave, before you get all snarly about these- remember, I still have the button maker... - MissInformation [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
  #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: 22
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
  #2   Spotlight this post!  
Unread 03-02-2016, 18:11
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 236
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Re: Code does not work, and there seems to be 0 issues.

Which part? Also, why do you have a Robot constructor? You don't need that
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP

Last edited by TimTheGreat : 03-02-2016 at 18:13.
Reply With Quote
  #3   Spotlight this post!  
Unread 03-02-2016, 18:18
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: 22
Lesafian is an unknown quantity at this point
Re: Code does not work, and there seems to be 0 issues.

Nothing works, and what do you mean?
Reply With Quote
  #4   Spotlight this post!  
Unread 03-02-2016, 18:36
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 236
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Re: Code does not work, and there seems to be 0 issues.

Quote:
Originally Posted by Lesafian View Post
Nothing works, and what do you mean?
So you have public Robot(). You don't need this method. Just put it all in robotInit
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP
Reply With Quote
  #5   Spotlight this post!  
Unread 03-02-2016, 20:14
c0d3rman's Avatar
c0d3rman c0d3rman is offline
Programming Captain
AKA: Yoni Lerner
FRC #4904 (Bot Provoking)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2014
Location: California
Posts: 10
c0d3rman is an unknown quantity at this point
Re: Code does not work, and there seems to be 0 issues.

When you say "nothing works", what exactly do you mean? What is happening when you enable?
Reply With Quote
  #6   Spotlight this post!  
Unread 03-02-2016, 20:45
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: 22
Lesafian is an unknown quantity at this point
Re: Code does not work, and there seems to be 0 issues.

The drive motors do not turn, the arm motor does not turn, the slide motor does not turn. The compressor works though.
Reply With Quote
  #7   Spotlight this post!  
Unread 03-02-2016, 20:52
dvanvoorst dvanvoorst is offline
Registered User
FRC #2771 (Code Red)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Grand Rapids, MI
Posts: 61
dvanvoorst is an unknown quantity at this point
Re: Code does not work, and there seems to be 0 issues.

Maybe your joystick isn't working?
Have you had the code working before? If so, what changes have been made?
Reply With Quote
  #8   Spotlight this post!  
Unread 03-02-2016, 21:04
JacobD's Avatar
JacobD JacobD is offline
Registered User
AKA: Jacob
FRC #1672 (Mahwah Robo T-Birds)
Team Role: Leadership
 
Join Date: Jan 2015
Rookie Year: 2013
Location: New Jersey
Posts: 91
JacobD is an unknown quantity at this point
Re: Code does not work, and there seems to be 0 issues.

If there are 0 errors, be sure that you have the rioLog open in eclipse (open from the view menu). Also, assuming that you do not have any errors, have you used this roboRio successfully before now? Have you performed any recent updates? Have you installed Java on the rio?
__________________
2013-2014: Electrical, Mechanical
2014-2017: Team Captain
Reply With Quote
  #9   Spotlight this post!  
Unread 03-02-2016, 22:57
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: 22
Lesafian is an unknown quantity at this point
Re: Code does not work, and there seems to be 0 issues.

Yes, it has worked successfully. No I have not updated anything. No, there are 0 Rio log errors. Yes Ive installed java on it.
Reply With Quote
  #10   Spotlight this post!  
Unread 04-02-2016, 08:25
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 103
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: Code does not work, and there seems to be 0 issues.

Try adding some diagnostic tools to your code.

For example at the end of your constructor, try adding the following two lines:

Code:
LiveWindow.addActuator("Drive", "Left Motor", drivemotor1);
LiveWindow.addActuator("Drive", "Right Motor", drivemotor2);
If you deploy the code and put your Driver Station in "Test" mode, you should see two sliders appear on your SmartDashboard related to your drive motors. You should be able to adjust the sliders and see the motors turn.

You can also add "debug output" that appears during normal operation. Try adding the following field (lastDashboardUpdate) and method to your Robot class:

Code:
        // time stamp of last time we sent values to dash board	
	private double lastDashboardUpdate = 0;
	
	private void updateDashboard() {
		double now = Timer.getFPGATimestamp();
		
		// Diagnostic updates about 10 times a second
		if ((now - lastDashboardUpdate) > 0.1) {
			lastDashboardUpdate = now;
			
                        // Diagnostic information about the state of the robot
			SmartDashboard.putNumber("Left Stick", xboxController.getRawAxis(2));
			SmartDashboard.putNumber("Right Stick", xboxController.getRawAxis(5));
			SmartDashboard.putNumber("Left Drive Power", drivemotor1.get());
			SmartDashboard.putNumber("Right Drive Power", drivemotor2.get());
		}
	}
Then, inside the while() loop in your operatorControl() method, call the new updateDashboard() method.

Deploy the code and start the driver station in Teleop mode. You should see values update on your smart dashboard corresponding to the inputs on your game pad and the output power of your drive motors. If you see zero values on your joysticks even when you are moving them, check the driver station console and make certain that your gamepad has not been re-mapped to a different port.

After you get things working on the drive, you can comment out the debug output in the updateDashboard() method and use this approach to troubleshoot the rest of your components.
Reply With Quote
  #11   Spotlight this post!  
Unread 04-02-2016, 08:52
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: Code does not work, and there seems to be 0 issues.

Quote:
Originally Posted by Lesafian View Post
Code does not work, and there seems to be 0 issues.
First, as someone who does software for a living, I would be an extremely rich person if I had $0.05 for every time I've heard (or said) those words.


Second, your location says Posen. Is that as in Posen, MI? That would be pretty cool because I'm from that general area.


Anyway, sorry to sidetrack the coversation.
__________________
-
An ounce of perception is worth a pound of obscure.
Reply With Quote
  #12   Spotlight this post!  
Unread 04-02-2016, 18:13
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: 22
Lesafian is an unknown quantity at this point
Re: Code does not work, and there seems to be 0 issues.

Posen, MI.
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 01:51.

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