Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Can anyone create new commands? (http://www.chiefdelphi.com/forums/showthread.php?t=33226)

Jakenan 22-01-2005 10:45

Can anyone create new commands?
 
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.

steven114 22-01-2005 11:11

Re: Can anyone create new commands?
 
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)
Code:

[returntype] [functionname]([argtype1] [argname1],[argtype2] [argname2]...){
/*Your code here*/
return [result];
}

For example:
Code:

double squareit(double numberToBeSquared){
return numberToBeSquared*numberToBeSquared;
}


Jakenan 22-01-2005 17:47

Re: Can anyone create new commands?
 
No, in the command.h and .c files are a list of...functions, or commands*not 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

ahmed 22-01-2005 19:29

Re: Can anyone create new commands?
 
Quote:

Originally Posted by Jakenan
No, in the command.h and .c files are a list of...functions, or commands*not 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

steven114 22-01-2005 20:20

Re: Can anyone create new commands?
 
I think he's talking about the default autonomous code, which is different. I have not used it, so I don't know.

iscrc2 22-01-2005 21:38

Re: Can anyone create new commands?
 
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'


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

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi