Go to Post The biggest fallacy in FIRST is the belief we are just a bunch of different teams. We are ONE BIG TEAM with a lot of sub teams for the purpose of competition. - Al Skierkiewicz [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #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: 22
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!
  #2   Spotlight this post!  
Unread 10-02-2016, 17:06
eedoga's Avatar
eedoga eedoga is offline
Registered User
FRC #2980
 
Join Date: Jan 2011
Location: Oak Harbot
Posts: 218
eedoga has much to be proud ofeedoga has much to be proud ofeedoga has much to be proud ofeedoga has much to be proud ofeedoga has much to be proud ofeedoga has much to be proud ofeedoga has much to be proud ofeedoga has much to be proud of
Re: Forward and Reverse is normal yet Left and Right turning is inverted

plug your left motor ESCs pwm into your right motor spot and your right motor ESCs pwm into your left motor spot. Basically switch the sides that the motors are on and everything should be better...

Best of luck!

Edoga
  #3   Spotlight this post!  
Unread 10-02-2016, 17:12
nickbrickmaster's Avatar
nickbrickmaster nickbrickmaster is offline
Not Allowed Near Power Tools
AKA: Nick Schatz
FRC #3184 (Blaze Robotics)
Team Role: Leadership
 
Join Date: Jan 2015
Rookie Year: 2014
Location: Eagan MN
Posts: 159
nickbrickmaster is an unknown quantity at this point
Re: Forward and Reverse is normal yet Left and Right turning is inverted

You could either switch your PWM sides either in code or electronically, or you can negate all the turn values in your code. Either way.
__________________
I have approximate knowledge of many things.

FRC 3184: 2014-, FTC 10648: 2015-
  #4   Spotlight this post!  
Unread 10-02-2016, 17:28
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,610
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Forward and Reverse is normal yet Left and Right turning is inverted

Both.
If you just invert all the motor speeds, left and right will still be inverted, but forward and reverse will become inverted.

If you just swap left and right, left and right will remain inverted, and forward and reverse will become inverted.

Do both - invert all the motors from their current direction, and swap the left and right sides to fix it all at the same time.

Edit: I'm surprised that you have forward and reverse being forward and reverse, not spinning, without any inverted motors. Did you invert the motors on one side in wiring?
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.

Last edited by GeeTwo : 10-02-2016 at 17:31.
  #5   Spotlight this post!  
Unread 10-02-2016, 19:10
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Forward and Reverse is normal yet Left and Right turning is inverted

Seems easier to just change

Code:
drive.arcadeDrive(xboxController);
to

Code:
drive.arcadeDrive(xboxController.getRawAxis(1), -xboxController.getRawAxis(0));
__________________
FRC Team 1684 - Head Programmer (2013-2016)
FRC Team 5460 - Programming Mentor (2015-2016)

FIRST in Michigan - Technical Crew (2015-continuing)
  #6   Spotlight this post!  
Unread 10-02-2016, 20:20
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Forward and Reverse is normal yet Left and Right turning is inverted

Quote:
Originally Posted by Lesafian View Post
...and the two motors on the right are in ports 2, and 2.
There's your problem right there


Closed Thread


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 00:38.

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