Go to Post Fans come and go... but if you're a diehard, you stick around during the losing seasons, too. - Amanda Morrison [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

 
Closed Thread
 
Thread Tools Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 05-02-2006, 15:19
seg9585's Avatar
seg9585 seg9585 is offline
Registered User
AKA: Eric
FRC #4276 (Surf City Vikings)
Team Role: Engineer
 
Join Date: Feb 2006
Rookie Year: 2001
Location: Boeing (Seal Beach, CA)
Posts: 520
seg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond repute
Re: Stupidest Programming Mistakes

We've had QUITE a few:

to convert angle radians to degrees:

int tiltdeg = tiltrad*( (int)3.14 / 180 );

hmmm, no wonder why we kept getting "0" as a tile angle...
and oh yeah, it shoulda been 180/3.14 to begin with...


In trying to comment stuff out with "/* */", we realize that we comment out other stuff already commented out using the same method, and whenever it reached that comment's "*/" it would end, causing a bunch of syntax errors throughout the rest of the uncommented code, and we couldnt figure out for the life of us why it was reading that code...

and dont know what we were thinking here:

if(TILT_SERVO > Tilt_Servo_Max)
TILT_SERVO = Tilt_Servo_Max - Tilt_Servo_Min + Step_Size;

um, I think we were trying to have the camera search in the last area it saw the light if it immediately loses it too high...but um.. Tilt_Servo_Min = 0 and Step_Size is greater than 0...
  #2   Spotlight this post!  
Unread 05-02-2006, 15:24
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: Stupidest Programming Mistakes

Quote:
Originally Posted by seg9585
In trying to comment stuff out with "/* */", we realize that we comment out other stuff already commented out using the same method, and whenever it reached that comment's "*/" it would end, causing a bunch of syntax errors throughout the rest of the uncommented code, and we couldnt figure out for the life of us why it was reading that code...
Little trick Mark McLeod showed me for that:

Code:
#ifdef //This is actually a comment block, #1
code
code
code
#endif //This is the end of comment block #1
Since the #ifdef is missing something to check, it always fails, so any code in it never compiles, doesn't get stopped by */, quite useful
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
  #3   Spotlight this post!  
Unread 05-02-2006, 17:03
Mike Shaul's Avatar
Mike Shaul Mike Shaul is offline
Registered User
FRC #0065 (Huskie Brigade)
Team Role: Engineer
 
Join Date: Jan 2006
Rookie Year: 2003
Location: Farmington Hills, MI
Posts: 53
Mike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant future
Re: Stupidest Programming Mistakes

The C Programing language has MANY different "issues" with undefined behavior or easy-to-make mistakes that compilers won't usually catch.

This website has compiled 10 (actually more than 10) common mistakes, check it out.
__________________
By far the best proof is experience. - Sir Francis Bacon
  #4   Spotlight this post!  
Unread 05-02-2006, 18:12
Goldeye Goldeye is offline
Registered User
AKA: Josh Hecht
FRC #0694 (Stuypulse)
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2005
Location: New York
Posts: 145
Goldeye has a spectacular aura aboutGoldeye has a spectacular aura aboutGoldeye has a spectacular aura about
Send a message via AIM to Goldeye
Re: Stupidest Programming Mistakes

My teammate made a great slipup that him and a mentor didn't catch till I looked. Here it is (with the error) in a function for averaging something in pseudocode.
Code:
int sum,count;
while(stuff_left)
{
     sum+=stuff;
     count++;
}
if(!count == 0)
     return -1
else
     return sum/count;
__________________
Team 694

2005 Championship - Galileo Semifinalist
2005 New York - Regional Chairmans Award
2005 New York - Semifinalist (Thanks 1257,1340)
  #5   Spotlight this post!  
Unread 05-02-2006, 18:50
Cuog's Avatar
Cuog Cuog is offline
Registered Linux User: 390661
AKA: Alex
FRC #0422
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 2004
Location: Richmond, Virginia
Posts: 852
Cuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond repute
Send a message via AIM to Cuog
Re: Stupidest Programming Mistakes

I havent made any hilariously dumb mistakes coding, i have done the condition after the else statement but i caught it quickly and i have also done the good old no semi-colon, but my most hilarious story is from an alumni from our team on his first programming attempt,

Basically to init his PWM values he set them to 0 logically thinking that zero meant no speed, the robot the ran full speed backward over the laptop he was using to program giving it the name "smokey" for ever and now i have to try and fix this old i286 laptop to use for some random off season stuff
__________________
KK4KQO
http://voltair.us
Too many projects, too little time.
  #6   Spotlight this post!  
