Go to Post Gotta love the blurred robots :cool: - Steven Donow [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 13-02-2015, 15:48
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
Straffing Issue

Okay so everything is working. Currently the left joyx on our XBox controller is straffing and the left joyy on the controller is forwards/backwards. The straffing is inverted - if I push the joystick left it goes right and vice versa. Also it is REALLY slow while straffing. The mecanumDrive function is in the subsystem Mecanum and the values are passed to it in the DriveTele command

I inverted the values already because at first forwards/backwards was inverted and straffing was good - but when I inverted it forwards/backwards was right and straffing was inverted

Does anyone have any ideas on how to invert the straffing and increase its speed?

Here is the code: https://github.com/MrSTUDofCODE/NewM...team4623/robot

THANKS!
Reply With Quote
  #2   Spotlight this post!  
Unread 13-02-2015, 16:09
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: Straffing Issue

Quote:
Originally Posted by LFRobotics View Post
The straffing is inverted - if I push the joystick left it goes right and vice versa.
If everything is working properly except for the left/right reversal of strafing, then negate your joystick X axis before using it.


Reply With Quote
  #3   Spotlight this post!  
Unread 13-02-2015, 16:12
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: Straffing Issue

Quote:
Originally Posted by LFRobotics View Post
it is REALLY slow while straffing
this is symptomatic of poor roller adjustment (high roller spinning friction).

check every single one of the rollers on each of the four wheels to make sure they spin freely.


Reply With Quote
  #4   Spotlight this post!  
Unread 13-02-2015, 17:04
cstelter cstelter is offline
Programming Mentor
AKA: Craig Stelter
FRC #3018 (Nordic Storm)
Team Role: Mentor
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Mankato, MN
Posts: 77
cstelter will become famous soon enough
Re: Straffing Issue

Quote:
Originally Posted by LFRobotics View Post
Does anyone have any ideas on how to invert the straffing and increase its speed?

THANKS!
Here is what your command sends to mecanumDrive from your DriveTele command:

Code:
    	Robot.mec.mecanumDrive(
                (oi.stick.getLeftJoyX()+oi.stick.getLeftJoyY())/2,
                (oi.stick.getLeftJoyY()-oi.stick.getLeftJoyX())/2,
                -(oi.stick.getLeftJoyY()-oi.stick.getLeftJoyX())/2,
                -(oi.stick.getLeftJoyX()+oi.stick.getLeftJoyY())/2);
this in turn calls:

Code:
   public void mecanumDrive(double FL, double RL, double FR, double RR)   {
        frontLeftMotor.set(-FL);
        rearLeftMotor.set(-RL);
        frontRightMotor.set(-FR);
        rearRightMotor.set(-RR);
    }
at first glance it is obvious that even if oi.stick.getLeftJoyX() is 1.0 and your Y is 0.0, a pure strafe is going to genrate 0.5 for all motors (probably your slowness problem).

In the case of strafe right, X will be 1.0 so your 4 values become

FL=0.5
RL=-0.5
FR=+0.5
RR=-0.5

You then negate all of these for the motors so the motors see

frontLeft -0.5
rearLeft +0.5
frontRight -0.5
rearRight +0.5

Because those on the right side are likely driving in reverse on positive voltage this is most likely

frontLeft toward robot rear 0.5
rearLeft toward robot fore 0.5
frontRight toward robot fore 0.5
rearRight toward robot rear 0.5

which unfortunately is the way to rotate wheels for strafing left.

So as Ether says, change the +/- in front of all your getX() calls in your DriveTele and this will solve the problem.

To fix your speed issue you need to do something different than (X + Y)/2.0.

(X+Y)/2.0 gives you 1.0 only on the diagonals, but not straight ahead or to the sides.

If you have studied polar math in school, you should know that a better formulation for what you are trying to do is to combine the two into a magnitude with sqrt(x*x + y*y) via the Pythagorean theorem. This way straight left calculates sqrt(1+0) = 1.0. And sqrt(0.5*0.5 + 0.5*0.5) = 0.5. But then to get your signs right, you have to compensate. based on the sign of x and y.

I would recommend that you instantiate a RobotDrive object in your subsystem and call the mecanumDrive_Cartesian(x,y,rot,gyro) function-- you can pass 0 in for rotation and the gyro. Then you can just pass getX and getY from your stick.

Code:
public class Mecanum extends Subsystem {
    ...
    SpeedController frontLeftMotor = new Jaguar(0);
    SpeedController frontRightMotor = new Jaguar(1);
    SpeedController rearLeftMotor = new Talon(2);
    SpeedController rearRightMotor = new Jaguar(3);
    RobotDrive myDrive;    
    ...
    
   public Mecanum() {
        //Constructor-- called when we do new Mecanum() in Robot
        myDrive=new RobotDrive(frontLeftMotor,rearLeftMotor,
                               frontRightMotor,rearRightMotor);
   }
   
   public void mecanumDrive(double FL, double RL, double FR, double RR)   {
        frontLeftMotor.set(-FL);
        rearLeftMotor.set(-RL);
        frontRightMotor.set(-FR);
        rearRightMotor.set(-RR);
    }

    
    public void mecanumViaRobotDrive(double x, double y, double rotation, double gyro)
    {
         myDrive.mecanumDrive_Cartesian(x,y,rotation,gyro);
    }
    
Then in DriveTele

Code:
    	
public void execute() {
    Robot.mec.mecanumViaRobotDrive(oi.stick.getLeftJoyX(),oi.stick.getLeftJoyY(),0,0);
}

Good luck!
Reply With Quote
  #5   Spotlight this post!  
Unread 15-02-2015, 00:47
viggy96 viggy96 is offline
Registered User
FRC #3331
Team Role: College Student
 
Join Date: Jan 2015
Rookie Year: 2010
Location: Charlotte
Posts: 59
viggy96 is infamous around these partsviggy96 is infamous around these parts
Yeah, just negate the axis values you are using to strafe. Also, strafing requires more torque than moving normally, so its normal to be moving more slowly. If you want to move more effectively sideways, then gear your drivetrain for torque.
Reply With Quote
  #6   Spotlight this post!  
Unread 18-02-2015, 12:13
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
Re: Straffing Issue

Okay I that fixed the straffing inverted issue but it still does not go faster with cartesian - and if I try multiplying the values everything gets screwed up
Reply With Quote
  #7   Spotlight this post!  
Unread 18-02-2015, 12:35
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: Straffing Issue

Quote:
Originally Posted by LFRobotics View Post
it still does not go faster with cartesian
Did you do this yet?

Quote:
Originally Posted by Ether View Post
this is symptomatic of poor roller adjustment (high roller spinning friction).

check every single one of the rollers on each of the four wheels to make sure they spin freely.

Reply With Quote
  #8   Spotlight this post!  
Unread 18-02-2015, 14:53
cstelter cstelter is offline
Programming Mentor
AKA: Craig Stelter
FRC #3018 (Nordic Storm)
Team Role: Mentor
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Mankato, MN
Posts: 77
cstelter will become famous soon enough
Re: Straffing Issue

Quote:
Originally Posted by LFRobotics View Post
Okay I that fixed the straffing inverted issue but it still does not go faster with cartesian - and if I try multiplying the values everything gets screwed up
Have you tried using RobotDrive?

I looked at your Github code which was updated about 24 hours ago and it still looks like you are sending 0.5 power to all your motors while strafing.
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 00:42.

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