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

KinematicsPolarToCartesian converts polar coordinates (radius and angle) to Cartesian coordinates (X and Y). More...

#include <kinematics.hpp>

Inheritance diagram for KinematicsPolarToCartesian:

Public Member Functions

void begin (float64_t fixed_radius=0)
 Initializes the KinematicsPolarToCartesian with an optional fixed radius. If a fixed radius is provided, the radius input BlockPort will be ignored.

Public Attributes

BlockPort input_radius
 Input BlockPort for radius (r) in polar coordinates. Ignored if a fixed radius is set in begin(). Map upstream components to this port.
BlockPort input_angle
 Input BlockPort for angle (theta) in polar coordinates. Map upstream components to this port.
BlockPort output_x
 Output BlockPort for X axis motion. Map downstream components to this port.
BlockPort output_y
 Output BlockPort for Y axis motion. Map downstream components to this port.

Protected Member Functions

void run ()

Detailed Description

KinematicsPolarToCartesian converts polar coordinates (radius and angle) to Cartesian coordinates (X and Y).

The KinematicsPolarToCartesian class transforms polar coordinate inputs into Cartesian X and Y outputs. This is useful for simulating a system with a polar mechanism like a pottery wheel or a lathe. Heres an example of how to instantiate and configure a KinematicsPolarToCartesian component and then use it to drive Cartesian motion from polar inputs:

#define module_driver
#include "stepdance.hpp"
AnalogInput angle_input;
Encoder radius_enc;
KinematicsPolarToCartesian polar_to_cartesian_kinematics;
VelocityGenerator angle_velocity_gen;
Channel channel_x;
Channel channel_y;
OutputPort output_x;
OutputPort output_y;
void setup(){
// Initialize OutputPorts and enable drivers
output_x.begin(OUTPUT_A);
output_y.begin(OUTPUT_B);
enable_drivers();
// Initialize Channels
channel_x.begin(&output_x, SIGNAL_E);
channel_y.begin(&output_y, SIGNAL_E);
vel_genocity_gen.begin();
angle_velocity_gen.output.map(polar_to_cartesian_kinematics.input_angle);
// Initialize AnalogInput for angle
angle_input.set_floor(0, 25); // Set floor to 0 output at ADC values of 25 and below.
angle_input.set_ceiling(3.28, 1020); //radians per second
angle_input.map(&angle_velocity_gen.speed_units_per_sec); // Map analog output to VelocityGenerator speed ControlParameter
angle_input.begin(IO_A1);
// Initialize Encoder for radius
radius_enc.begin(ENCODER_1);
radius_enc.set_ratio(1, 2400);
radius_enc.output.map(polar_to_cartesian_kinematics.input_radius);
// Initialize KinematicsPolarToCartesian and map to channels
polar_to_cartesian_kinematics.begin();
polar_to_cartesian_kinematics.output_x.map(channel_x.input_target_position);
polar_to_cartesian_kinematics.output_y.map(channel_y.input_target_position);
dance_start();
}
void loop(){
dance_loop();
}

Member Function Documentation

◆ begin()

void KinematicsPolarToCartesian::begin ( float64_t fixed_radius = 0)

Initializes the KinematicsPolarToCartesian with an optional fixed radius. If a fixed radius is provided, the radius input BlockPort will be ignored.

Parameters
fixed_radiusOptional fixed radius value. Default is 0.

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