Nodegraph Editor: Difference between revisions

From RoboPad Wiki
Jump to navigation Jump to search
(Added link to controller page)
(→‎Example Nodegraphs: Links to examples.)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
[[File:Node Editor Screenshot.png|thumb|675x675px|The Nodegraph Editor page, displaying the default nodegraph (as of 2023-02-25, [[beta]] build).]]
[[File:Node Editor Screenshot.png|thumb|675x675px|The Nodegraph Editor page, displaying the default nodegraph (as of 2023-02-25, [[beta]] build).]]
At the core of the configurability of RoboPad is the Nodegraph Editor. It allows you to specify a control flow from the UI elements that make up your on-screen controller when in [[The Controller|controller mode]] all the way to the RoboPad itself. Every bit of processing that is performed on the node graph is performed on the device you are using to control the robot (usually a mobile phone), meaning that it has minimal impact on the robot's performance. Every time a node is updated - either by it's UI element moving (such as a joystick being moved or a button being pressed), it transmits that change out of it's output ports (golden rounded-squares on the left side of the node), and into the input ports (blue circles on the right side of the node) of any connected nodes. In this way, data can be transformed using different nodes before transmission to the robot itself. This lets you do things like configure different controllers on the screen, adding buttons to perform additional functions or process control signals in different ways.
At the core of the configurability of RoboPad is the Nodegraph Editor. It allows you to specify a control flow from the UI elements that make up your on-screen controller when in [[The Controller|controller mode]] all the way to the RoboPad itself. While the nodegraph itself is stored on the RoboPad, every bit of processing that is performed on the node graph is performed on the device you are using to control the robot (usually a mobile phone), meaning that it has minimal impact on the robot's performance. Every time a node is updated - either by it's UI element moving (such as a joystick being moved or a button being pressed), it transmits that change out of it's output ports (golden rounded-squares on the left side of the node), and into the input ports (blue circles on the right side of the node) of any connected nodes. In this way, data can be transformed using different nodes before transmission to the robot itself. This lets you do things like configure different controllers on the screen, adding buttons to perform additional functions or process control signals in different ways.


If you are looking to start exploring the nodegraph editor, you may want to start with the list of '''Node Catalogue''' or list of '''Example Nodegraphs''' below, once you have familiarised yourself with general usage of the nodegraph editor and the concepts of inter-node communication.
If you are looking to start exploring the nodegraph editor, you may want to start with the list of '''Node Catalogue''' or list of '''Example Nodegraphs''' below, once you have familiarised yourself with general usage of the nodegraph editor and the concepts of inter-node communication.
Line 60: Line 60:


== Example Nodegraphs ==
== Example Nodegraphs ==
Example nodegraphs coming soon...
The [[Example Robot Configurations|Example Robots page]] has some more in-depth worked examples of nodegraph usage.

Latest revision as of 22:14, 24 August 2024

The Nodegraph Editor page, displaying the default nodegraph (as of 2023-02-25, beta build).

At the core of the configurability of RoboPad is the Nodegraph Editor. It allows you to specify a control flow from the UI elements that make up your on-screen controller when in controller mode all the way to the RoboPad itself. While the nodegraph itself is stored on the RoboPad, every bit of processing that is performed on the node graph is performed on the device you are using to control the robot (usually a mobile phone), meaning that it has minimal impact on the robot's performance. Every time a node is updated - either by it's UI element moving (such as a joystick being moved or a button being pressed), it transmits that change out of it's output ports (golden rounded-squares on the left side of the node), and into the input ports (blue circles on the right side of the node) of any connected nodes. In this way, data can be transformed using different nodes before transmission to the robot itself. This lets you do things like configure different controllers on the screen, adding buttons to perform additional functions or process control signals in different ways.

If you are looking to start exploring the nodegraph editor, you may want to start with the list of Node Catalogue or list of Example Nodegraphs below, once you have familiarised yourself with general usage of the nodegraph editor and the concepts of inter-node communication.

General Usage

The Nodegraph Editor stage is fairly simple - the top-bar is where you'll find every button to handle things that effect the whole nodegraph. Here you can:

  • Save the Nodegraph, which will save the current nodegraph to the RoboPad, allowing it to be loaded when you open the controller.
  • Add a Node, which will spawn a new node of the type specified by the dropdown on the left to the top-left of the nodegraph editor stage.
  • Automatically adjust the UI, the "Auto UI" button will automatically arrange the UI elements on the controller following a simple pattern. This is useful if you wan to quickly iterate on controller UI designs. The new UI transform settings will be visible in each UI node's settings menu, meaning you can change them (or the nodegraph) to fine-tune the UI placement.

In order to change settings about individual nodes on the stage, you can use the three buttons at the bottom of each node. The clone and delete buttons allow you to copy (along with all configured settings) and delete the node, while the edit button opens each node's specific settings menu that allows you to configure that node's behaviour. On UI nodes, this will generally involve things like placement and physical behaviour of the UI element that the node describes, while on non-UI nodes these settings will control node behaviour. The only non-removable node is the Chip Node, which is a special node that represents the RoboPad itself. The input and output ports on the Chip Node are defined by the physical configuration of the RoboPad in the IO Config Editor.

