Jump to content

Photo

Programming Tutorial

* * * * * 2 votes

  • Please log in to reply
20 replies to this topic

#1
Kalapixie

Kalapixie
  • VIP Passport
  • 28 posts
Hi, this is just a reference manual I've created for all of the various programming blocks and some usage scenarios for them. I haven't gotten passed much the elbow part, so I can't help further than that. As well, my main computer went kaput, so I am unable to provide video tutorials or pictures until around january.

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
kira321

kira321
  • VIP Passport
  • 305 posts
  • LocationMelbourne Florida
So if I wanted to toggle, lets say a bridge I'd add both sample and part?
The Uniforms of the Imperial Guard are camouflaged in order to protect their wearers by hiding them from sight. The principle is that what the enemy cannot see he cannot kill. This is not the way of the Adeptus Astartes. A Space Marine’s armour is bright with heraldry that proclaims his devotion to his Chapter and the beloved Emperor of Mankind. Our principle is that what the enemy can see, he will soon learn to fear… -ChaplainAston,Fire Hawks10th Company.

#3
Kalapixie

Kalapixie
  • VIP Passport
  • 28 posts
Assuming it's the bridge in the beggining with the power bit. What you would do is set the toggle up with a sample as described above, and then output the toggles Sample to the bridges power bit.

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
kira321

kira321
  • VIP Passport
  • 305 posts
  • LocationMelbourne Florida
The passcode does pose a problem ... It's four numbers...hmmm I wonder...and got it. Who née help cracking the code?
The Uniforms of the Imperial Guard are camouflaged in order to protect their wearers by hiding them from sight. The principle is that what the enemy cannot see he cannot kill. This is not the way of the Adeptus Astartes. A Space Marine’s armour is bright with heraldry that proclaims his devotion to his Chapter and the beloved Emperor of Mankind. Our principle is that what the enemy can see, he will soon learn to fear… -ChaplainAston,Fire Hawks10th Company.

#5
Xyceres

Xyceres
  • VIP Passport
  • 267 posts
  • LocationVictoria, Australia
I just spent hours trying to make a switch like thing using logic gates and now you tell me selector does exactly that with next to no issues. I'm slightly annoyed i couldn't work out what that command did now.
Squish: Hello rozgo, would you like to confirm or deny rumours that you are a duck and/or an elf
rozgo: elf, definitely elf

Never trust an elf!

#6
Kalapixie

Kalapixie
  • VIP Passport
  • 28 posts
Woot, I got my main computer working. Yaaay me. So I should be able to continue, assuming save doesn't bugger up.

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
kira321

kira321
  • VIP Passport
  • 305 posts
  • LocationMelbourne Florida
alright this be a programming question. :P How do i get multipul parts into one programming screen?
The Uniforms of the Imperial Guard are camouflaged in order to protect their wearers by hiding them from sight. The principle is that what the enemy cannot see he cannot kill. This is not the way of the Adeptus Astartes. A Space Marine’s armour is bright with heraldry that proclaims his devotion to his Chapter and the beloved Emperor of Mankind. Our principle is that what the enemy can see, he will soon learn to fear… -ChaplainAston,Fire Hawks10th Company.

#8
Xyceres

Xyceres
  • VIP Passport
  • 267 posts
  • LocationVictoria, Australia
Hold shift as you click the part (worked it out earlier today)
Squish: Hello rozgo, would you like to confirm or deny rumours that you are a duck and/or an elf
rozgo: elf, definitely elf

Never trust an elf!

#9
kira321

kira321
  • VIP Passport
  • 305 posts
  • LocationMelbourne Florida
ah ok thank you :) makes it much easier to program the hover parts and plasma canons.
The Uniforms of the Imperial Guard are camouflaged in order to protect their wearers by hiding them from sight. The principle is that what the enemy cannot see he cannot kill. This is not the way of the Adeptus Astartes. A Space Marine’s armour is bright with heraldry that proclaims his devotion to his Chapter and the beloved Emperor of Mankind. Our principle is that what the enemy can see, he will soon learn to fear… -ChaplainAston,Fire Hawks10th Company.

#10
Wardog

Wardog
  • VIP Passport
  • 456 posts
  • LocationTasmania
  • Badges:Mazinger Badge
ty :)

Shazam.gif


#11
Magma

Magma
  • VIP Passport
  • 169 posts
  • LocationUnder a rock, behind 7 proxies
not sure if incomplete entries are allowed but here's something, now if i only knew how to use it...

Controller
Description: PID controller
Inputs: >SetPoint, >Feedback, >kp, >ki, >kd
Output: <Control
Usage:
Always come up with crazy ideas...
...they just might work.

#12
rbf192

rbf192
  • Members
  • 56 posts
  • LocationOn my MTB at the top of a mountain.

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
Kalapixie

Kalapixie
  • VIP Passport
  • 28 posts
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

#14
Xyceres

Xyceres
  • VIP Passport
  • 267 posts
  • LocationVictoria, Australia
anyone else noticed some oddities when you set the sample_min/max then stray from those bounds (things like the output resetting instead of continuing to extrapolate).
Squish: Hello rozgo, would you like to confirm or deny rumours that you are a duck and/or an elf
rozgo: elf, definitely elf

Never trust an elf!

#15
javehdez

javehdez

    Cutthroat Jerk

  • Administrators
  • 108 posts
  • LocationTeslight, Main Core Facility.
  • Badges:Programmer

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
Rackzo

Rackzo

    Dev Hunter & Forum Police

  • Moderators
  • 386 posts
  • LocationIn a galaxy, far far away, where physics don't always work 100% of the time
can someone make a tutorial for how to controll a elbow with your keyboard because I can't get that to work :/

"You can't spell pacifist without fist, which always leads to violence!"

 

Also called Dr. Skåning on steam


#17
Xyceres

Xyceres
  • VIP Passport
  • 267 posts
  • LocationVictoria, Australia

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
Squish: Hello rozgo, would you like to confirm or deny rumours that you are a duck and/or an elf
rozgo: elf, definitely elf

Never trust an elf!

#18
ThunderPants

ThunderPants
  • VIP Passport
  • 53 posts
Connectivity


Anyone figured out how to use it?

#19
Xyceres

Xyceres
  • VIP Passport
  • 267 posts
  • LocationVictoria, Australia

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
Squish: Hello rozgo, would you like to confirm or deny rumours that you are a duck and/or an elf
rozgo: elf, definitely elf

Never trust an elf!

#20
GrepaEmperor

GrepaEmperor
  • VIP Passport
  • 3 posts

can someone make a tutorial for how to controll a elbow with your keyboard because I can't get that to work :/

lol, it's 95% the same as a wheel