Unread 05-02-2006, 19:11
Kristian Calhoun's Avatar
Kristian Calhoun Kristian Calhoun is offline
Celebrating 20 years of 25
FRC #0025 (Raider Robotix)
Team Role: Mentor
 
Join Date: Oct 2005
Rookie Year: 2006
Location: No. Brunswick, NJ
Posts: 1,077
Kristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond repute
Send a message via AIM to Kristian Calhoun
Re: Stupidest Programming Mistakes

this was one that someone els eon our programming team made that i had caught. we kept trying to compile the code and we kept getting an error, it ended up that instead of pwm01 and pwm02, that the other member of our team had put pwn01 and pwn02. we reached the conclusion that you cannot pwn the pwms lol.
__________________
Raider Robotix: Home | Twitter | Facebook | Instagram
Brunswick Eruption: Home | Twitter | Facebook
  #7   Spotlight this post!  
Unread 05-02-2006, 20:47
scitobor 617's Avatar
scitobor 617 scitobor 617 is offline
More nerd than you can handle!
AKA: Alan Meekins
FRC #0617 (HSHS 617 "DUKE")
Team Role: Programmer
 
Join Date: Nov 2003
Rookie Year: 2003
Location: Richmond, VA
Posts: 153
scitobor 617 will become famous soon enoughscitobor 617 will become famous soon enough
Send a message via AIM to scitobor 617
Re: Stupidest Programming Mistakes

For some reason whenever I open a project in MPlab it automaticlly opens user_routines.c from an old version of my code. It took me half of a saturday to figure out way changing stuff in user_routines.c had no effect what so ever, even when I intentionally added errors that should have caused all kinds of compile time errors. I still do not know what is causing this but I now know to check which file I'm editting before I make any changes.
__________________
Beta testers needed!
http://www.nullagent.no-ip.com

Your kidding, there are other operating systems besides Linux?!
  #8   Spotlight this post!  
Unread 05-02-2006, 23:46
BrianR BrianR is offline
Registered User
AKA: Brian Roehl
FRC #1525 (Warbots)
Team Role: Electrical
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Deerfield, IL
Posts: 79
BrianR has a spectacular aura aboutBrianR has a spectacular aura about
Send a message via AIM to BrianR
Re: Stupidest Programming Mistakes

Today we were trying to do our angle calculations, and we had made a trig mistake. So we changed it and uploaded the code. But for some reason it kept having the same problem. After we changed some other stuff to no result, we happened to notice that the loader was calling the wrong code, and that for some reason, it had built the .hex file to a different spot. Once we figured that out, it worked like a charm.
  #9   Spotlight this post!  
Unread 06-02-2006, 01:05
Chris_Elston's Avatar
Chris_Elston Chris_Elston is offline
Controls Engineer
AKA: chakorules
FRC #1501 (Team THRUST)
Team Role: Engineer
 
Join Date: Feb 2004
Rookie Year: 2001
Location: Huntington, Indiana
Posts: 750
Chris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond repute
Re: Stupidest Programming Mistakes

Code:
    if (varible = 1)
    {
      do this;
    }

Burns me ALL this time....don't forget to use DOUBLE equal signs....
__________________
Team T.H.R.U.S.T. 1501
Download all of our past robot's source code here:Repository

Favorite CD quote:
"That can't be their 'bot. not nearly enough (if any) rivets to be a 1501 machine." ~RogerR: Team #1369
  #10   Spotlight this post!  
Unread 06-02-2006, 08:27
tpc's Avatar
tpc tpc is offline
Registered User
AKA: Tom Convery
FRC #0623 (Cougar Robotics)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Falls Church, VA
Posts: 7
tpc is on a distinguished road
Re: Stupidest Programming Mistakes

Quote:
Originally Posted by chakorules
Burns me ALL this time....don't forget to use DOUBLE equal signs....
This is why I always write the constant first, when comparing equality between a constant and a variable:

Code:
if (1 == variable)
{
  /* do something */
}
Then if I inadvertently use an assignment rather than a comparison, it's a compile-time error (can't assign a value to a constant).
  #11   Spotlight this post!  
Unread 06-02-2006, 22:46
ForgottenSalad's Avatar
ForgottenSalad ForgottenSalad is offline
In search of a home...
AKA: Michael Wessler
no team
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Bethlehem, NH
Posts: 136
ForgottenSalad will become famous soon enoughForgottenSalad will become famous soon enough
Send a message via AIM to ForgottenSalad
Re: Stupidest Programming Mistakes

I spent an hour and a half or so trying to figure out why a new revision of our code wasn't working at all today. After switching speed controllers, cables, checking for abnormalities with a multimeter... I realized I had never called my routine. I ended up (stupidly) slamming my fist down on the laptop.
  #12   Spotlight this post!  
