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:
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_listmyvarible] =
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…