View Single Post
  #9   Spotlight this post!  
Unread 20-01-2005, 17:55
Rich Petras's Avatar
Rich Petras Rich Petras is offline
Registered User
#0691 (Hart Burn)
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Santa Clarita, CA
Posts: 4
Rich Petras is on a distinguished road
Re: Multiple command_lists

[quote=Jon236]In the Navigation code I downloaded, it is apparent that the command_list data structure contained in commands.h provides a list of actions for the robot to accomplish. Using robot_command(), one can call this from either the autonomous or the manual mode. But how can we create multiple lists of commands to be used from various autonomous programs? Can we re-create the data structure in different iterations in a .c file?

Kevin suggested that I jump in and answer this one. (He doesn't want to take the blame if you find any errors in my part of the code.)

There are a couple of ways to do what you want. A trivial one is to write a version
of CMD_JUMP that jumps within the existing command list based on a DIO signal.

If you want to get fancy, you could write a command that rewrites the whole command list. It is a variable after all, and not a constant. Just remember to allocate an array big
enough to hold your largest sequence. You would probably want to reset your command number to zero before the next pass through the loop too.

I looked at a few of the suggestions others have made. Any of them will work, but it can make it hard to share commands if you change the underlying operation. I tried to avoid pointers, this is the elegant solution, but so many people get screwed up by pointers that we thought it might be better to not do that.

Last edited by Rich Petras : 20-01-2005 at 18:06.