Go to Post Thanks to team 1114 and 1503 for not wiping the floor with us. - SpaceBoy2000 [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-02-2003, 00:53
Tazlikesrobots's Avatar
Tazlikesrobots Tazlikesrobots is offline
Jack of all trades...Master of none
AKA: Robert
FRC #1745 (P-51 Mustangs)
Team Role: Coach
 
Join Date: Feb 2003
Rookie Year: 2000
Location: Rowlett, Texas
Posts: 205
Tazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud of
Send a message via Yahoo to Tazlikesrobots
Question Bug in IR sensor code

I got a problem with my IR sensors code. Everything works ok until the robot reaches the end of the white line. I thought i'd be cleaver and wrote an if statement that says if rc_sw 1,2 & 3 =0 then go straight, however the robot goes into a left hand loop.

Any help or suggestions would be greatly appreciated!!

Here is the code I wrote:

FullAutoMode:

if rc_sw2=1 then straight:
if rc_sw1=1 & rc_sw3=0 then turnleft:
if rc_sw3=1 & rc_sw1=0 then turnright:
if rc_sw1 & rc_sw2 & rc_sw3=0 then straight:
goto endir:
straight:
debug "staight",cr
p1_y = 234
p3_y = 254
goto endir:

turnleft:
debug "left",cr
p1_y = 84
p3_y = 127
goto endir:

turnright:
debug "right",cr
p1_y = 127
p3_y = 84
goto endir:





KillAuto:

endir:
__________________
It is all mind over matter....If you don't mind, it does not matter.
_________________
2006 Woodie Flowers Award Recipient - Lone Star Regional
2006 Rookie All-Star - Lone Star Regional
2007 Lone Star Regional Champions
2008 Quarter-finalist - Lone Star Regional
2009 Chairman's Award & Website Award - Dallas Regional
2009 Quarter-finalist - Dallas Regional
2010 - Xerox Creativity Award & Semi-finalist - Dallas Regional
  #2   Spotlight this post!  
Unread 16-02-2003, 01:40
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
I believe the problem is centered around improper use of the &. Try replacing them with the keyword AND as well as splitting up that last if into multiple equlaties joined with the AND keyword.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #3   Spotlight this post!  
Unread 16-02-2003, 02:03
Gadget470's Avatar
Gadget470 Gadget470 is offline
A Fire Outside
AKA: Brandon Joerges
no team (Alpha Omega)
Team Role: Alumni
 
Join Date: Jan 2002
Rookie Year: 2000
Location: Madison Heights, MI
Posts: 1,000
Gadget470 is a jewel in the roughGadget470 is a jewel in the roughGadget470 is a jewel in the roughGadget470 is a jewel in the rough
Send a message via ICQ to Gadget470 Send a message via AIM to Gadget470
Code:
if rc_sw2=1 then straight: 
if rc_sw1=1 AND rc_sw3=0 then turnleft:
if rc_sw3=1 AND rc_sw1=0 then turnright:
if rc_sw1=0 AND rc_sw2=0 AND rc_sw3=0 then straight:
  #4   Spotlight this post!  
Unread 16-02-2003, 13:48
Tazlikesrobots's Avatar
Tazlikesrobots Tazlikesrobots is offline
Jack of all trades...Master of none
AKA: Robert
FRC #1745 (P-51 Mustangs)
Team Role: Coach
 
Join Date: Feb 2003
Rookie Year: 2000
Location: Rowlett, Texas
Posts: 205
Tazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud of
Send a message via Yahoo to Tazlikesrobots
Talking

Thanks for the help. It does not make a whole lot of sence since "&" and "and" are the same thing, however it works now!


_______________
Very funny Scottie....NOW BEAM DOWN MY CLOTHES!
__________________
It is all mind over matter....If you don't mind, it does not matter.
_________________
2006 Woodie Flowers Award Recipient - Lone Star Regional
2006 Rookie All-Star - Lone Star Regional
2007 Lone Star Regional Champions
2008 Quarter-finalist - Lone Star Regional
2009 Chairman's Award & Website Award - Dallas Regional
2009 Quarter-finalist - Dallas Regional
2010 - Xerox Creativity Award & Semi-finalist - Dallas Regional
  #5   Spotlight this post!  
Unread 16-02-2003, 13:52
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Quote:
Originally posted by Tazlikesrobots
Thanks for the help. It does not make a whole lot of sence since "&" and "and" are the same thing, however it works now!
They actually aren't AND is the logical version (like C's && if that helps) whereas & is the bitwise version (like C's &). For more detail, see this post.

Taking your previous code, assume sw1=1, sw2=0, sw3=1. Evaluate left to right:

sw1 & sw2 & sw3 => 1 & 0 & 1, which is 0. Then apply the comparison evaluator, 0=0, which evaluates to true. Thus if any of the switches are 0, this will evaluate to true.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #6   Spotlight this post!  
Unread 16-02-2003, 18:38
Tazlikesrobots's Avatar
Tazlikesrobots Tazlikesrobots is offline
Jack of all trades...Master of none
AKA: Robert
FRC #1745 (P-51 Mustangs)
Team Role: Coach
 
Join Date: Feb 2003
Rookie Year: 2000
Location: Rowlett, Texas
Posts: 205
Tazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud ofTazlikesrobots has much to be proud of
Send a message via Yahoo to Tazlikesrobots
Oh! I understand now! I just had an id-10-t error!

Once again, thanks for your input.
__________________
It is all mind over matter....If you don't mind, it does not matter.
_________________
2006 Woodie Flowers Award Recipient - Lone Star Regional
2006 Rookie All-Star - Lone Star Regional
2007 Lone Star Regional Champions
2008 Quarter-finalist - Lone Star Regional
2009 Chairman's Award & Website Award - Dallas Regional
2009 Quarter-finalist - Dallas Regional
2010 - Xerox Creativity Award & Semi-finalist - Dallas Regional
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
The 9:43 PM Server Bug sanddrag CD Forum Support 11 12-11-2003 19:13
Last Call for bug reports rbayer Programming 0 08-01-2003 02:48
SOCKS ???? archiver 2001 3 24-06-2002 02:09
Popularity of this site... archiver 2000 16 23-06-2002 22:42
Small bug Jay Lundy CD Forum Support 1 18-06-2001 17:03


All times are GMT -5. The time now is 22:05.

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