Go to Post I've found that being outraged on behalf of others is often a misuse of energy. - Taylor [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 Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 02-15-2015, 08:53 PM
Tweety Tweety is offline
Registered User
AKA: Amzad Chowdhury
no team
Team Role: Mentor
 
Join Date: Nov 2013
Rookie Year: 2009
Location: New York City
Posts: 3
Tweety is an unknown quantity at this point
Strafing Problem

Hi all,
I'm having issues with the mecanum drive code. Problem is that strafing doesn't work. Robot can turn fine and go forward/back. I referred to how the wheels should be moving when it's strafing and it seems like they are just doing something else. Both sides are moving outwards so its just countering itself.

I read somewhere that I have to invert motors. How do I do it in java?


Code:
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Gyro;
import edu.wpi.first.wpilibj.CANTalon;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.networktables.NetworkTable;
import edu.wpi.first.wpilibj.networktables2.type.NumberArray;


public class Robot extends IterativeRobot {
    //LEFT STICK = AXIS  RIGHT STICK = ROTATION
    private Joystick leftJoystick = new Joystick(1);
    private Joystick rightJoystick = new Joystick(2);
    private CANTalon frontLeft = new CANTalon(1);
    private CANTalon rearLeft = new CANTalon(2);
    private CANTalon frontRight = new CANTalon(3);
    private CANTalon rearRight = new CANTalon(4);
    private RobotDrive mecDrive = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight);
    private Gyro gyroscope = new Gyro(1);
    
    //Pneumatics
    private Compressor compressor = new Compressor(1);
    private DoubleSolenoid Gripper = new DoubleSolenoid(1,2);
    
    //Nerd Stuff
    NetworkTable table;
    
   
    public void robotInit() {
        compressor.start();
        table = NetworkTable.getTable("");
    }
       
    public void autonomous() {
        
    }
    
    public void operatorControl() {
        double xValue = 0.0;
        double yValue = 0.0;
        double y = 0.0;
        double x = 0.0;
        double rotation = 0.0;
        double gyroAngle = 0.0;
        double throttle  = 0.0;
                
         while(isOperatorControl() && isEnabled()) {

             //EDC
             x = -leftJoystick.getX();
             y = -leftJoystick.getY();
             rotation = -rightJoystick.getX();
             
             throttle = leftJoystick.getThrottle();
             if (throttle < .5) {
            	 yValue = y * .5;
            	 xValue = x * .5;
             }

             gyroAngle = gyroscope.getAngle();
            
             mecDrive.mecanumDrive_Cartesian(xValue, yValue, rotation, gyroAngle);
                     
         }
    
    }
    
    public void test() {
    
    }
}
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 08:30 AM.

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