Go to Post According to Merriam-Webster the definition of lurker is an FRC Q&A person. - marshall [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 28-01-2017, 16:44
CocoGuo CocoGuo is offline
Registered User
FRC #3345 (Yellow Jacket 3345)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2015
Location: San Antonio
Posts: 3
CocoGuo is an unknown quantity at this point
Error with joystick controller and driver station

I am the programmer from team Yellow Jacket 3345, the driver station is giving me error about the joysticks are not plug in,but ti is plug in right and all show green but we all check the program is no error.And we don't know the problems.

https://www.dropbox.com/s/5bczzz5frj...nshot.png?dl=1

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

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Spark;
import edu.wpi.first.wpilibj.Talon;

public class Robot extends IterativeRobot {
	final String defaultAuto = "Default";
	final String customAuto = "My Auto";
	String autoSelected;
	SendableChooser<String> chooser = new SendableChooser<>();
	private RobotDrive robotDrive1, robotDrive2;
	private Joystick leftJoystick, rightJoystick;
	private Spark gearMotor;
	private Talon fuelGate, scissorLift;
	private double driveBaseSpeed = 1.0;
	private double scissorLiftSpeed = 1.0;
	private double fuelGateSpeed = 1.0;
	private double gearMotorSpeed = 1.0;

	@Override
	public void robotInit() {
		chooser.addDefault("Default Auto", defaultAuto);
		chooser.addObject("My Auto", customAuto);
		SmartDashboard.putData("Auto choices", chooser);
		//spark and function part
		robotDrive1 = new RobotDrive(1, 2);
		robotDrive2 = new RobotDrive(3, 4);
		fuelGate = new Talon(5);
		scissorLift = new Talon(6);
		gearMotor = new Spark(0);
		leftJoystick = new Joystick(1);
		rightJoystick = new Joystick(2);
	}

	@Override
	public void autonomousInit() {
		autoSelected = chooser.getSelected();
		// autoSelected = SmartDashboard.getString("Auto Selector",
		// defaultAuto);
		System.out.println("Auto selected: " + autoSelected);
	}

	@Override
	public void autonomousPeriodic() {
		switch (autoSelected) {
		case customAuto:
			// Put custom auto code here
			break;
		case defaultAuto:
		default:
			// Put default auto code here
			robotDrive1.arcadeDrive(0.5, 0.0);
			robotDrive2.arcadeDrive(0.5, 0.0);
			gearMotor.set(0.5);
			fuelGate.set(0.5);
			scissorLift.set(0.5);
			break;
		}
	}

	@Override
	public void teleopPeriodic() {
		while(true) {
			robotDrive1.arcadeDrive(leftJoystick.getY()*driveBaseSpeed, rightJoystick.getX());
			robotDrive2.arcadeDrive(leftJoystick.getY()*driveBaseSpeed, rightJoystick.getX());
			gearMotor.set(rightJoystick.getY()*gearMotorSpeed);
			
			if(rightJoystick.getRawButton(4)) {
				fuelGate.set(1.0*fuelGateSpeed);
			} else if(rightJoystick.getRawButton(5)) {
				fuelGate.set(-1*fuelGateSpeed);
			} else {
				fuelGate.set(0);
			}
			
			if(rightJoystick.getRawButton(6)) {
				scissorLift.set(1.0*scissorLiftSpeed);
			} else if(rightJoystick.getRawButton(7)) {
				scissorLift.set(-1*scissorLiftSpeed);
			} else {
				scissorLift.set(0);
			}
		}
	}

	@Override
	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 09:50.

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