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

Used for generating circular motion signals. More...

#include <generators.hpp>

Inheritance diagram for CircleGenerator:

Public Member Functions

void begin ()
 Initialize the CircleGenerator. Must be called to set up the generator.
void setNoInput ()
 Use internal frame count for phase instead of an input signal. This will allow the circle generator to update automatically based on frame rate. When enabled, input is ignored.
void debugPrint ()
 Print debug information about the CircleGenerator to the Serial console.

Public Attributes

volatile ControlParameter radius = 1.0
 ControlParameter for the circle radius. You can set it directly or map an input to it.
volatile ControlParameter rotational_speed_rev_per_sec = 6
 ControlParameter for the rotational speed, in revolutions per second. You can set it directly or map an input to it.
BlockPort input
 Optional input BlockPort (phase). If setNoInput() is called, this input is ignored.
BlockPort output_x
 Output BlockPort for X component of the circular path.
BlockPort output_y
 Output BlockPort for Y component of the circular path.

Protected Member Functions

void run ()

Protected Attributes

volatile float64_t current_angle_rad = 0
volatile float64_t delta = 0

Detailed Description

Used for generating circular motion signals.

A CircleGenerator produces a motion signal that traverses a circle defined by a radius and a rotational speed. It can be driven by an input signal (phase) or run autonomously using the internal frame count when setNoInput() is called. The two outputs, output_x and output_y, provide the Cartesian components of the circle. Here's an example of how to instantiate and configure a CircleGenerator:

// Example of using CircleGenerator to create circular motion in X-Y plane (assuming an Cartesian X-Y mechanism)
#define module_driver
#include "stepdance.hpp"
CircleGenerator circle_gen;
Channel channel_x;
Channel channel_y;
OutputPort output_x;
OutputPort output_y;
void setup(){
// Initialize OutputPort and enable drivers
output_x.begin(OUTPUT_A);
output_y.begin(OUTPUT_B);
enable_drivers();
// Configure circle generator to run without input
circle_gen.setNoInput();
circle_gen.radius = 10.0; // example radius in units
circle_gen.rotational_speed_rev_per_sec = 0.5; // example frequency in rev/s
circle_gen.begin();
// Map generator outputs to two channels (X and Y)
circle_gen.output_x.map(channel_x.input_target_position);
circle_gen.output_y.map(channel_y.input_target_position);
channel_x.begin(&output_x, SIGNAL_E);
channel_y.begin(&output_y, SIGNAL_E);
dance_start();
}
void loop(){
dance_loop();
}

Member Data Documentation

◆ input

BlockPort CircleGenerator::input

Optional input BlockPort (phase). If setNoInput() is called, this input is ignored.

input_a.output_x.map(circle.input); // Map a phase signal to CircleGenerator input

◆ output_x

BlockPort CircleGenerator::output_x

Output BlockPort for X component of the circular path.

circle.output_x.map(channelX.input_target_position); // Map X output to X-axis channel

◆ output_y

BlockPort CircleGenerator::output_y

Output BlockPort for Y component of the circular path.

circle.output_y.map(channelY.input_target_position); // Map Y output to Y-axis channel

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