rcute_cozmars.sonar

class rcute_cozmars.sonar.Sonar(robot)

声纳,即超声波距离传感器

when_in_range = None

回调函数,当探测到前方障碍物的距离小于阈值距离 threshold_distance 时调用,默认为 None

该回调函数接受一个参数,即此时探测到的前方距离(米)

distance

探测到前方障碍物的距离(米)

当距离超过 max_distance 时只能也只显示 max_distance

max_distance

最远能测量的距离(米),默认是 0.5

threshold_distance

阈值距离(米),默认时 0.1

当探测到前方障碍物的距离小于阈值距离时触发 when_in_range 时间,大于阈值距离时触发 when_out_of_range 事件

when_out_of_range = None

回调函数,当探测到前方障碍物的距离大于阈值距离 threshold_distance 时调用,默认为 None

该回调函数接受一个参数,即此时探测到的前方距离(米)