miki sumito
/
four_wheel_omni
四輪オムニの足回りを動かすプログラム
Diff: motor/motor.cpp
- Revision:
- 0:39c2bb18192b
diff -r 000000000000 -r 39c2bb18192b motor/motor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/motor/motor.cpp Sat Oct 08 11:13:31 2022 +0000 @@ -0,0 +1,32 @@ +#include "motor.hpp" + +Motor::Motor(PinName pin_a,PinName pin_b) : motor1(pin_a),motor2(pin_b) +{ + motor1.period_us(2048); + motor2.period_us(2048); +} + +void Motor::revolution(double pwm) +{ + if(pwm == 0.0) + { + motor1 = 0.0; + motor2 = 0.0; + } + else if(pwm > 0.0) + { + motor1 = pwm; + motor2 = 0.0; + } + else if(pwm < 0.0) + { + motor1 = 0.0; + motor2 = -pwm; + } +} + +void Motor::reset() +{ + motor1 = 0.0; + motor2 = 0.0; +} \ No newline at end of file