Nodes can communicate with each other via signals over connections, which can be made by first clicking/tapping on either a port (the blue or gold shapes extending out of the side of each node) and then tapping on a port of the other colour on another node, linking them and allowing data to flow from one to the other.

Inter-Node Communication

Individual nodes can control a variety of processes and communicate with each other via the gold and blue ports on either side of them - rounded-square edges gold ports on the left of the node always output signals, emitting data away from the node, while circular light-blue ports on the right of the node consume signals. In the example below, signals flow from the right-hand side into the Chip Node, which then actuators the robot's M1 output. Every time the Slider is moved on the controller, it's signal is sent into the divide Math node (which has also previously been sent the signal "3" from the Number node), which computes the new value of a/b and the emits that value into M1 on the Chip Node. In this case, that has the effect of decreasing the sensitivity and maximum value of the slider by three.

Similarly, the Chip Node will emit a signal of "1" on the M1 armed output port whenever M1 becomes armed. In the example, we connect this signal to an Indicator, a UI element that will allow us to see that the motor is armed.

Control flow example.png

You'll notice that signals can be any numeric value - while most built-in UI elements and IO Units work within the range of zero to one, any value can be passed between the nodes. This can be very useful when you are trying to perform more complex behaviours within a nodegraph, however you should always know what values the input ports on the Chip Node (as defined by the IO Units currently configured) accept. Strange and difficult to debug behaviour may be the result of sending values to the Chip Node that it's not expecting. If in doubt, try adding an Indicator Node to the stage first before hooking anything up to the Chip Node and check that the values it's displaying are as expected as you use the UI elements on the screen. Once you've verified that, then you can start hooking up nodes to the Chip Node itself.

Node Catalogue

Here is a list of all nodes available to you while in the nodegraph editor, clicking on each will bring you to a page outlining it's function, behaviour and available settings. The list has been split into the groups found on the "Add Node" UI selector in the editor, with the addition of a link to the Chip Node.

Special Nodes

The chip node is in it's own category as it is solely configured through the IO Configuration Editor. It has a golden title region.

UI Element Nodes

The User Interface (UI) nodes almost all draw things to the controller, allowing you to actually interactively change values within the nodegraph. All UI nodes have a dark blue title region to separate them from other nodes.

  • Slider Node - Places a slider element (acting like a single-direction joystick on a traditional hand-held controller) on the controller either horizontally or vertically, allowing you to input a linear signal between 0 and 1.
  • Joystick Node - Places what is essentially a two-dimensional slider (acting like a bidirectional joystick on a traditional hand-held controller) on the controller that allows you to input a linear XY signal between 0 and 1 indicating the position of the stick within it's zone on the controller.
  • Button Node - Places a button on the controller, allowing you to send a signal into the nodegraph when it is pressed.
  • Indicator Node - Places a region on the controller that changes as a signal is sent to it; this is like an LED or indicator light on a traditional hand-held controller. You can also label and configure these indicators to show the value passed to them - very useful for debugging!
  • Gamepad Node - Does not place a UI element on the controller, but instead when the controller is running, searches the device for a connected gamepad, allowing you to use a physical input device to send signals to the nodegraph.

Signal Processing

Most nodes within the nodegraph deal with signals between 0 and 1, and signal processing nodes are designed to work with this in mind, providing basic manipulation steps that you might want to perform on nodegraph signals. Also found in this group are nodes that control signal flow through the nodegraph, allowing for things like signal delay or signal switching.

  • Joystick Mixer Node - Specifically designed to transform a signal pair (between 0 and 1) that encodes a joystick position (as is generated by the Joystick Node) into a dual-wheel drive signal, suitable for passing to Hbridge Motor IO Units.
  • Inverter Node - Inverts a signal about 0.5; 0 becomes 1, 0.2 becomes 0.8 ect.
  • Scaler Node - Scales a signal around 0.5 (by default).
  • Switch Node - Switches which input it uses as an output dependant on another value, think of it like a train track switch, allowing a node to selectively listen to signals emitted by one or another node.
  • Delay Node - Delays a signal by a set number of milliseconds. Useful for timed behaviour.

Computation

The nodes found here perform generic computational operations - anything that allows you to perform mathematical manipulations of signal data

  • Math Node - Performs basic mathematical operations on incoming signals.
  • Number Node - Used to generate a static numeric signal.

Custom Nodes

Two nodes are configured to allow for custom JavaScript, so that you can write fully customised nodes. Be aware, however, that the JavaScript you write for these is currently stored uncompressed on the RoboPad's internal memory store, which is quite limited. You can see how much of the internal memory is currently in use by checking in the Management Page. Note that updating the firmware can require a large chunk of internal memory to cache the update.

Example Nodegraphs

The Example Robots page has some more in-depth worked examples of nodegraph usage.