#ifndef BLENDMATH_H
#define BLENDMATH_H
#include "posemath.h"
#include "tc_types.h"
#define BLEND_ACC_RATIO_TANGENTIAL 0.5
#define BLEND_ACC_RATIO_NORMAL (pmSqrt(1.0 - pmSq(BLEND_ACC_RATIO_TANGENTIAL)))
#define BLEND_KINK_FACTOR 0.25
typedef enum {
BLEND_NONE,
BLEND_LINE_LINE,
BLEND_LINE_ARC,
BLEND_ARC_LINE,
BLEND_ARC_ARC,
} blend_type_t;
typedef struct {
PmCartesian u1;
PmCartesian u2;
PmCartesian P;
PmCartesian normal;
PmCartesian binormal;
PmCartesian u_tan1;
PmCartesian u_tan2;
PmCartesian center1;
PmCartesian center2;
double radius1;
double radius2;
double theta_tan;
double v_max1;
double v_max2;
} BlendGeom3;
#ifdef BLEND_9D
typedef struct {
} BlendGeom9;
#endif
typedef struct {
double tolerance;
double L1;
double L2;
double v_req;
double a_max;
double theta;
double phi;
double a_n_max;
double R_plan;
double d_plan;
double v_goal;
double v_plan;
double v_actual;
double s_arc;
int consume;
double line_length;
int convex1;
int convex2;
double phi1_max;
double phi2_max;
} BlendParameters;
typedef struct {
PmCartesian arc_start;
PmCartesian arc_end;
PmCartesian arc_center;
double trim1;
double trim2;
} BlendPoints3;
#ifdef BLEND_9D
typedef struct {
} BlendPoints9;
#endif
double findMaxTangentAngle(double v, double acc, double cycle_time);
double findKinkAccel(double kink_angle, double v_plan, double cycle_time);
double fsign(double f);
int clip_min(double * const x, double min);
int clip_max(double * const x, double max);
double saturate(double x, double max);
double bisaturate(double x, double max, double min);
int sat_inplace(double * const x, double max);
int checkTangentAngle(PmCircle const * const circ, SphericalArc const * const arc, BlendGeom3 const * const geom, BlendParameters const * const param, double cycle_time, int at_end);
int findIntersectionAngle(PmCartesian const * const u1,
PmCartesian const * const u2, double * const theta);
double pmCartMin(PmCartesian const * const in);
int calculateInscribedDiameter(PmCartesian const * const normal,
PmCartesian const * const bounds, double * const diameter);
int findAccelScale(PmCartesian const * const acc,
PmCartesian const * const bounds,
PmCartesian * const scale);
int pmUnitCartsColinear(PmCartesian const * const u1,
PmCartesian const * const u2);
int pmCartCartParallel(PmCartesian const * const u1,
PmCartesian const * const u2,
double tol);
int pmCartCartAntiParallel(PmCartesian const * const u1,
PmCartesian const * const u2,
double tol);
int pmCircLineCoplanar(PmCircle const * const circ,
PmCartLine const * const line, double tol);
int blendCoplanarCheck(PmCartesian const * const normal,
PmCartesian const * const u1_tan,
PmCartesian const * const u2_tan,
double tol);
int blendCalculateNormals3(BlendGeom3 * const geom);
int blendComputeParameters(BlendParameters * const param);
int blendCheckConsume(BlendParameters * const param,
BlendPoints3 const * const points,
TC_STRUCT const * const prev_tc, int gap_cycles);
int blendFindPoints3(BlendPoints3 * const points, BlendGeom3 const * const geom,
BlendParameters const * const param);
int blendGeom3Init(BlendGeom3 * const geom,
TC_STRUCT const * const prev_tc,
TC_STRUCT const * const tc);
int blendParamKinematics(BlendGeom3 * const geom,
BlendParameters * const param,
TC_STRUCT const * const prev_tc,
TC_STRUCT const * const tc,
PmCartesian const * const acc_bound,
PmCartesian const * const vel_bound,
double maxFeedScale);
int blendInit3FromLineLine(BlendGeom3 * const geom, BlendParameters * const param,
TC_STRUCT const * const prev_tc,
TC_STRUCT const * const tc,
PmCartesian const * const acc_bound,
PmCartesian const * const vel_bound,
double maxFeedScale);
int blendInit3FromLineArc(BlendGeom3 * const geom, BlendParameters * const param,
TC_STRUCT const * const prev_tc,
TC_STRUCT const * const tc,
PmCartesian const * const acc_bound,
PmCartesian const * const vel_bound,
double maxFeedScale);
int blendInit3FromArcLine(BlendGeom3 * const geom, BlendParameters * const param,
TC_STRUCT const * const prev_tc,
TC_STRUCT const * const tc,
PmCartesian const * const acc_bound,
PmCartesian const * const vel_bound,
double maxFeedScale);
int blendInit3FromArcArc(BlendGeom3 * const geom, BlendParameters * const param,
TC_STRUCT const * const prev_tc,
TC_STRUCT const * const tc,
PmCartesian const * const acc_bound,
PmCartesian const * const vel_bound,
double maxFeedScale);
int blendArcArcPostProcess(BlendPoints3 * const points, BlendPoints3 const * const points_in,
BlendParameters * const param, BlendGeom3 const * const geom,
PmCircle const * const circ1, PmCircle const * const circ2);
int blendLineArcPostProcess(BlendPoints3 * const points, BlendPoints3 const * const points_in,
BlendParameters * const param, BlendGeom3 const * const geom,
PmCartLine const * const line1, PmCircle const * const circ2);
int blendArcLinePostProcess(BlendPoints3 * const points, BlendPoints3 const * const points_in,
BlendParameters * const param, BlendGeom3 const * const geom,
PmCircle const * const circ1, PmCartLine const * const line2);
int arcFromBlendPoints3(SphericalArc * const arc, BlendPoints3 const * const points,
BlendGeom3 const * const geom, BlendParameters const * const param);
int blendGeom3Print(BlendGeom3 const * const geom);
int blendParamPrint(BlendParameters const * const param);
int blendPoints3Print(BlendPoints3 const * const points);
double pmCartAbsMax(PmCartesian const * const v);
typedef struct {
double v_max;
double acc_ratio;
} PmCircleLimits;
PmCircleLimits pmCircleActualMaxVel(const PmCircle *circle,
double v_max_nominal,
double a_max_nominal);
int findSpiralArcLengthFit(PmCircle const * const circle,
SpiralArcLengthFit * const fit);
int pmCircleAngleFromProgress(PmCircle const * const circle,
SpiralArcLengthFit const * const fit,
double progress,
double * const angle);
double pmCircleEffectiveMinRadius(const PmCircle *circle);
static inline double findVPeak(double a_t_max, double distance)
{
return pmSqrt(a_t_max * distance);
}
#endif