Subject:
|
Programming the SPIRIT.OCX from VB (random #s?)
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Sun, 3 Jan 1999 01:38:53 GMT
|
Viewed:
|
1321 times
|
| |
| |
I thought my original question was fairly clear, but I guess not! I want to
program some "random" behaviors for my robot and download them into the RCX.
This being the case, I assume that I need to use the "random" register in the
RCX, as opposed to generating one inside VB.
Specifically, I want to program the robot to, for example, turn it's head
left and then right "X" times, where X = a random number between 1 and 5.
At other times, I'd like to tell the robot to go into "explore" mode for
anywhere from 10 to 250 seconds.
What is the best way to do this using SPIRIT.OCX commands?
Also, if anyone has any commented source code (for the Mindstorms RCX) I'd
love to see it!
Thanks for the replies.
-- John
Peter Hesketh wrote in message ...
> In article <000e01be369d$acc1cce0$53b0acc1@fam.-van-dam>, B van Dam
> <bvandam@westbrabant.net> writes
> > > What is the best way to get a random number using VB?
>
> If you really mean "How do I generate a random number within VB" then
> click "Help" in VB and search for random.
>
> If you mean "How can RCX code generate a random number" look at Kekoa's
> Opcodes Reference and search for random.
>
> If you mean "How can I convert a random number 1 to 32768 into a random
> number 5 to 25 using VB", then use:
>
> Random5to25 = 5 + 21 * int(( random1to32768 - 1 ) / 32768 )
>
> If you mean something else, please pose your question in a less
> ambiguous manner.
> --
> Regards - Peter Hesketh, Mynyddbach, Mon.
> Forty reasons why a dog is better than a woman: number 16
> "Dogs like it when you leave lots of things on the floor."
> --
> Did you check the web site first?: http://www.crynwr.com/lego-robotics
>
|
|
Message has 1 Reply: | | Re: Programming the SPIRIT.OCX from VB (random #s?)
|
| In article <F4yn8t.Gvx@lugnet.com>, John Cutter <lugnet.robotics@lugnet.com> writes [snip] (...) No problem. Spirit commands (answer in register 31): .setvar 31, 4, 4 'Get a random (source 4) number between 0 and 4 .sumvar 31, 2, 1 'Add constant 1 (...) (26 years ago, 3-Jan-99, to lugnet.robotics)
|
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
Active threads in Robotics
|
|
|
|