Go to Post sigh, I started wondering why we weren't there than I realized it was in California. Thats a bit of a road trip... - Raumiester2010 [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 29-01-2017, 23:02
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: 38
Lesafian is an unknown quantity at this point
ADXRS450 Straight Drive Not Working

My team is using mecanum wheels this year, and we've found that it's very hard to drive in a straight line. Along with that, it is impossible to drive straight in auton. We decided to use the gyroscope that comes with the kit of parts (ADXRS450). I've used the code in the screensteps, and it does not work whatsoever. I'm unable to set the sensitivity for the gyro, but I assume it's because there is no need since the class is specifically for that gyroscope.

Here is the code.

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


import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.ADXRS450_Gyro;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.VictorSP;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;


public class Robot extends SampleRobot {
    RobotDrive drive;
    VictorSP leftFront, leftBack, rightFront, rightBack;
    ADXRS450_Gyro gyro;
    double kP = 0.03;

    public Robot() {
    	leftFront = new VictorSP(0);
    	leftBack = new VictorSP(1);
    	rightFront = new VictorSP(2);
    	rightBack = new VictorSP(3);
        drive = new RobotDrive(leftFront, leftBack, rightFront, rightBack);
        gyro = new ADXRS450_Gyro();
        gyro.calibrate();
    }

    public void autonomous() {
    	gyro.reset();
    	while (isAutonomous() && isEnabled()) {
    		SmartDashboard.putNumber("Gyro Angle", gyro.getAngle());
    		//X and Y are switched because of inversion
    		drive.mecanumDrive_Cartesian(-0.5, 0, -gyro.getAngle()*kP, 0);
    	}
    }

The only noticeable effect of the gyroscope is that when kP is above 0.005 the robot spins at full speed in a circle.

Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 29-01-2017, 23:40
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,770
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: ADXRS450 Straight Drive Not Working

We did mecanum code back in 2014, so I am not familiar with using it on the new gyro. However, unless you get better advice, the first thing I would try would be to remove the negative from the gyro input to mecanumDrive_Cartesian(). If your gyro input is of the incorrect sign (or moves rapidly in one direction independently of what is going on), this will cause a high-speed spin as the drive pushes farther and faster away from the desired set point.

Do you have trouble driving straight manually? When we implemented this in 2014 with 6 inch wheels, drivers were able to quickly adapt even to our prototype robot, which had about 6x as much weight on the right rear wheel as on the front left. (That prototype is the only team robot I drove for more than an hour, and it took me less than a minute to compensate for the pull.) If straight driving is difficult for people, you probably have some significant physical problem, whether swapped gearboxes or a gearbox which is not rotating freely. Having some of the roller bolts so tight so that they do not rotate freely might also cause this issue.
__________________

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.
Reply With Quote
  #3   Spotlight this post!  
Unread 30-01-2017, 09:07
tatzoid tatzoid is offline
Registered User
FRC #4573
 
Join Date: Jan 2017
Location: South River, NJ
Posts: 2
tatzoid is an unknown quantity at this point
Re: ADXRS450 Straight Drive Not Working

I think you are using the gyro the wrong way for the cartesian form:

mecanumDrive_Cartesian(x speed, y speed, rotation rate, gyro angle)
Use gyro for "field oriented driving"
see: https://wpilib.screenstepslive.com/s...-mecanum-drive

The polar form may be more appropriate here:
mecanumDrive_Polar(driveSpeed, angle, rotation rate)

Use the Gyro for the angle: use -gyro.getAngle() to go straight (0 degrees) and use zero for rotation rate.
Reply With Quote
Reply


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:19.

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