Go to Post I approve of this misuse of machinery! - RoboChair [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Spotlight this post!  
Unread 05-02-2008, 17:52
Bryan Herbst's Avatar
Bryan Herbst Bryan Herbst is offline
Registered User
AKA: Bryan
FRC #2052 (KnightKrawler)
Team Role: Mentor
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Minneapolis, Minnesota
Posts: 545
Bryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond repute
Re: Code spitting out -16256?

We got rid of some things that were being used, switched to not using the table, and and made all the variables ints.

Updated code-
Code:
void Mechanum(void)
{
    signed int prepwm01, prepwm02, prepwm03, prepwm04, wFL, wFR, wRL, wRR, velocity, rotation, strafe, wMax;
    static char pwm01_1, pwm02_1, pwm03_1, pwm04_1; //will be used eventually

    velocity = (p1_y - 127);
    rotation = (p1_x - 127);
    strafe = (p2_x - 127);

printf("Velocity: %d  Rotation: %d  Strafe: %d \r \n", velocity, rotation, strafe);
   
    wFL = velocity - rotation - strafe;
    wFR = velocity + rotation + strafe;
    wRL = velocity - rotation + strafe;
    wRR = velocity + rotation - strafe;

printf("Wheels before wMax- FL: %d FR: %d RL: %d RR: %d \r \n", wFL, wFR, wRL, wRR);

   wMax = intMax(127, intABS(wFL));
   wMax = intMax(wMax, intABS(wFR));
   wMax = intMax(wMax, intABS(wRL));
   wMax = intMax(wMax, intABS(wRR));


    wFL = (wFL / wMax);
    wFR = (wFR * 127 / wMax);
    wRL = (wRL / wMax);
    wRR = (wRR * 127 / wMax);
  if (-127 > wFL || wFL > 127 || -127 > wFR || wFR > 127 || -127 > wRL || wRL > 127 || -127 > wRR || wRR > 127)
    {     
        printf("Received an unexpected number FL: %d FR: %d RL: %d RR: %d /n", wFL, wFR, wRL, wRR);
    }
else
    {

    prepwm01 = wFL + 127;
    prepwm02 = 127 - wFR;
    prepwm03 = wRL + 127;
    prepwm04 = 127 - wRR;   


    pwm01 = prepwm01;
    pwm02 = prepwm02;
    pwm03 = prepwm03;
    pwm04 = prepwm04;

printf("PWMS- pwm01: %d , pwm02: %d , pwm03: %d , pwm04: %d \r \n", pwm01, pwm02, pwm03, pwm04);
}
}
None of the other functions have changed.

We are currently receiving not quite so crappy numbers, but still aren't getting the desired results (COM window attached).

We've found the problem to lie in-
Code:
    velocity = (p1_y - 127);
    rotation = (p1_x - 127);
    strafe = (p2_x - 127);
We've put some printf statements before and after these 3 lines, but the p1 and p2 variables are correct. For some reason the code is adding 129 to p1_x and p2_y and storing that into rotation and strafe instead of subtracting 127.

We can't figure out where this is coming from. Any ideas?


Sorry we couldn't try the last poster's suggestion today- our lab lost its internet connection, and we forgot what it was. We'll try that tomorrow.
Attached Images
File Type: bmp craptacular.bmp (98.8 KB, 35 views)
__________________
Team 2052- KnightKrawler
Mentor and volunteer
 


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
Out of the Box Camera Code russell Programming 9 21-10-2009 05:28
Any Examples Of Ready To Go Autonymous Code Out There ? gemccnp Programming 2 20-02-2005 19:24
Need Advice On Code Out Of Box...New To This gemccnp Programming 4 30-01-2005 18:57
CMUCam2 Camera Code - Are important parts commented out? Mr. Lim Programming 4 14-01-2005 12:11


All times are GMT -5. The time now is 19:15.

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