S-curve acceleration / deceleration model generator (using FPU)

Dependents:   2021NHK_B_main

position_controller.h

Committer:
tanabe2000
Date:
2018-09-15
Revision:
3:65ae32169b33
Parent:
2:2c5e4f521390
Child:
4:4cc455e372c2

File content as of revision 3:65ae32169b33:

#ifndef POSITION_CONTROLLER_H
#define POSITION_CONTROLLER_H

#include "mbed.h"
#define M_PI 3.141592653589793238462643383219502884

class PositionController {
    public :
        PositionController(double accDistance_, double decDistance_, double initialVelocity_, double terminalVelocity_, float maxVelocity_);

        void compute(int positionX, int positionY);
        void targetXY(int targetX_, int targetY_);
        double getVelocityX();
        double getVelocityY();
    private :

        double generateSineWave(double x, double initV, double termV, double start, double length);

        double accDistance;
        double decDistance;
        double accTrue;
        double decTrue;
        double initialVelocity;
        double terminalVelocity;
        float maxVelocity;
        double target;
        int targetX;
        int targetY;
        double radians;
        double velocity[2];

        bool enoughDistance;

        double getVelocity(int position);
};
#endif