miki sumito
/
four_wheel_omni
四輪オムニの足回りを動かすプログラム
rotaryinc/rotaryinc.hpp@0:39c2bb18192b, 2022-10-08 (annotated)
- Committer:
- m_smt
- Date:
- Sat Oct 08 11:13:31 2022 +0000
- Revision:
- 0:39c2bb18192b
move four wheel omni
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
m_smt | 0:39c2bb18192b | 1 | #ifndef ROTARY_INC_ |
m_smt | 0:39c2bb18192b | 2 | #define ROTARY_INC_ |
m_smt | 0:39c2bb18192b | 3 | #include <mbed.h> |
m_smt | 0:39c2bb18192b | 4 | #define M_PI 3.1415926535 |
m_smt | 0:39c2bb18192b | 5 | |
m_smt | 0:39c2bb18192b | 6 | #if 0 |
m_smt | 0:39c2bb18192b | 7 | ~example~ |
m_smt | 0:39c2bb18192b | 8 | rotaryinc name(ピン名1,ピン名2,オムニの直径,パルスの分解能,一回のプログラムの時間(Δt))でこのクラスを使うことができる |
m_smt | 0:39c2bb18192b | 9 | name.getpulse()でパルスの値を取得できる |
m_smt | 0:39c2bb18192b | 10 | name.getspeed()でモータの速さを取得できる |
m_smt | 0:39c2bb18192b | 11 | name.loop(一回のプログラムの時間(Δt))でΔt秒ごとのプログラムにできる |
m_smt | 0:39c2bb18192b | 12 | #endif |
m_smt | 0:39c2bb18192b | 13 | |
m_smt | 0:39c2bb18192b | 14 | class rotaryinc |
m_smt | 0:39c2bb18192b | 15 | { |
m_smt | 0:39c2bb18192b | 16 | public: |
m_smt | 0:39c2bb18192b | 17 | rotaryinc(PinName pinA,PinName pinB,double,double,double); |
m_smt | 0:39c2bb18192b | 18 | ~rotaryinc(); |
m_smt | 0:39c2bb18192b | 19 | Timer timer; |
m_smt | 0:39c2bb18192b | 20 | double getpulse(); |
m_smt | 0:39c2bb18192b | 21 | double getspeed(); |
m_smt | 0:39c2bb18192b | 22 | double gettheta(); |
m_smt | 0:39c2bb18192b | 23 | double getomega(); |
m_smt | 0:39c2bb18192b | 24 | double getrevolution(); |
m_smt | 0:39c2bb18192b | 25 | void loop(); |
m_smt | 0:39c2bb18192b | 26 | private: |
m_smt | 0:39c2bb18192b | 27 | InterruptIn *pin_a_,*pin_b_; |
m_smt | 0:39c2bb18192b | 28 | double time; |
m_smt | 0:39c2bb18192b | 29 | double pulse[2]; |
m_smt | 0:39c2bb18192b | 30 | double speed; |
m_smt | 0:39c2bb18192b | 31 | void init(PinName,PinName); |
m_smt | 0:39c2bb18192b | 32 | void riseA(void); |
m_smt | 0:39c2bb18192b | 33 | void riseB(void); |
m_smt | 0:39c2bb18192b | 34 | void fallA(void); |
m_smt | 0:39c2bb18192b | 35 | void fallB(void); |
m_smt | 0:39c2bb18192b | 36 | double theta[2]; |
m_smt | 0:39c2bb18192b | 37 | double omega; |
m_smt | 0:39c2bb18192b | 38 | double Resolution; |
m_smt | 0:39c2bb18192b | 39 | double Diameter; |
m_smt | 0:39c2bb18192b | 40 | double dt_; |
m_smt | 0:39c2bb18192b | 41 | double revolution_num; |
m_smt | 0:39c2bb18192b | 42 | }; |
m_smt | 0:39c2bb18192b | 43 | |
m_smt | 0:39c2bb18192b | 44 | #endif |