The Keyboard module provides a way to interface key strokes (from your keyboard) to change specific variables within RoboRealm. For example, using this module you can assign that when F1 is pressed the variable left_motor is set to 0 and when F2 is pressed that same variable will be set to 255. This is a nice way to add options within your program to perform different behviours without needing to load other programs or reconfigure interfaces.

The key to interfacing with control elements (like motors, servos, etc.) within RoboRealm are via variables. If you change a variable that is used within one of the control interfaces that maps to a servo you are in effect controlling that servo. Thus, by changing a variables value you can change the behavior of a servo, usb missile launcher, pan/tilt camera, etc.

The Keyboard module is also a good replacement for the Joystick or Mouse interface modules.



1. To create a new key/variable combination click on the Add button. This will create a new default key/variable mapping. Use the interface items on the left side of the interface to change the properties of the current mapping.
2. Key - the keypress you want to use
3. Modifier - select if one of the modifier keys should be used (SHIFT, ALT, CTRL, WIND) in combination with the selected key.
4. Variable - the variable you want modified when the above key is pressed.
5. Action - how the variable should be modified when the above key is pressed.

Set - the value is assigned to or overwrites the above variable.

Add - the value is added to the current value of the variable

Subtract - the value is subtracted from the current value of the variable

Or - the value is bitwise ORed with the current value of the variable

And - the value is bitwise ANDed with the current value of the variable

Xor - the value is bitwise XORed with the current value of the variable

6. Value - the value either assigned to the variable or combined with the variable based on the action selected above.
7. Min - the minimum value the variable can be reduced to.
8. Max - the maximum value the variable can be increased to.
9. Set on Release - if selected this will cuase the variable's value to be set to the value below once the key has been released. This is useful if you need to terminate an action based on a variable when the user releases a key. The default (off) will not alter the variables value once the user has released the key.
10. Continue to edit, add and delete key/variable combinations by selecting them in the right hand side list and pressing delete to remove the currently selected combination or by using the left hand side controls to change values.


The interface above shows the configuration need to change a left_motor and right_motor variables based on the cursor keys. Note that selecting CTRL while using the cursor keys will change the values quicker than without.

Try this configuration yourself. Click on this link and RoboRealm will start running the above configuration. Edit (or double click on) the Watch_Variables module in the processing pipeline to see the left_motor and right_motor variables change when you either cursor left or cursor right. To complete the example you will need to attach those variables to another control module. That part of the exercise if left up to you.

See Also


 New Post 

Keyboard Related Forum PostsLast postPostsViews