Go to Post Mike Wade was the Fall offseason guy. - Michael Leicht [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 26-02-2014, 12:55
ashb1025 ashb1025 is offline
Registered User
FTC #6095
 
Join Date: Feb 2014
Location: New Castle, IN
Posts: 11
ashb1025 is an unknown quantity at this point
FTC Block Party IR-Sensor

Hi, I am the main programmer for 6095, we are having some trouble with using if statements on our IR autonomous program. I am familiar with RobotC but am having some trouble. Some help would be greatly appreciated.
  #2   Spotlight this post!  
Unread 26-02-2014, 15:53
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: FTC Block Party IR-Sensor

Can you post your code in its current state? Or at the least, give us a better idea of what you're trying to do and where you're having problems.
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
  #3   Spotlight this post!  
Unread 27-02-2014, 12:45
ashb1025 ashb1025 is offline
Registered User
FTC #6095
 
Join Date: Feb 2014
Location: New Castle, IN
Posts: 11
ashb1025 is an unknown quantity at this point
Re: FTC Block Party IR-Sensor

This is the code, the idea of it is to work like a check list for each of the buckets, say you have buckets 1-4 it'll check bucket 1 for a infrared signal if it doesn't get one it moves on to bucket 2, if it does then it dumps the block in the bucket and moves to the closest ramp.AutonomousIR.c, I apologize I don't know how to get the code to display in the post
  #4   Spotlight this post!  
Unread 27-02-2014, 13:09
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: FTC Block Party IR-Sensor

It looks like you're pretty close; you just need to repeat the check for each of the buckets. You can either copy-and-paste the code as many times as you need (probably 4 in this case), but a more maintainable way would be to use a loop.

Code:
for(int i = 0; i < 4; i++)
{
    // put code for a single basket here
}
--Ryan

P.S. You can use tags to inline code in your post. Look for the button with the # symbol in the post editor
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
  #5   Spotlight this post!  
Unread 27-02-2014, 13:14
ashb1025 ashb1025 is offline
Registered User
FTC #6095
 
Join Date: Feb 2014
Location: New Castle, IN
Posts: 11
ashb1025 is an unknown quantity at this point
Re: FTC Block Party IR-Sensor

Thank you, and 1 more question, would you happen to know how to read the returning values from the sensor and then how to use those values for a 2 conditional if statement? For example if the first conditional returns true and the second conditional returns > 100 then run the if statement
  #6   Spotlight this post!  
Unread 27-02-2014, 13:35
ashb1025 ashb1025 is offline
Registered User
FTC #6095
 
Join Date: Feb 2014
Location: New Castle, IN
Posts: 11
ashb1025 is an unknown quantity at this point
Re: FTC Block Party IR-Sensor

I was thinking it would be something like this but I don't know for sure
Code:
task main()
  {
    if (conditional1(sensor)==2)
     {
       if(conditional2(sensor) > 100)
         {
           //run bucket commands
         }
       else
        {
          //move on to next bucket
         }
  #7   Spotlight this post!  
Unread 27-02-2014, 13:49
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: FTC Block Party IR-Sensor

That would definitely work, and there's no problem with that, but you would need to have two identical else {} blocks (one on each of the two if statements) so that the "move on to next bucket" code would be run if either of the conditions was false.

An easier way to do this is to use the "and" operator to combine both if statements. In ROBOTC, you write this as &&

Code:
task main()
{
   if (conditional1(sensor)==2 && conditional2(sensor) > 100)
   {
      //run bucket commands
   }
   else
   {
      //move on to next bucket
   }
}
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor

Last edited by RyanCahoon : 27-02-2014 at 14:06.
  #8   Spotlight this post!  
Unread 27-02-2014, 13:51
ashb1025 ashb1025 is offline
Registered User
FTC #6095
 
Join Date: Feb 2014
Location: New Castle, IN
Posts: 11
ashb1025 is an unknown quantity at this point
Re: FTC Block Party IR-Sensor

Thank you very much
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


All times are GMT -5. The time now is 02:36.

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