Go to Post When a vomit shooter runs out of balls, is it dry heaving? :p - Lil' Lavery [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-01-2008, 15:21
Vasily Zaitsev's Avatar
Vasily Zaitsev Vasily Zaitsev is offline
Registered User
FRC #1111 (Power Hawks)
Team Role: Electrical
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Maryland
Posts: 3
Vasily Zaitsev is an unknown quantity at this point
Send a message via AIM to Vasily Zaitsev
2008 Omni Drive Code Help

Our robot is using a four wheel, four motor omni drive system. Our code gives good output except for sometimes it swaps outputs. Instead of giving a 250, it gives a 4.

drive_ly and drive_lx are our drive joystick.
motor_fl_1 and all the others are the variables we send to the motors. fl=front left.
pwm_drive_fl are the actual motors.

Heres the code:
Code:
  if ( (drive_ly + drive_lx - 127) > 254 )
    motor_fl_1 = 254;
  else if ( ( drive_ly + drive_lx - 127) < 0 )
    motor_fl_1 = 0;
  else motor_fl_1 = drive_ly + drive_lx - 127;

  if ( ( 127 - drive_ly + drive_lx ) > 254 )
    motor_fr_1 = 254;
  else if ( (  127 - drive_ly + drive_lx ) < 0 )
    motor_fr_1 = 0;
  else motor_fr_1 =  127 - drive_ly + drive_lx;

  if ( ( 382 - drive_ly - drive_lx ) > 254 )
    motor_br_1 = 254;
  else if ( (  382 - drive_ly - drive_lx ) < 0 )
    motor_br_1 = 0;
  else motor_br_1 =  382 - drive_ly - drive_lx;

  if ( ( 127 + drive_ly - drive_lx ) > 254 )
    motor_bl_1 = 254;
  else if ( (  127 + drive_ly - drive_lx ) < 0 )
    motor_bl_1 = 0;
  else motor_bl_1 =  127 + drive_ly - drive_lx;



  if ( (motor_fl_1 < 137) && ( motor_fl_1 > 117 ) )
    pwm_drive_fl = 127;
  else  pwm_drive_fl = motor_fl_1;

  if ( (motor_fr_1 < 137) && ( motor_fr_1 > 117 ) )
    pwm_drive_fr = 127;
  else  pwm_drive_fr = motor_fr_1;

  if ( (motor_br_1 < 137) && ( motor_br_1 > 117 ) )
    pwm_drive_br = 127;
  else  pwm_drive_br = motor_br_1;

  if ( (motor_bl_1 < 137) && ( motor_bl_1 > 117 ) )
    pwm_drive_bl = 127;
  else  pwm_drive_bl = motor_bl_1;
we're pretty sure its an overflow error, but this code should make up for that.

can anybody help please?
  #2   Spotlight this post!  
Unread 26-01-2008, 17:09
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: 2008 Omni Drive Code Help

Anytime you add two chars together you risk overflow. Try making all your variables ints. Overflow is still possible, but only when you're working with numbers a lot larger than joystick and motor values.
  #3   Spotlight this post!  
Unread 26-01-2008, 22:11
Vasily Zaitsev's Avatar
Vasily Zaitsev Vasily Zaitsev is offline
Registered User
FRC #1111 (Power Hawks)
Team Role: Electrical
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Maryland
Posts: 3
Vasily Zaitsev is an unknown quantity at this point
Send a message via AIM to Vasily Zaitsev
Re: 2008 Omni Drive Code Help

yea that was our first idea too.
we made everything signed ints in order to avoid this issue. but somehow when we tried to limit mix them into the 0-254 range, the limit mix failed or something.
but no matter what happened it still didnt work.
could it be that we never casted them back into unsigned chars before assigning them to the pwm? because when i tried that we got pure 254 for all four outputs.

thanks for the help by the way. much appreciated.
  #4   Spotlight this post!  