Unread 06-02-2006, 23:14
Chris_Elston's Avatar
Chris_Elston Chris_Elston is offline
Controls Engineer
AKA: chakorules
FRC #1501 (Team THRUST)
Team Role: Engineer
 
Join Date: Feb 2004
Rookie Year: 2001
Location: Huntington, Indiana
Posts: 750
Chris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond repute
Re: Stupidest Programming Mistakes

This is an EXCELLENT idea. Thanks for sharing this.




Quote:
Originally Posted by tpc
This is why I always write the constant first, when comparing equality between a constant and a variable:

Code:
if (1 == variable)
{
  /* do something */
}
Then if I inadvertently use an assignment rather than a comparison, it's a compile-time error (can't assign a value to a constant).
__________________
Team T.H.R.U.S.T. 1501
Download all of our past robot's source code here:Repository

Favorite CD quote:
"That can't be their 'bot. not nearly enough (if any) rivets to be a 1501 machine." ~RogerR: Team #1369
  #13   Spotlight this post!  
Unread 07-02-2006, 00:18
X-Istence X-Istence is offline
Melt the RC controller!
AKA: Bert JW Regeer
no team
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Montville
Posts: 151
X-Istence will become famous soon enoughX-Istence will become famous soon enough
Send a message via AIM to X-Istence Send a message via MSN to X-Istence
Re: Stupidest Programming Mistakes

Listen to the compiler when it tells you about casting. Don't try to force something to cast, and then lose information. Like going from unsigned to signed ints.
__________________
My Blog!
  #14   Spotlight this post!  
Unread 09-02-2006, 00:33
jfelser jfelser is offline
Registered User
FRC #0948
Team Role: Leadership
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Seattle, WA.
Posts: 43
jfelser will become famous soon enough
Send a message via AIM to jfelser
Re: Stupidest Programming Mistakes

I dunno if this is truly a programming mistake... but testing autonomous (using PID) we forgot to plug in one of the the interrupt pins on the encoders, resulting in a very interesting open-loop control system, and various material damages (the robot LED, the green light, the 6' stack of books the light was sitting on, the desk the books were sitting on, the counter with microscopes behind the desk with the books and light, and my self confidence).
__________________
Code Red Robotics Team 639 | www.team639.org
2004 Canadian SUPER Regional Winners with 33 & 1112, GM Industrial Design Award
2005 Finger Lakes Regional Winners with 191 & 494, Canadian Regional GM Industrial Design Award


Newport Robotics Group Team 948 | www.nrg948.org
2006 Portland Regional Motorola Quality Award Winners
2007 Portland Regional Finalists with 1540 & 1778, GM Industrial Design Award


-Jake Felser-
  #15   Spotlight this post!  
Unread 15-02-2006, 22:45
aaeamdar's Avatar
aaeamdar aaeamdar is offline
Post-A-Holic
AKA: Paul Dennis
FRC #1719 (The Umbrella Corp)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Baltimore, MD
Posts: 231
aaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant future
Re: Stupidest Programming Mistakes

I had this:

Code:
auto_mode = ~auto_select1 + 2(~auto_select2) + 3(~auto_select3);
Where auto_mode is later used in a switch{case:}, and auto_selectNs are variouss rc_dig_ins.

Can someone spot the error there? Yeah, 2() is not a valid method. So I changed it to this:

Code:
auto_mode = ~auto_select1 + 2*(~auto_select2) + 3*(~auto_select3);
And it still didn't work. Gee whiz. What is wrong now. It gives me a run-time unexpectedness glitch where auto_mode is calculated to be 246 or some nonsense like that. OK, fixed that by not using the binary complement and instead used the logical complement (in a #define) and it works.

In another one we had:

Code:
printf("Some motor values %d %d %d", 1,2,3);//Whatever
And nothing was printing. Gosh, that sure was weird. Well, it turns out that we failed to import stdio.h (or anything else that gives us access to printfs). And then, to make things worse, the C language is so incredibly stupid that all it gives you is a warning because it's not prototyped. Since we had been using some other methods that weren't prototyped (may have been a few in Kevins Code) those warnings got mushed in with the others.

Thank goodness for Java.

Paul Dennis
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
Programming Vex w/ MPLab dababyjebus FIRST Tech Challenge 27 25-04-2008 09:11
Programming - Getting Started Mark McLeod Programming 80 16-04-2008 23:37
VEX programming Gene F Programming 14 08-08-2006 22:21
Suggestion for Delphi Programming Posts Chris Hibner CD Forum Support 1 27-07-2005 10:02
Robot Programming Education phrontist Programming 11 03-05-2004 07:32


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

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