Stepdance Software Library
Loading...
Searching...
No Matches
PathLengthGenerator2D Class Reference

Used for generating an output proportional to the 2D path length traveled by two inputs. More...

#include <generators.hpp>

Inheritance diagram for PathLengthGenerator2D:

Public Member Functions

void begin ()
 Initialize the PathLengthGenerator2D. Must be called to set up the generator.
void set_ratio (ControlParameter ratio)
 Set the ratio between output distance and input path length.
void set_ratio (ControlParameter output_distance, ControlParameter input_distance)
void set_ratio_for_circle (ControlParameter circle_radius, ControlParameter output_per_revolution)
 Configure the generator for circular motion (e.g., from CircleGenerator). Sets the ratio so that the output advances by the specified distance per complete revolution.

Public Attributes

ControlParameter ratio = 1.0
 ControlParameter scaling output relative to input path length (output/input).
BlockPort input_1
 First input BlockPort (e.g., X position).
BlockPort input_2
 Second input BlockPort (e.g., Y position).
BlockPort output
 Output BlockPort proportional to 2D path length.
DecimalPosition input_1_position
DecimalPosition input_2_position
DecimalPosition output_position

Protected Member Functions

void run ()

Detailed Description

Used for generating an output proportional to the 2D path length traveled by two inputs.

PathLengthGenerator2D measures the incremental Euclidean distance traversed by two input signals and produces an output that is proportional to that path length by a configurable ratio. This is useful for applications like controlling extrusion rate of a 3D printer based on XY machine movement. Here's an example of how to instantiate and configure a PathLengthGenerator2D:

#define module_driver
#include "stepdance.hpp"
Channel channel_x;
Channel channel_y;
Channel channel_z;
OutputPort output_a
void setup(){
// Initialize OutputPort and enable drivers
output_p2.begin(OUTPUT_A);
enable_drivers();
// Initialize InputPort and map X/Y to path length inputs
input_a.begin(INPUT_A);
input_a.output_x.map(path2_gen.input_1);
input_a.output_y.map(path2_gen.input_2);
// Configure and begin generator
path2_gen.set_ratio(1.0);
path2_gen.begin();
// Map generator output to a channel
path2_gen.output.map(channel_p2.input_target_position);
channel_p2.begin(&output_p2, SIGNAL_E);
dance_start();
}
void loop(){
dance_loop();
}

Member Function Documentation

◆ set_ratio()

void PathLengthGenerator2D::set_ratio ( ControlParameter ratio)

Set the ratio between output distance and input path length.

Parameters
ratioThe proportionality constant (output / input).

◆ set_ratio_for_circle()

void PathLengthGenerator2D::set_ratio_for_circle ( ControlParameter circle_radius,
ControlParameter output_per_revolution )

Configure the generator for circular motion (e.g., from CircleGenerator). Sets the ratio so that the output advances by the specified distance per complete revolution.

Parameters
circle_radiusThe radius of the circle being traced by the inputs.
output_per_revolutionDistance the output should advance per full circle (e.g., 1.0 for 1mm per revolution).

For example, to move Z-axis 1mm for each complete circle of radius 10mm:

path_gen.set_ratio_for_circle(10.0, 1.0);

Member Data Documentation

◆ output

BlockPort PathLengthGenerator2D::output

Output BlockPort proportional to 2D path length.

xy_path.output.map(channelE.input_target_position); // Map to downstream target

The documentation for this class was generated from the following file: