View Single Post
  #1   Spotlight this post!  
Unread 10-02-2005, 23:01
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: 747
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
If statement in .h file or Indirect addressing? Kevin NAV code...

Ok...so I am not sure how to explain what I need but I know what I want to do.

I am helping our team program this year and really this is the first time I've dabble in C code. I normally program PLCs (programmable logic controllers)...anyway...

I noticed that Kevins nav code uses a commands.h file which is a structured something to send commands in a list format to the robot.c file. Very slick and easy. We've made our own functions and commands for our automous mode.

What I'd like to do is alter this with some inputs to create multi automous modes. We have all the inputs selections working but not sure what would be the best approach in C code to do what we need.

I want to do something like this:


Code:
if (input = 1)
    {
    struct commands command_list[] = {

    /*   Command              parm 1     parm 2   parm 3   */

    {CMD_WAIT,                 1000,        0,      0},
    {CMD_DRIVE,                1500,        0,      0},
    {CMD_WAIT,                 4000,        0,      0},
    }
};

Of course that's not exactly legal in C code....

So if I was doing this in a PLC, I might use what is called indirect addressing, or assigning a varaible to a pointer.

Like:

struct commands command_list*myvarible*[] =

so if myvarible is equal to 1 then run the commands in list #1. If myvarible is equal to 2 then run the commands in list #2.

Is there such a thing like this in C Code?

I hope that makes sense...
__________________
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