Go to Post Use sensors to collect data about the surrounding environment, then discard it and drive into walls. - Jared Russell [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 09-02-2003, 06:14
Steven Carmain Steven Carmain is offline
Bit Twiddler
FRC #2832
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Westland, MI
Posts: 93
Steven Carmain will become famous soon enough
Aliases

Can you make a temp variable, give it like 4 aliases and use anyone of them? This may be very effective if you use put and get statements because of our variable space.
__________________
2017 - Team 2832 Mentor
2016 - Team 6013 Mentor
2002-05 - Team 45 Software/Electrical

A robot is like a campfire: it takes a while to bulid it, and then everyone surounds it!
A world without standards is chaos. A world with standards is chaos.
  #2   Spotlight this post!  
Unread 09-02-2003, 09:09
Unsung FIRST Hero
Nate Smith Nate Smith is offline
FRC Key Volunteer Trainer
AKA: CrazyNate
no team
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Old Town, Maine
Posts: 1,029
Nate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to behold
Send a message via AIM to Nate Smith Send a message via Yahoo to Nate Smith
I haven't seen anything that would keep you from doing this...
__________________
Nate Smith
nsmith@smythsoft.com
12 seasons, 4 teams, and more time logged behind the scorekeeper's table than I care to remember...
returning for 2011? only time will tell...
  #3   Spotlight this post!  
Unread 09-02-2003, 14:56
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Re: Aliases

Quote:
Originally posted by Steven Carmain
Can you make a temp variable, give it like 4 aliases and use anyone of them? This may be very effective if you use put and get statements because of our variable space.
We've done exactly this the last few years.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
  #4   Spotlight this post!  
Unread 10-02-2003, 06:59
Gobiner Gobiner is offline
Registered User
#0753 (High Desert Droids)
 
Join Date: Nov 2002
Location: Bend, Oregon
Posts: 54
Gobiner is an unknown quantity at this point
Send a message via ICQ to Gobiner Send a message via AIM to Gobiner
The way I understand it, you can use as many aliases as you want because all the variables are turned into memory addresses when tokenized.
__________________
0N3 1337 PR0G|24MM1N6 N1NJ4
  #5   Spotlight this post!  
Unread 10-02-2003, 07:22
rust710's Avatar
rust710 rust710 is offline
Registered User
#0862 (Lightning Robotics)
 
Join Date: Dec 2002
Location: Canton, MI
Posts: 103
rust710 is an unknown quantity at this point
Send a message via AIM to rust710
When a varable is aliased is the value the same for all aliased names?
__________________
Andrew Radamis
Programmer on 862
info@lightingrobotics.com
  #6   Spotlight this post!  
Unread 10-02-2003, 08:57
Jeff Waegelin's Avatar
Jeff Waegelin Jeff Waegelin is offline
El Jefe de 148
AKA: Midwest Refugee
FRC #0148 (Robowranglers)
Team Role: Engineer
 
Join Date: Aug 2001
Rookie Year: 2001
Location: Greenville, TX
Posts: 3,132
Jeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond repute
Quote:
Originally posted by rust710
When a varable is aliased is the value the same for all aliased names?
Yes. All aliases for a given variable have the same value. When the code is tokenized, all aliases point to the same spot in memory, so they are essentially the same variable.
__________________
Jeff Waegelin
Mechanical Engineer, Innovation First Labs
Lead Engineer, Team 148 - The Robowranglers
  #7   Spotlight this post!  
Unread 11-02-2003, 00:42
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
Question sooo....

so then why alias a variablle to different names? if they all equal the same thing, why not just use the same one again and again, it would save code and space. Is it just for ease and readability?

-Kesich
__________________
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 11-02-2003, 01:07
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Re: sooo....

Quote:
Originally posted by Anthony Kesich
so then why alias a variablle to different names? if they all equal the same thing, why not just use the same one again and again, it would save code and space. Is it just for ease and readability?

-Kesich
That's the main reason. The other reason is if you want to access smaller portions of a variable. For example, relay1_fwd is an alias of the relayA variable, but only points to one bit inside it.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #9   Spotlight this post!  
Unread 11-02-2003, 02:11
Jnadke Jnadke is offline
Go Badgers!
#0093
Team Role: Alumni
 
Join Date: Jan 2002
Location: Appleton, WI
Posts: 775
Jnadke is on a distinguished road
Send a message via ICQ to Jnadke Send a message via AIM to Jnadke Send a message via Yahoo to Jnadke
Re: sooo....

Quote:
Originally posted by Anthony Kesich
Is it just for ease and readability?

-Kesich

Bingo. When your robot breaks down next year and you urgently need it to do a demonstration to get some team funds, you'll want to know what the heck you were thinking when you wrote the code.


I always use the default names for the SERIN so I know what's being input, then I alias them for my code so that I know what I'm doing. It helps the train of thought because then you can read it more like a sentence.
__________________
The best moments of our lives fall in two categories: those that did happen and those that did not.
  #10   Spotlight this post!  
Unread 11-02-2003, 14:36
Mike Soukup's Avatar
Mike Soukup Mike Soukup is offline
Software guy
FRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Schaumburg, IL
Posts: 797
Mike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond repute
Re: sooo....

Quote:
Originally posted by Anthony Kesich
so then why alias a variablle to different names? if they all equal the same thing, why not just use the same one again and again, it would save code and space. Is it just for ease and readability?
You don't lose any program space when you alias variables. When the code is compiled (or tokenized if you prefer) all the names are converted to memory addresses. The processor has no idea that you've created aliases. All it gets is a command to fetch some data from a memory location.

Besides code readability, a reason to use aliases the way Jnadke said is to quickly change the input mapping. If you want to switch your drive stick to port 2 instead of port 1 and you don't have any aliases, you have to change all the occurrances of p1_x and p1_y to p2_x and p2_y respectively. If you use aliases such as drive_stick_x and drive_stick_y, all you have to do is change the alias in one place and you're done.

You should do the same for your outputs as well. Or you can write your motor output speeds to scratchpad RAM locations (such as s_left_drive_speed) and then fetch your speed to the correct pwm variable right before the Serout.

Those are just a few tricks to make changing input & output mappings less of a headache.
  #11   Spotlight this post!  
Unread 11-02-2003, 22:23
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
Lightbulb uhhuh

ahh i see...., so it makes it much easier. (you'll have to excuse me, im a rookie programmer, err the only programmer on a rookie team, and ive taught myself all of the code, so i have learned to question EVERYTHING)

-Kesich

P.S. I've had that problem many times before, changing ports that is, and i find it to be a pain in th neeck, expecially when you miss ONE of them and it destroys the entire operation.
__________________
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
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


All times are GMT -5. The time now is 04:00.

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