Im new at C and is slowly figuring it out. I learned how to use the current commands and is wondering if it is posible to program new commands. Man i have to go to a meeting soon, so if some one can help that would be great and i will be sure to read and express my thanks when i get back.
What do you mean by ‘commands?’ Are you referring to functions? Or are you referring to the autonomous program provided by FIRST? If you’re talking about built-in functions, then you certainly can! The basic format of a function is this:
(replace the items in square brackets with the proper keywords)
[returntype] [functionname]([argtype1] [argname1],[argtype2] [argname2]...){
/*Your code here*/
return [result];
}
For example:
double squareit(double numberToBeSquared){
return numberToBeSquared*numberToBeSquared;
}
No, in the command.h and .c files are a list of…functions, or commandsnot too sure that say: COMMAND, parameter1, parameter2, parameter3. I guess i dont understand how the commands are created and how to create my own commands and set parameters to them. if any one can, please help… :o
What you are refering to sound much like what steven114 just explained
I think he’s talking about the default autonomous code, which is different. I have not used it, so I don’t know.
yes you can ‘define’ new commands to place in the command.h
in robot.h around line 169 insert new lines that name a command and give a function prototype
in robot.c around line 156 insert new lines that will act on the new command
(it would look almost exactly like the CMD_KEEP_HEADING block just before it)
at the end of robot.c add the function you gave a prototype to in robot.h
(you might use the command state structure the other commands use: START, IN_PROGRESS, COMPLETE) don’t forget to return a 1 else it will get stuck on that command.
Then you can use your new command in the command.h ‘script’