S-curve acceleration / deceleration model generator (using FPU)
Diff: position_controller.h
- Revision:
- 4:4cc455e372c2
- Parent:
- 3:65ae32169b33
diff -r 65ae32169b33 -r 4cc455e372c2 position_controller.h --- a/position_controller.h Sat Sep 15 05:05:27 2018 +0000 +++ b/position_controller.h Tue Jun 25 08:28:21 2019 +0000 @@ -2,36 +2,36 @@ #define POSITION_CONTROLLER_H #include "mbed.h" -#define M_PI 3.141592653589793238462643383219502884 +const float F_PI = 3.141593f; class PositionController { public : - PositionController(double accDistance_, double decDistance_, double initialVelocity_, double terminalVelocity_, float maxVelocity_); + PositionController(float accDistance_, float decDistance_, float initialVelocity_, float terminalVelocity_, float maxVelocity_); void compute(int positionX, int positionY); void targetXY(int targetX_, int targetY_); - double getVelocityX(); - double getVelocityY(); + float getVelocityX(); + float getVelocityY(); private : - double generateSineWave(double x, double initV, double termV, double start, double length); + float generateSineWave(float x, float initV, float termV, float start, float length); - double accDistance; - double decDistance; - double accTrue; - double decTrue; - double initialVelocity; - double terminalVelocity; + float accDistance; + float decDistance; + float accTrue; + float decTrue; + float initialVelocity; + float terminalVelocity; float maxVelocity; - double target; + float target; int targetX; int targetY; - double radians; - double velocity[2]; + float radians; + float velocity[2]; bool enoughDistance; - double getVelocity(int position); + float getVelocity(int position); }; #endif