Go to Post We talked to a team in Las Vegas and next year there will be another team with a 25 drive train. The west coast may never be the same. - nuggetsyl [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 30-01-2003, 09:56
Jonbca Jonbca is offline
Registered User
#1084
 
Join Date: Jan 2003
Location: Sarnia
Posts: 9
Jonbca is an unknown quantity at this point
Exponenets and floats

I'm working on doing some different things to help and increase the amout of control that we have over the robotwhile driving. What We're setting up is a expodential curve istead of the linear one setup by default. what we're looking at is something like this:

p1_y = 73 * ((1.06526 ^ p1_y - 1) / 100)

This will basically give me a persentage of 73. Can I do this, or is not possible(with the decimal numbers) or does pBasic allow this? Also, is there a default command for doing exponents? Thanks a lot
__________________
I can imagine a world without hate, a world without fear, a world without war. And I can imagine us attacking that world, because they would never expect it.
  #2   Spotlight this post!  
Unread 30-01-2003, 10:09
Jeff_Rice's Avatar
Jeff_Rice Jeff_Rice is offline
ElementisRegamusProelium
#1359
Team Role: Programmer
 
Join Date: Dec 2002
Location: Linn County
Posts: 283
Jeff_Rice will become famous soon enoughJeff_Rice will become famous soon enough
The secret is to think of the joystick as a graph, and define what you want the output to be depending on the number. I did this, and now our controls vary with the square. But be forewarned. Doing this can cause very weird and hard to squash bugs. When I first did it I bumped the joystick and the robot attacked a few nearby 55 gallon drums(edit: I forgot to mention now it works). You will end up using four if then statements. (hint one for each quadrant).
__________________
"He said my name is Private Andrew Malone
If you're reading this then I didn't make it home
But for every dream that's shattered another one comes true
This car was once a dream of mine now it belongs to you
And though you may take her and make her your own
You'll always be riding with Private Malone" David Ball, "Private Malone"
  #3   Spotlight this post!  
Unread 30-01-2003, 10:27
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,562
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
There are several things wrong here.

First of all is your formula. 1.0625^254 is 10222. Taking into account the rest of your formula, you are still nowhere near a range of 0 to 254.

Second, even if your formula did work mathematically, it uses floating point numbers, which the basic stamp doesn't support. It also uses an exponent, which you would have write code to support, because the stamp doesn't.

It is much easier (and probably faster) to figure out your algorithm (and test it using excel or another tool), and then implement it in a lookup table then to try to convert your algorithm to valid pbasic code.

PS, I like the choice of your scaling constant ;-)
  #4   Spotlight this post!  
Unread 30-01-2003, 13:08
Jonbca Jonbca is offline
Registered User
#1084
 
Join Date: Jan 2003
Location: Sarnia
Posts: 9
Jonbca is an unknown quantity at this point
Thoanks for the tips, I've ended up using a square. Just to let you know what I wa working on for the exponents thing, it was this:

SELECT p1_y
CASE 127 to 200 ' 73 unit range
p1_y = p1_y - 127
p1_y = 73 * ((1.06526 ^ p1_y - 1) / 100) 'gives a percentage of 73
' this is done for all sections giving it a smoother movement
CASE 200 to 254
...
ENDSELECT
__________________
I can imagine a world without hate, a world without fear, a world without war. And I can imagine us attacking that world, because they would never expect it.
  #5   Spotlight this post!  
Unread 31-01-2003, 08:28
Ryan Meador Ryan Meador is offline
Registered User
#0190
Team Role: Electrical
 
Join Date: Jan 2002
Rookie Year: 1999
Location: Worcester, NH
Posts: 68
Ryan Meador will become famous soon enough
I've done nearly exactly what you're suggesting in PBASIC before. I just plugged some joystick values into my TI-89 (and 83 would be more than sufficient, however) in one list, the expected output into another list, and did a regression. Just put the regression curve into the code and you're all set. Make sure both your domain and range are [0, 254].
__________________
-Ryan

"You're not a real programmer until you end all your sentences with semicolons;"
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 20:26.

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