first
Dependents: 17robo_fuzi 17robo_tokyo_kaede
Revision 0:e7a61140ec7d, committed 2017-09-20
- Comitter:
- echo_piyo
- Date:
- Wed Sep 20 07:06:29 2017 +0000
- Commit message:
- (??)?????????????????encorder.h???????????
Changed in this revision
accelerator.cpp | Show annotated file Show diff for this revision Revisions of this file |
accelerator.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/accelerator.cpp Wed Sep 20 07:06:29 2017 +0000 @@ -0,0 +1,19 @@ + +#include "accelerator.h" +#include "mbed.h" + +void Accelerator::setup(float Acceleration, float time){ + a = Acceleration*time; + v = 0; +} + +float Accelerator::duty(float target){ + if (fabs(target-v) <= a) { + v = target; + } else if (v < target) { + v = v + a; + } else if (v > target) { + v = v - a; + } + return v; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/accelerator.h Wed Sep 20 07:06:29 2017 +0000 @@ -0,0 +1,21 @@ +/* +* [Accelerator] +* 時間を指定し段階的な加減速を行う +*/ + +#ifndef MBED_ACCELERATOR_H +#define MBED_ACCELERATOR_H + +#include "mbed.h" + +class Accelerator{ +public : + void setup(float Acceleration, float time); + float duty(float target); + +private : + float a; + float v; +}; + +#endif \ No newline at end of file