Go to Post [You know you're proud to be a FIRSTer when...] You explain to someone how do do something, they go off and do it, come back and ask, "is this right?" and you say, "Yes." . - NorviewsVeteran [more]
Home
Go Back   Chief Delphi > Technical > Programming
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 10-02-2016, 16:53
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: 24
Lesafian is an unknown quantity at this point
Forward and Reverse is normal yet Left and Right turning is inverted

Hi,

our team is having issues with our drive having inverted turning.

We're using 4 drive motors, all with VictorSP's. We've also confirmed that they're in ordered ports. the 2 motors on the left are in ports 0, and 1, and the two motors on the right are in ports 2, and 2.

Here's our code.
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.Timer;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.VictorSP;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.CameraServer;
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 {

    // Declarations
	RobotDrive drive;
	
	CameraServer camserver;
	
	Compressor compressor;
	
	DoubleSolenoid ds;
	//Solenoid s;

	Joystick xboxController;

	TalonSRX slideMotor;
	
	Victor armMotor;
	
	VictorSP drivemotor1;
	VictorSP drivemotor2;
	VictorSP drivemotor3;
	VictorSP drivemotor4;
	

	// 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 VictorSP(0);
		drivemotor2 = new VictorSP(1);
		drivemotor3 = new VictorSP(2);
		drivemotor4 = new VictorSP(3);
		
		compressor = new Compressor(0);
		
		drive = new RobotDrive(drivemotor1, drivemotor2, drivemotor3, drivemotor4);
		drive.setExpiration(0.1);
		
		xboxController = new Joystick(0);
		
		armMotor = new Victor(5);
		slideMotor = new TalonSRX(4);

		ds = new DoubleSolenoid(0, 1);
		//s = new Solenoid(2);

		chooser = new SendableChooser();
		
		camserver = CameraServer.getInstance();
		camserver.setQuality(50);
		camserver.startAutomaticCapture("cam0");

	}

	public void robotInit() {
		compressor.setClosedLoopControl(true);
		chooser.addDefault("Default Autonomous", 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() {
		drive.setSafetyEnabled(false);
		String autoSelected = (String) chooser.getSelected();
		System.out.println("Autonomous Mode selected: " + autoSelected);

		switch (autoSelected) {

		case customAuto5:
			 /*Only use if have to
			 * Goal: Go through the portcullis & pick up a ball
			 * Note: Values might change as testing is done
			 */
			
			//Drive forwards while lowering arms to default
			drive.drive(1, 0);
			armMotor.set(-0.5);
			Timer.delay(1);
			
			armMotor.set(1);
			Timer.delay(1);
			drive.drive(1, 0);
			Timer.delay(2);
			
			drive.drive(0.5, 1);
			ds.set(DoubleSolenoid.Value.kForward);
			Timer.delay(1);
			ds.set(DoubleSolenoid.Value.kOff);			
		
			break;
		case customAuto4:
			/*Hallway autonomous test
			 * Goal: Drive forwards, turn around, come back
			 */
			drive.drive(-0.25, 0);
			Timer.delay(3);
			drive.drive(0.50, 1);
			Timer.delay(1.75);
			drive.drive(-0.1, 0);
			
			break;
		case customAuto3:
			break;
		case customAuto2:
			break;
		case customAuto:
			break;
		case defaultAuto:
		default:
			/*Preferred w/ preferred spawn point
			Goal: Go through the low bar and pick up a ball. */
			
			//Drive forwards
			drive.drive(1, 0);
			Timer.delay(1);
			
			//Turn to low bar
			drive.drive(0, 0.5);
			Timer.delay(1);
			
			//Drive through low bar and approach ball in center
			drive.drive(1, 0.25);
			Timer.delay(2);
			
			//Pick up the ball
			ds.set(DoubleSolenoid.Value.kForward);
			Timer.delay(1);
			ds.set(DoubleSolenoid.Value.kOff);
			break;
		}
		Scheduler.getInstance().run();
	}

	public void operatorControl() {
		drive.setSafetyEnabled(true);
		while (isOperatorControl() && isEnabled()) {
			
			compressor.start();
			// Move robot using left and right joystick
			//drive.tankDrive(xboxController.getRawAxis(1), xboxController.getRawAxis(5));
			drive.arcadeDrive(xboxController);

			// 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);
			}
			
			//Wait for motor update times
			Timer.delay(0.005);
			
			// Move sliding mechanism forwards and backwardss
			
			if (Math.abs(xboxController.getRawAxis(5)) > .1) {
     
				slideMotor.set(xboxController.getRawAxis(5));
				
			} else {
				
				slideMotor.set(0);
            }
			
			//Wait for motor update times
			Timer.delay(0.005);

			// Open and close the claw
			if (xboxController.getRawButton(2)) {
				
				ds.set(DoubleSolenoid.Value.kForward);
				
			} else if (xboxController.getRawButton(1)) {
				
				ds.set(DoubleSolenoid.Value.kReverse);
			}
			
			//Wait for motor update times.
			Timer.delay(0.005);
		}
	}

	public void test() {
	}
}
Thanks!
 


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 20:02.

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