Used for generating position signals based on a target position and maximum velocity.
More...
#include <generators.hpp>
|
|
| PositionGenerator () |
| | Default constructor for PositionGenerator. Does not initialize the Generator. Call begin() to set up the generator.
|
|
void | begin () |
| | Initialize the PositionGenerator. Must be called to set up the generator.
|
| void | set_speed (ControlParameter speed) |
| | Set the speed (maximum velocity) for the PositionGenerator.
|
| void | go (float64_t distance_or_position, uint8_t mode) |
| | Command the PositionGenerator to move to a specified distance or position.
|
| void | go (float64_t distance_or_position, uint8_t mode, ControlParameter speed) |
| | Command the PositionGenerator to move to a specified distance or position with a specified speed.
|
Used for generating position signals based on a target position and maximum velocity.
A PositionGenerator maintains an internal position state and incrementally drives an output to reach a specified target position under the constraints of a maximum velocity. It is useful for generating smooth trajectories to an absolute or relative position. Position generators do not require an input signal, as they generate motion based on internal state and commands. Here's an example of how to instantiate and configure a PositionGenerator:
#define module_driver
#include "stepdance.hpp"
void setup() {
output_a.
begin(OUTPUT_A);
enable_drivers();
pos_gen.
output.
map(channel_a.input_target_position);
channel_a.
begin(&output_a, SIGNAL_E);
start_button.
begin(IO_D1);
dance_start();
}
void onButtonRelease() {
pos_gen.
go(100.0, ABSOLUTE);
}
void loop(){
dance_loop();
}
◆ go() [1/2]
| void PositionGenerator::go |
( |
float64_t | distance_or_position, |
|
|
uint8_t | mode ) |
Command the PositionGenerator to move to a specified distance or position.
- Parameters
-
| distance_or_position | The target distance (incremental) or position (absolute). |
| mode | The mode of operation: INCREMENTAL or ABSOLUTE. |
◆ go() [2/2]
| void PositionGenerator::go |
( |
float64_t | distance_or_position, |
|
|
uint8_t | mode, |
|
|
ControlParameter | speed ) |
Command the PositionGenerator to move to a specified distance or position with a specified speed.
- Parameters
-
| distance_or_position | The target distance (incremental) or position (absolute). |
| mode | The mode of operation: INCREMENTAL, ABSOLUTE, or GLOBAL |
| speed | The speed in units per second. |
◆ set_speed()
| void PositionGenerator::set_speed |
( |
ControlParameter | speed | ) |
|
Set the speed (maximum velocity) for the PositionGenerator.
- Parameters
-
| speed | The speed in units per second. |
◆ output
Output BlockPort for the PositionGenerator. This is what you map from to a downstream component.
position_gen.output.map(channelX.input_target_position);
The documentation for this class was generated from the following file: