Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   General Forum (http://www.chiefdelphi.com/forums/forumdisplay.php?f=16)
-   -   Left and Right Inverted on Joystick (http://www.chiefdelphi.com/forums/showthread.php?t=154714)

riptide321 04-02-2017 11:56

Left and Right Inverted on Joystick
 
Here is the code:
Code:


package org.usfirst.frc.team4404.robot;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Spark;
import edu.wpi.first.wpilibj.Timer;


/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the IterativeRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class Robot extends IterativeRobot {
        Joystick mainStick;
        Timer timer = new Timer();
        RobotDrive drive;
        Solenoid gearDropper = new Solenoid(1);
        Spark rightMotor1;
        Spark rightMotor2;
        Spark leftMotor1;
        Spark leftMotor2;
       



        /**
        * This function is run when the robot is first started up and should be
        * used for any initialization code.
        */
        @Override
        public void robotInit() {
                rightMotor1 = new Spark(0);
                rightMotor2 = new Spark(1);
                leftMotor1 = new Spark(2);
                leftMotor2 = new Spark(3);
               
                drive = new RobotDrive(leftMotor2, leftMotor1, rightMotor2, rightMotor1);
                //drive.setInvertedMotor(RobotDrive.MotorType.kFrontLeft, true);
                //drive.setInvertedMotor(RobotDrive.MotorType.kRearLeft, true);
               
               
               
                       
                mainStick = new Joystick(0);
               
               
               
               
               
        }

        /**
        * This autonomous (along with the chooser code above) shows how to select
        * between different autonomous modes using the dashboard. The sendable
        * chooser code works with the Java SmartDashboard. If you prefer the
        * LabVIEW Dashboard, remove all of the chooser code and uncomment the
        * getString line to get the auto name from the text box below the Gyro
        *
        * You can add additional auto modes by adding additional comparisons to the
        * switch structure below with additional strings. If using the
        * SendableChooser make sure to add them to the chooser code above as well.
        */
        @Override
        public void autonomousInit() {
                timer.reset();
                timer.start();
        }

        /**
        * This function is called periodically during autonomous
        */
        @Override
        public void autonomousPeriodic() {
               
        }

        /**
        * This function is called periodically during operator control
        */
        @Override
        public void teleopPeriodic()
        {
                drive.arcadeDrive(mainStick);
                boolean buttonValue, isOpen;
                isOpen = false;
                buttonValue = mainStick.getTrigger();
               
                if(buttonValue)
                {
                        if(!isOpen)
                        {
                                gearDropper.set(true);
                        }
                        else
                        {
                                gearDropper.set(false);
                        }
                       
                        isOpen = !isOpen;
                       
                }
               
        }

        /**
        * This function is called periodically during test mode
        */
        @Override
        public void testPeriodic() {
        }
}


What is causing the joystick and the robot from moving in opposite directions in the y-direction but not while going forwards and backwards?

T8PineappleSam 04-02-2017 12:01

Re: Left and Right Inverted on Joystick
 
It is possible that the left and right ports for your speed controllers are mixed up. When you go forward and backwards (giving both sides the same input) this isn't apparent, but when you try to turn (giving one side more input than the other) the robot turns the opposite direction. I would recommend switching the left and right side ports and seeing if that fixes the problem.

GeeTwo 04-02-2017 21:37

Re: Left and Right Inverted on Joystick
 
Quote:

Originally Posted by T8PineappleSam (Post 1640298)
It is possible that the left and right ports for your speed controllers are mixed up. When you go forward and backwards (giving both sides the same input) this isn't apparent, but when you try to turn (giving one side more input than the other) the robot turns the opposite direction. I would recommend switching the left and right side ports and seeing if that fixes the problem.

+1: swapping left and right is so easy to do, and is so difficult to puzzle your way out of.


All times are GMT -5. The time now is 00:58.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi