Go to Post -Best FIRST Robot: One that Makes it to Competition - Conor Ryan [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 19-01-2005, 20:19
Jon236's Avatar
Jon236 Jon236 is offline
Registered User
AKA: Jon Mittelman
FRC #2648 (Infinite Loop)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2000
Location: Windsor, Maine
Posts: 741
Jon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond repute
Multiple command_lists

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, I would feel a lot better if you moved a little farther from the cliff!


Jon Mittelman
Team 236 Mentor
  #2   Spotlight this post!  
Unread 19-01-2005, 22:05
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
Re: Multiple command_lists

Quote:
Originally Posted by 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, I would feel a lot better if you moved a little farther from the cliff!


Jon Mittelman
Team 236 Mentor

If it was me, we have used thumb wheels in the form of binary input to some digital I/O. So we work out which program we are going to run before the match starts, set the thumb wheel to select the program we want to run. In code it sort of looks like this:

Code:
if (thumb_wheel = 1)
	{
	do these commands;
	do these commands;
	do these commands;
	do these commands;
	}


if (thumb_wheel = 2)
	{
	do these commands;
	do these commands;
	do these commands;
	do these commands;
	}

if (thumb_wheel = 3)
	{
	do these commands;
	do these commands;
	do these commands;
	do these commands;
	}
__________________
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
  #3   Spotlight this post!  
Unread 19-01-2005, 22:07
Jon236's Avatar
Jon236 Jon236 is offline
Registered User
AKA: Jon Mittelman
FRC #2648 (Infinite Loop)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2000
Location: Windsor, Maine
Posts: 741
Jon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond repute
Re: Multiple command_lists

Quote:
Originally Posted by chakorules
If it was me, we have used thumb wheels in the form of binary input to some digital I/O. So we work out which program we are going to run before the match starts, set the thumb wheel to select the program we want to run. In code it sort of looks like this:

Code:
if (thumb_wheel = 1)
	{
	do these commands;
	do these commands;
	do these commands;
	do these commands;
	}


if (thumb_wheel = 2)
	{
	do these commands;
	do these commands;
	do these commands;
	do these commands;
	}

if (thumb_wheel = 3)
	{
	do these commands;
	do these commands;
	do these commands;
	do these commands;
	}
Godd idea....but what I was wondering was how to list the different lists...can you put them in different .h files or all in the code files?
  #4   Spotlight this post!  
Unread 19-01-2005, 22:08
Jon236's Avatar
Jon236 Jon236 is offline
Registered User
AKA: Jon Mittelman
FRC #2648 (Infinite Loop)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2000
Location: Windsor, Maine
Posts: 741
Jon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond repute
Re: Multiple command_lists

Quote:
Originally Posted by chakorules
If it was me, we have used thumb wheels in the form of binary input to some digital I/O. So we work out which program we are going to run before the match starts, set the thumb wheel to select the program we want to run. In code it sort of looks like this:

Code:
if (thumb_wheel = 1)
	{
	do these commands;
	do these commands;
	do these commands;
	do these commands;
	}


if (thumb_wheel = 2)
	{
	do these commands;
	do these commands;
	do these commands;
	do these commands;
	}

if (thumb_wheel = 3)
	{
	do these commands;
	do these commands;
	do these commands;
	do these commands;
	}
Good idea....but what I was wondering was how to list the different lists...can you put them in different .h files or all in the code files?
  #5   Spotlight this post!  
Unread 19-01-2005, 22:40
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
Re: Multiple command_lists

That depends. Multiple header files will work, if you call each array in them a different name, then you can use code similar to above, and call the correct command on each array.
  #6   Spotlight this post!  
Unread 19-01-2005, 23:33
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Multiple command_lists

Quote:
Originally Posted by 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?
Actually, Rich Petras, another JPL engineer wrote this code. I talked with Rich tonight and he said that when he gets a chance, he wants to add conditional branching to the code, which will make it easier to do what you want. If he doesn't get to it in the next few days, I'll start working on it.


Quote:
Originally Posted by Jon236
Kevin, I would feel a lot better if you moved a little farther from the cliff!
In which direction <grin>?

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #7   Spotlight this post!  
Unread 20-01-2005, 01:28
Anthony Kesich's Avatar
Anthony Kesich Anthony Kesich is offline
Programmer Turned Engineer
AKA: SonKenshin
#1097 (Site 3 Engineernig)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Sacramento, CA
Posts: 186
Anthony Kesich has a spectacular aura aboutAnthony Kesich has a spectacular aura about
Send a message via AIM to Anthony Kesich
Re: Multiple command_lists

I would suggest making a two dimentional array.

Code:
Example commands.h file:

#define AUTO_MODE 1

struct commands command_list[][] =
     {
          {Set 0 of autonomous commands;}
     },
     {
          {set 1 of autonomous commands;}
     },
     {
          {set 2 of autonomous commands;}
     }
Code:
Example robot.c code:

switch (command_list[AUTO_MODE][current_command].command)
  {
  case NULL:
    {
	rc = 0;    // We don't want to increment to the next command
    break;
    }

  case CMD_SHOW_STATE:
    {
    rc = cmd_show_state();
    break;
    }
...so on and so forth
Anyways, this allows for multiple programs that change with one macro definition. If you're worried about space, just have multiple codes in you commands.h file, and comment them all out except for the one you want.

This array decliration can also be used if you have multiple programs and want to change between them with a switch on the robot without recompiling and downloading. Just replace the macro definition with the input source.

-Tony K
__________________
C is screwing up my English--I'm ending all my sentences in semi-colons;

Horray for most things! -George Carlin

"Sure, I'll play rugby. Besides, I have a lot of experience running from really big guys who want to cream me." -Me, Freshman year
  #8   Spotlight this post!  
Unread 20-01-2005, 15:58
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Multiple command_lists

What I did was redid the code so that it accessed a pointer to the array, than made that pointer an argument:

Code:
struct commands *command_list;
//...
void robot_control(struct commands *script)
{
robot_command(script);
robot_timer();
robot_position();
}

void robot_command(struct commands *script)
{
//...
}
Of course, I also macro'ed access to the elements in the array, which makes such changes easy:
Code:
#define GET_COMMAND(index) command_list[(index)]
#define CUR_COMMAND GET_COMMAND(current_command)
#define COMMAND CUR_COMMAND.command
#define PARAM1 CUR_COMMAND.parm_1
#define PARAM2 CUR_COMMAND.parm_2
#define PARAM3 CUR_COMMAND.parm_3
So my autonomous mode is now:
Code:
    robot_control(default_script);
After you set all of this up, you can easily add something to select which mode.
  #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.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
White Paper Discuss: Operator Interface - Userbyte Multiple Displays Variables marccenter Extra Discussion 0 02-12-2004 14:56
Multiple version of Inventor on one computer sanddrag Inventor 4 30-11-2004 13:31
Remember that thread? [11-11-04]: Multiple Regionals Ken Leung General Forum 5 11-11-2004 16:53
Multiple teams from one high school? KathieK General Forum 24 28-06-2004 16:30
Multiple Motors phrontist Motors 12 21-06-2004 23:05


All times are GMT -5. The time now is 22:29.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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