Main Page | Modules | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

ExtProfiler Class Reference
[Miscellaneous Library Utilities]

#include <ExtProfiler.hh>

List of all members.


Detailed Description

Class for generating piecewise cubic functions of a single variable.

This class is a utility for defining and evaluating piecewise linear or cubic functions of a single variable. It is primarily used in setting up motion profiles for actuators but can also be used for any other domain which requires such functions.

Following the creation of an instance, defining the function involves incrementally adding a number of nodes along the independent axis with the corresponding function value and smoothing parameters. The overloaded method addSegment is used for this purpose. The implementation assumes that the function is defined on the real line, with the parts prior to the first segment and following the last segment assumed to remain constant.

Once all the nodes are added, the methods getVal and getSlope can be used to evaluate the function. Furthermore, the method getTarget is provided to return a motor target structure for convenience.

Note that all the addSegment and setup methods assume that the supplied data is sorted with an increasing order for the independent variable. Violating this assumption will cause weird behavior.


Public Member Functions

 ExtProfiler (void)
double getVal (double x)
double getSlope (double x)
void getAll (double x, float *pos, float *vel)
MotorTarget_t getTarget (double x)
void addSegment (double x, double y, double begin_slope, double end_slope)
void addSegment (double x, double y, double end_slope)
void addSegment (double x, double y)
void setup (Floats set_x, Floats set_y, Floats set_begin_slope, Floats set_end_slope)
void setup (Floats set_x, Floats set_y, Floats set_end_slope)
void setup (Floats set_x, Floats set_y)
void setupLinear (double x1, double y1, double x2, double y2)
void reset (void)
void print (void)


Constructor & Destructor Documentation

ExtProfiler::ExtProfiler void   ) 
 

This constructor creates a profile object with no nodes.


Member Function Documentation

void ExtProfiler::addSegment double  x,
double  y
 

This method adds a new segment to the end of the profile with both the beginning and end slopes properly chosen to yield a linear function for this segment. Repeated use of this method results in a piecewise linear function.

void ExtProfiler::addSegment double  x,
double  y,
double  end_slope
 

This method adds a new segment to the end of the profile whose beginning slope is equal to the ending slope of the previous segment. Hence, this method can be used to create a smooth cubic function.

void ExtProfiler::addSegment double  x,
double  y,
double  begin_slope,
double  end_slope
 

This method adds a segment to the end of the profile Sets up the most general of segments, using (x,y) as the next point, and begin_slope and end_slope as the beginning and ending slope for this specific segment. It is assumed that the segments are added in increasing order of the independent variable x .

double ExtProfiler::getSlope double  x  ) 
 

This method evaluates the slope of the function at the specified value of the independent variable. Note that at least one node must have been added to the profile. Otherwise, a fatal error will be generated

MotorTarget_t ExtProfiler::getTarget double  x  ) 
 

This method returns a motor target structure with the value, slope and second derivative of the function at the supplied value of the independent variable.

double ExtProfiler::getVal double  x  ) 
 

This method evaluates the function at the specified value of the independent variable. Note that at least one node must have been added to the profile. Otherwise, a fatal error will be generated

void ExtProfiler::reset void   ) 
 

This method resets the profile by deleting all nodes.

void ExtProfiler::setup Floats  set_x,
Floats  set_y
 

This method sets up at once, a piecewise linear profile with the specified nodes.

void ExtProfiler::setup Floats  set_x,
Floats  set_y,
Floats  set_end_slope
 

This method sets up the profile at once with only the end slopes of each segment explicitly specified. The beginning slopes are computed to ensure smoothness across segments.

void ExtProfiler::setup Floats  set_x,
Floats  set_y,
Floats  set_begin_slope,
Floats  set_end_slope
 

This method sets up the profile at once with the least amount of constraints. Both the beginning and slopes for each segment can be arbitrarily specified, yielding a possibly non-smooth function.

void ExtProfiler::setupLinear double  x1,
double  y1,
double  x2,
double  y2
 

This method sets up a single line from (x1,y1) to (x2,y2)


RHexLib Reference Documentation