四輪オムニの足回りを動かすプログラム
Embed:
(wiki syntax)
Show/hide line numbers
motor.cpp
00001 #include "motor.hpp" 00002 00003 Motor::Motor(PinName pin_a,PinName pin_b) : motor1(pin_a),motor2(pin_b) 00004 { 00005 motor1.period_us(2048); 00006 motor2.period_us(2048); 00007 } 00008 00009 void Motor::revolution(double pwm) 00010 { 00011 if(pwm == 0.0) 00012 { 00013 motor1 = 0.0; 00014 motor2 = 0.0; 00015 } 00016 else if(pwm > 0.0) 00017 { 00018 motor1 = pwm; 00019 motor2 = 0.0; 00020 } 00021 else if(pwm < 0.0) 00022 { 00023 motor1 = 0.0; 00024 motor2 = -pwm; 00025 } 00026 } 00027 00028 void Motor::reset() 00029 { 00030 motor1 = 0.0; 00031 motor2 = 0.0; 00032 }
Generated on Sat Oct 8 2022 11:15:36 by
1.7.2