|
Stepdance Software Library
|
BlockPorts provide a unified interface for mapping inputs and outputs of different StepDance components (E.g. Channels, Kinematics, Generators, etc) More...
#include <core.hpp>
Public Member Functions | |
| BlockPort () | |
| Default constructor for BlockPort. Initializes a BlockPort instance. You do not need to call this directly; BlockPorts are typically members of other components and are automatically initialized when the component is initialized. | |
| void | set_ratio (float world_units, float block_units=1.0) |
| Sets the ratio between world units and block units for this BlockPort for automatic conversion. Default is 1:1. For example if ou want the BlockPort to transmit data in millimeters corresponding to a single step, you would set the ratio to 0.01 world units to 1 block_units (i.e. 1 step = 0.01mm). | |
| void | map (BlockPort *map_target, uint8_t mode) |
| Maps this BlockPort to a target BlockPort with a specified mode (INCREMENTAL or ABSOLUTE). | |
| void | map (BlockPort *map_target) |
| float64_t | read (uint8_t mode) |
| Returns the position value of the BlockPort in world units. Reading in INCREMENTAL mode returns the change to the position since the last read or update; reading in ABSOLUTE mode returns the absolute position value. | |
| float64_t | read_absolute () |
| Returns the absolute position value of the BlockPort in world units. | |
BlockPorts provide a unified interface for mapping inputs and outputs of different StepDance components (E.g. Channels, Kinematics, Generators, etc)
BlockPorts manage push and pull of data between components automatically through the map() method, which when called assigns a target to the BlockPort. Each BlockPort has an internal position value. On each interrupt frame a component reads its input BlockPorts' position, performs internal calculations specific to the component, and then stores the result in its output BlockPorts' position. The component then calls BlockPort.push() for each output BlockPort which transmits the position value to the mapped target BlockPort. However BlockPorts can only have one target of their map function. To get around this you can also have BlockPort Inputs pull from multiple other BlockPorts by mapping an input BlockPort to either an input or an output. The Component will first call BlockPort.pull() on its input BlockPorts to retrieve the latest values from all mapped BlockPorts, then perform its internal calculations, and finally call BlockPort.push() on its output BlockPorts to transmit the results.
You will never instantiate a BlockPort directly; instead, you can access the BlockPorts that are members of different components. The example below shows how to access and map an InputPort's BlockPort to a Channel's input target position BlockPort.
| void BlockPort::map | ( | BlockPort * | map_target, |
| uint8_t | mode ) |
| float64_t BlockPort::read | ( | uint8_t | mode | ) |
Returns the position value of the BlockPort in world units. Reading in INCREMENTAL mode returns the change to the position since the last read or update; reading in ABSOLUTE mode returns the absolute position value.
| mode | Mode of operation: INCREMENTAL or ABSOLUTE. |
| void BlockPort::set_ratio | ( | float | world_units, |
| float | block_units = 1.0 ) |
Sets the ratio between world units and block units for this BlockPort for automatic conversion. Default is 1:1. For example if ou want the BlockPort to transmit data in millimeters corresponding to a single step, you would set the ratio to 0.01 world units to 1 block_units (i.e. 1 step = 0.01mm).
| world_units | Number of world units. |
| block_units | Number of block units. Default is 1. |