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

Dependents:   2021NHK_B_main

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers position_controller.h Source File

position_controller.h

00001 #ifndef POSITION_CONTROLLER_H
00002 #define POSITION_CONTROLLER_H
00003 
00004 #include "mbed.h"
00005 const float F_PI = 3.141593f;
00006 
00007 class PositionController {
00008     public :
00009         PositionController(float accDistance_, float decDistance_, float initialVelocity_, float terminalVelocity_, float maxVelocity_);
00010 
00011         void compute(int positionX, int positionY);
00012         void targetXY(int targetX_, int targetY_);
00013         float getVelocityX();
00014         float getVelocityY();
00015     private :
00016 
00017         float generateSineWave(float x, float initV, float termV, float start, float length);
00018 
00019         float accDistance;
00020         float decDistance;
00021         float accTrue;
00022         float decTrue;
00023         float initialVelocity;
00024         float terminalVelocity;
00025         float maxVelocity;
00026         float target;
00027         int targetX;
00028         int targetY;
00029         float radians;
00030         float velocity[2];
00031 
00032         bool enoughDistance;
00033 
00034         float getVelocity(int position);
00035 };
00036 #endif
00037