Go to Post I blame FIRST for being the best thing that has happened to me. - vivek16 [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 Rating: Thread Rating: 3 votes, 4.67 average. Display Modes
  #1   Spotlight this post!  
Unread 03-02-2011, 15:55
Shantali Shantali is offline
Registered User
FRC #3609
 
Join Date: Jan 2011
Location: Maine, US
Posts: 9
Shantali is an unknown quantity at this point
Re: Single Joystick Tank Drive

It does say 0.0 at the beginning, but after driving it for a bit then letting go, it doesn't always center perfectly.

Both of our joysticks do that :\
Reply With Quote
  #2   Spotlight this post!  
Unread 03-02-2011, 16:00
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
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: Single Joystick Tank Drive

Quote:
Originally Posted by Shantali View Post
It does say 0.0 at the beginning, but after driving it for a bit then letting go, it doesn't always center perfectly.

Both of our joysticks do that :\
Clean the Mountain Dew out of them.


Reply With Quote
  #3   Spotlight this post!  
Unread 03-02-2011, 17:19
Shantali Shantali is offline
Registered User
FRC #3609
 
Join Date: Jan 2011
Location: Maine, US
Posts: 9
Shantali is an unknown quantity at this point
Re: Single Joystick Tank Drive

They're clean outta the box ones... :'(
Reply With Quote
  #4   Spotlight this post!  
Unread 03-02-2011, 17:30
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
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: Single Joystick Tank Drive

Quote:
Originally Posted by Shantali View Post
They're clean outta the box ones... :'(
Maybe there's an error in your software?

Try loading the default code that came with the LabVIEW installation and run it and see if it does the same thing.



Reply With Quote
  #5   Spotlight this post!  
Unread 05-02-2011, 02:28
Shantali Shantali is offline
Registered User
FRC #3609
 
Join Date: Jan 2011
Location: Maine, US
Posts: 9
Shantali is an unknown quantity at this point
Re: Single Joystick Tank Drive

After updating and running stuff again, joysticks center within 0.05 from center. Still not a perfect 0.

However, after playing around with various types of if statements, I'm starting to get the impression that the default way is the only way of making it operate smoothly.

If you look at the http://web.goodrobot.com/blog/wp-con.../tankdrive.png diagram clockwise, by default we get the "motor forward x3, motor off, motor backward x3, motor off" pattern.. That way there is never a situation where the motor has to abruptly switch directions.

If swapping the reverse directions, we get "motor forward x3, motor backward x3, motor off, motor backward, motor off". That way at some point there's an abrupt change in motors from going backwards to forward. That is the issue I've been having and at this point I see no way of avoiding it.

If I'm wrong, please correct me.
Reply With Quote
  #6   Spotlight this post!  
Unread 05-02-2011, 12:55
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
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: Single Joystick Tank Drive

Quote:
Originally Posted by Shantali View Post
After updating and running stuff again, joysticks center within 0.05 from center. Still not a perfect 0.

However, after playing around with various types of if statements, I'm starting to get the impression that the default way is the only way of making it operate smoothly.

If you look at the http://web.goodrobot.com/blog/wp-con.../tankdrive.png diagram clockwise, by default we get the "motor forward x3, motor off, motor backward x3, motor off" pattern.. That way there is never a situation where the motor has to abruptly switch directions.

If swapping the reverse directions, we get "motor forward x3, motor backward x3, motor off, motor backward, motor off". That way at some point there's an abrupt change in motors from going backwards to forward. That is the issue I've been having and at this point I see no way of avoiding it.

If I'm wrong, please correct me.
I think you are correct.

I believe the pseudo-code below implements the behavior shown in the diagram you referenced:

Code:
float Xj, Yj, L, R;

float max, sum, dif;

max = abs(Xj); if (abs(Yj)>max) max = abs(Yj);

sum = Xj+Yj; dif = Xj-Yj;

if(Yj<=0)
 {
 if(Xj>=0)
  {
  // first quadrant
  L =  max;
  R = -sum;
  }
 else
  {
  // second quadrant
  L =  dif;
  R =  max;
  }
 }
else
 {
 if(Xj>=0)
  {
  // fourth quadrant
  L =  dif;
  R = -max;
  }
 else
  {
  // third quadrant
  L = -max;
  R = -sum;
  }
 }
If you want to reverse the direction of rotation when backing up, I believe the following modified code would do that (note the addition of some deadband to address your concern about abrupt motor direction changes*):

Code:
float Xj, Yj, L, R;

float max, sum, dif, deadband;

if (Yj>-deadband)&&(Yj<deadband) Yj=0;

max = abs(Xj); if (abs(Yj)>max) max = abs(Yj);

sum = Xj+Yj; dif = Xj-Yj;

if(Yj<=0)
 {
 if(Xj>=0)
  {
  // first quadrant
  L =  max;
  R = -sum;
  }
 else
  {
  // second quadrant
  L =  dif;
  R =  max;
  }
 }
else
 {
 if(Xj>=0)
  {
  // fourth quadrant
  L = -max;
  R =  dif;
  }
 else
  {
  // third quadrant
  L =  -sum;
  R =  -max;
  }
 }

*if using Jaguars, you may want to experiment with putting the jumper in the "coast" setting to avoid abrupt motor braking when transitioning into/out_of the deadband zone



Last edited by Ether : 05-02-2011 at 14:54. Reason: added footnote; corrected modified code
Reply With Quote
  #7   Spotlight this post!  
Unread 05-02-2011, 18:09
Shantali Shantali is offline
Registered User
FRC #3609
 
Join Date: Jan 2011
Location: Maine, US
Posts: 9
Shantali is an unknown quantity at this point
Re: Single Joystick Tank Drive

I've tried having a dead zone, treating everything within 0.1 from the axis, as 0.
Then problem is that when you move the joystick all the way right to turn on the spot, then move it slightly forward, then slightly backwards, you can hear the motors clicking as they're going from "left forward right backwards" to "left backwards right forward".

I tried to play around with giving it more of a dead zone when turning on the spot
Code:
//x, y = joystick position
if (abs(x) > 0.5){
   if (abs(y) < 0.3)
      y = 0;}
to fix that, but it didn't work that well either.

I think my driver will have to get used to driving the way it was originally, with swapped reverses.
Reply With Quote
  #8   Spotlight this post!  
Unread 06-02-2011, 09:11
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
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: Single Joystick Tank Drive

Quote:
Originally Posted by Shantali View Post
I think my driver will have to get used to driving the way it was originally, with swapped reverses.
Have you considered doing something a little more advanced?

You could install the gyro and use it so that the driver interface would allow the driver to issue field-centric commands. The driver points the joystick, and the vehicle turns and goes in that direction at a speed determined by the magnitude of the joystick displacement.



Last edited by Ether : 06-02-2011 at 09:35.
Reply With Quote
  #9   Spotlight this post!  
Unread 07-02-2011, 19:58
Shantali Shantali is offline
Registered User
FRC #3609
 
Join Date: Jan 2011
Location: Maine, US
Posts: 9
Shantali is an unknown quantity at this point
Re: Single Joystick Tank Drive

I love the concept, but it's a little bit more advanced than I can manage at the moment :\ This is our rookie year, and there's a lot more to figure out. Maybe in the future!

Thanks so much for your help
Reply With Quote
  #10   Spotlight this post!  
Unread 23-03-2011, 15:40
maleche maleche is offline
Senior Engineering Program Manager
no team
 
Join Date: Mar 2011
Rookie Year: 2004
Location: Washington State
Posts: 1
maleche is an unknown quantity at this point
Re: Single Joystick Tank Drive

This is a great subject. I am working on the same concept using Visual Basic. I have a scaled Picture box with -128,128, 128,128 set as the scaled box points. Center is 0 (zero) with adjustable deadbands in both X & Y centered.

Moving a joystick OR mouse sends the Xj, Yj or Xm, Ym directly to the motor controller, after calculations.

I am using pythagorean for vector speed (Vel) based on joystick/mouse angle and distance from center. This works great in direct Y and -Y vectors ( both treads move at same speed and direction). -X, X will rotate Left and Right tank treads in opposite directions at equal speed. When steering slightly left and forward (Xj=-20, Yj=50) the total vector is the Sin(Angle)* Vel. This does well when transitioning from full forward to left/right steering. I'm still working out some bugs. I have not considered Tan2 yet or using a Gyro to steer by. The motor controller is a Sabertooth 2x50 and using 0-127 as speed with direction tokens.
One thing to consider however, is when going from full forward to all-stop. This can tip the robot or cause problems with stability. I programmed a ramp-down speed Vel=Vel-ramp^2. this allow VERY smooth and quick stopping transitions.
Keep in touch!
Doyle
Reply With Quote
  #11   Spotlight this post!  
Unread 23-03-2011, 18:31
siggy2xc siggy2xc is offline
Registered User
AKA: Tyler Siegrist
FRC #1756 (Argos)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2009
Location: peoria
Posts: 70
siggy2xc is an unknown quantity at this point
Re: Single Joystick Tank Drive

As for the gyro-guided driving, I know that labview has a rotate axis vi built in. Not sure if java has it or not but the challenge is finding a way to get it to turn completely because as it comes closer to the direction your pointing the joystick the less exaggerated the turn becomes because you are moving closer to 0 on the x-axis and if your turning too fast then your gyro loses its accuracy. Good luck
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 11:23.

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