Go to Post "So [you're] like battlebots" Standard answer: No -- it's better! - Roger [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 10-11-2009, 21:36
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: Aiken, SC
Posts: 1,584
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Re: [FTC]: Robot C

Quote:
Originally Posted by alphadog0309 View Post
i dont know why but i was told and ive seen it done only this way in robotc but it think its supposed to be

if(joy1Btn(1) !=0)
{
action
}

don't know why i just do it like that...
Yeah the programming Gods like you to do that it's really just unessesary code, and yeah it's been a long day i know i forgot the loop XD.
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632, FRC 4901
2013 FTC World Championship Guest Speaker
Reply With Quote
  #17   Spotlight this post!  
Unread 10-11-2009, 21:37
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: Aiken, SC
Posts: 1,584
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Re: [FTC]: Robot C

Quote:
Originally Posted by John_1102 View Post
Yeah the programming Gods like you to do that it's really just unessesary code, and yeah it's been a long day i know i forgot the loop XD.
if(joy1Btn(1) )
{
code for what you want to happen here
}
else
{
code to make that stop happening
}

this is still as efficiant i tried it today.
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632, FRC 4901
2013 FTC World Championship Guest Speaker
Reply With Quote
  #18   Spotlight this post!  
Unread 10-11-2009, 22:04
l0jec l0jec is offline
Registered User
no team
 
Join Date: Oct 2009
Rookie Year: 2004
Location: St. Louis, MO
Posts: 52
l0jec has a spectacular aura aboutl0jec has a spectacular aura about
Re: [FTC]: Robot C

Quote:
Originally Posted by alphadog0309 View Post
i dont know why but i was told and ive seen it done only this way in robotc but it think its supposed to be

if(joy1Btn(1) !=0)
{
action
}

don't know why i just do it like that...
What you're doing is perfectly valid, but may not be the "cleanest" way.

You need to understand that a boolean true/false in ROBOTC is the same as 1 or 0 where
'true' is the same as '1' and 'false' is the same as '0'. Therefore the follow statements are all logically equivalent:
Code:
if(value == true)
if(value == 1)
if(value != false)
if(value != 0)
Since the if statement is conditional on the truth of the argument, you can format the test for truth a number of ways. Understand that the "value == true" argument is going to be evaluated as either true ('value' is true(1)) or false ('value' is false(0)) and that is what the if() statement actually looks at.
So as long as the value variable in our example here is already a boolean, there is no need to explicitly check it for truth. That is there is no need to explicitly test if true is equal to true of if false is equal to false... just pass the boolean itself to the if() statement like:
Code:
if(value)
Where does this tie into checking if a button is pressed using the joy1Btn() function?
Well because those functions return a boolean. That means when you call the function you get back either a true or a false and there is no need to see if that is not equal to 0. Just test against the returned boolean like:
Code:
if(joy1Btn(1))
{
  //do stuff
}
Now changing if(joy1Btn(1) != 0) to if(joy1Btn(1)) will not make your code behave any differently, but it will make it much more readable. As someone much wiser once said, any fool can write code that a computer can understand, but a good programmer writes code that a human can understand.

Hope this clears us some of the fog.
Reply With Quote
  #19   Spotlight this post!  
Unread 11-11-2009, 18:18
alphadog0309's Avatar
alphadog0309 alphadog0309 is offline
Registered User
AKA: Karan Hiremath
FTC #0110 (MFS Foxes)
Team Role: Programmer
 
Join Date: Nov 2009
Rookie Year: 2008
Location: Moorestown, New Jersey
Posts: 41
alphadog0309 will become famous soon enoughalphadog0309 will become famous soon enough
Re: [FTC]: Robot C

ahh i see... yeah that makes sense... i guess my brain is just wired in some screwed up way haha
Reply With Quote
  #20   Spotlight this post!  
Unread 11-11-2009, 19:27
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: Aiken, SC
Posts: 1,584
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Re: [FTC]: Robot C

Quote:
Originally Posted by l0jec View Post
What you're doing is perfectly valid, but may not be the "cleanest" way.

You need to understand that a boolean true/false in ROBOTC is the same as 1 or 0 where
'true' is the same as '1' and 'false' is the same as '0'. Therefore the follow statements are all logically equivalent:
Code:
if(value == true)
if(value == 1)
if(value != false)
if(value != 0)
Since the if statement is conditional on the truth of the argument, you can format the test for truth a number of ways. Understand that the "value == true" argument is going to be evaluated as either true ('value' is true(1)) or false ('value' is false(0)) and that is what the if() statement actually looks at.
So as long as the value variable in our example here is already a boolean, there is no need to explicitly check it for truth. That is there is no need to explicitly test if true is equal to true of if false is equal to false... just pass the boolean itself to the if() statement like:
Code:
if(value)
Where does this tie into checking if a button is pressed using the joy1Btn() function?
Well because those functions return a boolean. That means when you call the function you get back either a true or a false and there is no need to see if that is not equal to 0. Just test against the returned boolean like:
Code:
if(joy1Btn(1))
{
  //do stuff
}
Now changing if(joy1Btn(1) != 0) to if(joy1Btn(1)) will not make your code behave any differently, but it will make it much more readable. As someone much wiser once said, any fool can write code that a computer can understand, but a good programmer writes code that a human can understand.

Hope this clears us some of the fog.
Tis exactly right
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632, FRC 4901
2013 FTC World Championship Guest Speaker
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[FTC]: Power Surge Robot Nitro-Guy FIRST Tech Challenge 7 21-05-2009 10:30
[FTC]: FTC Futures Forum at FTC World Championship gdo FIRST Tech Challenge 0 08-04-2009 18:46
[FTC]: FTC]: FTC Champ Tournament - Ontario (Scoring Breakdown) Mr. Lim FIRST Tech Challenge 2 03-03-2008 11:54
pic: FTC #3 robot design Techno-Turkey Extra Discussion 5 06-02-2008 08:07
[FTC]: [FTC]: Ontario Provincial FTC Start/End Times cbhl FIRST Tech Challenge 8 16-12-2007 13:37


All times are GMT -5. The time now is 20:11.

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