stanfordroboticsclub / StanfordQuadruped

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Abnormal process about pwm_to_duty_cycle

mangdangDOTnet opened this issue · comments

Hello,
Sometimes, I can get the abnormal return from functions "pwm_to_duty_cycle" in the file HardwareInterface.py.
It's OK after change from
return int(pulsewidth_micros / 1e6 * pwm_params.freq * pwm_params.range)
to
pulsewidth_micros = int(pulsewidth_micros / 1e6 * pwm_params.freq * pwm_params.range)
if np.isnan(pulsewidth_micros):
return 0
return int(np.clip(pulsewidth_micros, 0, 4096))

Please double confirm whether the change point is OK, thanks!
Best,
Afreez

sorry about the delay, yes seems fine