Go to Post Don't forget the robot, the most important hardware there is!:p - artK [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 20-02-2005, 00:55
Vincent Chan's Avatar
Vincent Chan Vincent Chan is offline
the Friendly Team Asian
#1127 (Lotus Robotics)
Team Role: Student
 
Join Date: Feb 2003
Location: Alpharetta, GA
Posts: 125
Vincent Chan is on a distinguished road
Send a message via AIM to Vincent Chan
C: Cascading for Aliases?

I'm the interim programmer for our team, and I'm trying to write some dead-reckoning code for the robot. I've currently got all my dead-reckoning strategies written in a .h file as an array of command type structures, much like the demo gyro code, but I need to be able to switch between them.

We're using a DIP switch to choose the strategy we want, and I was wondering if I could use an array variable of command type structures in my functions that is aliased via a cascading-if in my code. (It would look something like this

Code:
command struct command_list[];
if(dipswitch == 0)
      command_list[] = strat1_list[]; //strat1_list[] is defined in an included h file
else if(dipswitch == 1)
      command_list[] = strat2_list[];
and so on and so forth, with a method calling it like this:

Code:
int move_forward(void)
{
     end_time = command_list[current_command].parm_1;
     if(curr_time > end_time)
            rc = 1;
     else
            rc = 0;
}
(So that you can understand what's going on, end_time would be the time at which you stop moving forward, and curr_time would count millisecs since the match began. You would grab the parameter that end_time is set to from a command type structure out of an array of those structs. command_list[] is that array and current_command is a variable that increments as commands are completed.)

Our mentor wasn't sure whether the aliasing of arrays was legal in C, though it seems like it should be, and I need to change a pretty sizeable chunk of code to find out. Anyone have any ideas?
__________________
Lotus Robotics, Team #1127

"So everybody's got ideas. Ideas are cheap. What's unique is the conviction to follow through: to work at it until it pays off. That's what separates the person who thinks I wonder why they can't just make shampoo and conditioner in one? from the one who thinks Now, should I get the Mercedes, or another BMW?"
--Scat, in Syrup by Maxx Barry
 


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
switching modes Allison Programming 8 06-04-2004 13:37
Switching allys? archiver 1999 1 23-06-2002 22:34
Team 45 Dual Motor Gear Switching Assembly WorkThoseBuns Motors 1 20-03-2002 19:27
switching joystick axis????? team222badbrad Technical Discussion 9 16-01-2002 23:07
[white paper] Dual Motor Gear Switching Assy Brandon Martus Motors 0 29-06-2001 12:56


All times are GMT -5. The time now is 20: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