Unread 26-01-2008, 22:39
Steve_Alaniz Steve_Alaniz is offline
Registered User
FRC #2848 (All Sparks)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 1997
Location: Dallas
Posts: 211
Steve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond repute
Re: 2008 Omni Drive Code Help

First uses this:

pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);

They Add 2000 to prevent a negative value and when they call LIMIT_MIX ()
It evaluates the result and subtract out the 2000. I think your code could be changed to

motor_fl_1 = Limit_Mix(2000 + drive_ly + drive_lx - 127);

motor_fr_1 = Limit_Mix(2000 + 127 - drive_ly + drive_lx);

motor_br_1 = Limit_Mix(2000 + 382 - drive_ly - drive_lx);

motor_bl_1 = Limit_Mix(2000+ 127 + drive_ly - drive_lx);


if ( (motor_fl_1 < 137) && ( motor_fl_1 > 117 ) )
pwm_drive_fl = 127;
else pwm_drive_fl = motor_fl_1;

if ( (motor_fr_1 < 137) && ( motor_fr_1 > 117 ) )
pwm_drive_fr = 127;
else pwm_drive_fr = motor_fr_1;

if ( (motor_br_1 < 137) && ( motor_br_1 > 117 ) )
pwm_drive_br = 127;
else pwm_drive_br = motor_br_1;

if ( (motor_bl_1 < 137) && ( motor_bl_1 > 117 ) )
pwm_drive_bl = 127;
else pwm_drive_bl = motor_bl_1;

This should prevent any over runs even if your joystick is doing something weird. Are you using a chicket?
Although I must admit I don't understand the "382 - drive_ly - drive_lx" but I'll assume you know the formula to be correct and that the problem you're having is from a violation in a positive integer math problem.

Hope that helps

Steve
  #5   Spotlight this post!  
Unread 26-01-2008, 22:57
Vasily Zaitsev's Avatar
Vasily Zaitsev Vasily Zaitsev is offline
Registered User
FRC #1111 (Power Hawks)
Team Role: Electrical
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Maryland
Posts: 3
Vasily Zaitsev is an unknown quantity at this point
Send a message via AIM to Vasily Zaitsev
Re: 2008 Omni Drive Code Help

thanks for that code. and yes we are using a chicklet to enable us to use an xbox 360 controller. does that make a difference?
and we tried using the default limit mixes, they cased the same problem, which is why i wrote my own up in that code. we suspected that somewhere there was a datatype conversion that messed us up, so we tried to eliminate all of them.

Last edited by Vasily Zaitsev : 26-01-2008 at 22:59. Reason: added content
  #6   Spotlight this post!  
Unread 27-01-2008, 00:57
Steve_Alaniz Steve_Alaniz is offline
Registered User
FRC #2848 (All Sparks)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 1997
Location: Dallas
Posts: 211
Steve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond repute
Re: 2008 Omni Drive Code Help

Chicklet can give weird outputs if the calibration is off or if the battery goes low.
I had that problem once and have made sure the battery we use is fully charged whenever we use it.
Try using one of the joysticks as a test to see if the problem occurred in the code or just when the Chicklet and Xbox controller is being used. Since you are having the problem occur with default code and the Chicklet/Xbox, that's almost certainly the problem. Default is pretty solid. If the numbers are inverting in default code with that 250 to 4 flip, it's probably happening because the system is getting that information in to begin with.
Good luck

Steve
Closed Thread


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help in Kevin's 2008 default code robotrobot2 Programming 5 20-01-2008 14:36
Lego Omni Drive Synergy1848 Robot Showcase 19 03-01-2007 11:51
pic: vex omni drive 1902_Battery_SGT FIRST Tech Challenge 6 28-05-2006 17:55
omni drive vs tank |20807 61|2|_ Technical Discussion 49 17-01-2006 13:54
Omni-drive autonomous questions Andrew Schuetze Programming 6 17-01-2006 12:15


All times are GMT -5. The time now is 23:10.

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