logo

请问一下追踪小车car.py里,run(left_speed, right_speed)中,相对应的电机角速度是多少?

2022-06-19 23:25
U
_3sbx

请问一下追踪小车car.py里,run(left_speed, right_speed)中,相对应的电机角速度是多少?比如car.run(10,20).对电机这一块不是很了解

from pyb import Pin, Timer
inverse_left=False  #change it to True to inverse left wheel
inverse_right=False #change it to True to inverse right wheel

ain1 =  Pin('P0', Pin.OUT_PP)
ain2 =  Pin('P1', Pin.OUT_PP)
bin1 =  Pin('P2', Pin.OUT_PP)
bin2 =  Pin('P3', Pin.OUT_PP)
ain1.low()
ain2.low()
bin1.low()
bin2.low()

pwma = Pin('P7')
pwmb = Pin('P8')
tim = Timer(4, freq=1000)
ch1 = tim.channel(1, Timer.PWM, pin=pwma)
ch2 = tim.channel(2, Timer.PWM, pin=pwmb)
ch1.pulse_width_percent(0)
ch2.pulse_width_percent(0)

def run(left_speed, right_speed):
    if inverse_left==True:
        left_speed=(-left_speed)
    if inverse_right==True:
        right_speed=(-right_speed)

    if left_speed < 0:
        ain1.low()
        ain2.high()
    else:
        ain1.high()
        ain2.low()
    ch1.pulse_width_percent(int(abs(left_speed)))

    if right_speed < 0:
        bin1.low()
        bin2.high()
    else:
        bin1.high()
        bin2.low()
    ch2.pulse_width_percent(int(abs(right_speed)))
2022-06-20 20:49
I
网红小智智 星瞳科技

pwm是10%和20%

不同的电机不一样,电机没有把角速度的值写出来。

2022-06-21 14:15
U
_3sbx

就是官方的n20电机,那对应的转速能知道不?

2022-06-21 14:50
U
_3sbx

@kidswong999 就是官方的n20电机,那对应的转速能知道不?

2022-06-21 21:47
I
网红小智智 星瞳科技

@3sbx 厂家没有给我这个参数。