Programming Tutorial
#1
Posted 10 December 2012 - 11:01 PM
Oops, I named this tutorial when it's more accurately just a reference guide of the programming parts I've found.
------------------------------
Input Sampler -
Description: This is the most basic programming block you'll be using within Rawbots. It allows you to take two keypresses, and outputs them as a number.
Inputs: Positive, Negative, Attack, Release
Output: Sample
Usage: The input sampler outputs between -1, and 1, and defaults to 0. By assigning positive and negative keypresses or inputs, you can increase or decrease the input samplers output. Attack (defaults to .5, I believe) is how fast the input sampler will increment or decrement. An attack of 5 will almost immediately cause it to jump up or down to 1, and -1. Whereas an attack of .1 will cause the input sampler to take forever to reach it's limits. Release (default .5) is how long the input sampler takes to reset to 0 when neither positive or negative is applied. If you assign Release to 0, the input sampler will never return to 0 and will stay on whatever output you leave it. Obviously, output is sample.
-----------------------------
Sample Mapper -
Description: The sample mapper is used (usually) in conjunction with the input sampler. Whereas the input sampler has a very limited range, the sample mapper has a customizable range. By taking the output of the input sampler, it can give it a far higher range than just the input sampler is capable of providing.
Inputs: Sample, Sample_Min, Sample_Max, Mapper_Min, Mapper_Max, Invert
Outputs: Mapped, Invert
Usage:
The input Sample takes in a number, and then increments the sample mapper variable (which is output by Mapped) by the input. So if you input 1, it will increment the sample mapper by 1, every X milliseconds, until it reaches the maximum limit. Likewise with -1, and lower limit.
The limits are determined by Mapper_Min, and Mapper_Max, as well as Sample_Min, and Sample_Max. Mapper_Min and Mapper_Max are the hard limits of the sample mapper variable. Whereas Sample_Min and Sample_Max augment those limits, by default, Sample_Min is -1, and Sample_Max is 1. What this means is without changing these variables, the default output of the sample mapper will be the average of mapper_min, and mapper_max.
EG: If you set mapper min to -4, and mapper max to 4, then by default, sample mapper will output 0. You can then increment and decrement it until it reaches it's limits. But, if you set min to 0, and max to 4, then the default will be 2. For most intents and purposes, I've found this to be annoying. The way to get around this is to set sample_min to 0, instead of it's default of -1. Then instead of calculating the average of mapper_min and mapper_max for the default output, the default output will be the mapper_min instead. This is possibly very confusing but I can't think of (right now) a better way to explain it.
The INPUT invert will take either TRUE or FALSE, and cause the Mapper output to invert. Whereas the OUTPUT invert will output the opposite of the mapper. The difference is subtle, one changes the mapper output, one adds a secondary output.
------------------------------
Proximeter
Description: Outputs the distance between Part A, and Part B.
Input: Part A, Part B
Output: Distance
Usage: To use it, bring up two parts software components in the editor (you can bring them both into the same screen by using Shift when clicking on them.) Then attach to the components the Part output. Input each part's output into either A or B or the Part input in Proximeter, and it will output the distance!
-----------------------------
Altimeter
Description: Outputs the the altitude of a part.
Input: Part
Output: Altitude
Usage: Simply outputs the altitude of that singular part.
Example Usage: Create two altimeters, and input to them the front and back of your vehicle's parts respectively. With a little math, you can tell the difference between the heights of the two parts, and know whether you're pitching straight, up or down.
-----------------------
Toggle
Description: Changes the output between two numbers
Input: Sample_A, Sample_B (alternatively, color or part), Selector
Output: Sample/Color/Part
Usage: When Selector receives a value above .5, it's output will toggle between Sample A, and Sample B
Example Usage: Create an input sampler, set it's positive to whatever you want, it's attack to 10, and it's release to 10. Create a toggle, make it's sample_a to be 0, and it's sample_b to be 1. Output the sampler into the selector input, then output the toggle's sample into motors, or an input mapper connected to motors. Tada, you have yourself an auto-run button.
----------------------
Multiplexer
Description: Subtly different from the toggle.
Input: Sample_A, Sample_B (alternatively, color or part), Selector
Output: Sample/Color/Part
Usage: The multiplexer effectively works like a toggle, except it outputs A when the input is less than .5, and B when the input is greater than .5. Whereas the toggle triggers on getting a 1 signal.
---------------------
#2
Posted 10 December 2012 - 11:46 PM
#3
Posted 10 December 2012 - 11:51 PM
Input Sampler - Positve = U, Attack = 100, Release = 100, Outputs into Toggle. Toggles Sample A = 0, Toggles Sample B = 1 or whatever. Connect the toggles output to whatever you want. Then whenever you press U, if toggle is currently 0, it'll switch to 1. If it's 1, it'll switch to 0.
But I haven't got past the bridge with the passcode yet, so I couldn't confirm for sure.
#4
Posted 11 December 2012 - 12:02 AM
#5
Posted 11 December 2012 - 01:10 AM
rozgo: elf, definitely elf
Never trust an elf!
#6
Posted 11 December 2012 - 01:38 AM
Edit: Oh, here's the fun story. So a couple weeks ago, I'm playing modded minecraft, and I keep running into issues with java, because I'm on a 32 bit operating system, and java hates me. So I decide, on a whim. I'm going to install and dual boot Ubuntu (linux). Well during that process, which should have taken 30 minutes, but because of my specific hardware and laptop, it took eight hours. And when I was done, I realized I had borked windows, without a restore disk nearby. Sad me is sad. Tried everything I could over that two weeks, nodda.
*sigh* So I had to use my boyfriends far inferior computer to play rawbots when it came out yesterday. I was chugging at like 7FPS. Well, luck behold, just through magic and me being bored, I got my windows os to boot up. Yay. Rawbots still runs like a fat lazy cat chasing a mouse, but it runs. So I should be upping and fleshing out with pictures for the reference at some point.
#7
Posted 12 December 2012 - 04:34 AM
#8
Posted 12 December 2012 - 04:46 AM
rozgo: elf, definitely elf
Never trust an elf!
#9
Posted 12 December 2012 - 04:53 AM
#10
Posted 12 December 2012 - 06:25 AM
#11
Posted 12 December 2012 - 11:45 AM
Controller
Description: PID controller
Inputs: >SetPoint, >Feedback, >kp, >ki, >kd
Output: <Control
Usage:
...they just might work.
#12
Posted 12 December 2012 - 12:01 PM
EG: If you set mapper min to -4, and mapper max to 4, then by default, sample mapper will output 0. You can then increment and decrement it until it reaches it's limits. But, if you set min to 0, and max to 4, then the default will be 2. For most intents and purposes, I've found this to be annoying. The way to get around this is to set sample_min to 0, instead of it's default of -1. Then instead of calculating the average of mapper_min and mapper_max for the default output, the default output will be the mapper_min instead. This is possibly very confusing but I can't think of (right now) a better way to explain it.
The input sampler, the way I see it, is making a linear regression between 2 points, (x1,y1) (sample_min,mapped_min), (x2,y2) (sample_max, mapped_max).
If its sample (input) is consuming from an input_sampler, it will send by default 0, setting the mapped value to whatever the (x = 0) would in the regression.
#13
Posted 15 December 2012 - 01:02 AM
- Mel
#14
Posted 15 December 2012 - 01:07 AM
rozgo: elf, definitely elf
Never trust an elf!
#15
Posted 15 December 2012 - 09:36 AM
Alrighy. Unfortunately, because of how I scheduled my vacation, and how late rawbots released, starting from sunday, I won't be around for 11-ish days. So I won't be able to do any of my tutorial stuff until then.
- Mel
We'll be here with more features, have fun
____________________________
Life's a bitch... with puppies
#16
Posted 15 December 2012 - 10:55 AM
#17
Posted 15 December 2012 - 07:47 PM
can someone make a tutorial for how to controll a elbow with your keyboard because I can't get that to work :/
I'll do one quickly once I've made a video for my bomb pod. It'll be posted in Getting Started once it's done
rozgo: elf, definitely elf
Never trust an elf!
#18
Posted 16 December 2012 - 01:40 PM
#19
Posted 16 December 2012 - 03:27 PM
Connectivity
Anyone figured out how to use it?
just messed around with it, it tells whether 2 parts are directly connected. Heres a quick psuedo-code to explain what I mean
if (part_a.isConnected(part_<img src='http://www.rawbots.net/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' />) then {
output 1;
} else
output 0;
}
Edit: you could use it in a system similar to my lock (from the video stock lock and a yellow block) where you replace the proximeters I used with conectivity operands
rozgo: elf, definitely elf
Never trust an elf!
Sign In
Create Account

Back to top


