本文整理汇总了Python中analyzer.Analyzer.range_at_heading方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer.range_at_heading方法的具体用法?Python Analyzer.range_at_heading怎么用?Python Analyzer.range_at_heading使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类analyzer.Analyzer
的用法示例。
在下文中一共展示了Analyzer.range_at_heading方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_analzyer_on_field_model
# 需要导入模块: from analyzer import Analyzer [as 别名]
# 或者: from analyzer.Analyzer import range_at_heading [as 别名]
def test_analzyer_on_field_model():
"""
Create a model of the field, then ask the laser to compute
the range for sweep. Then move the robot and ask again.
"""
robot = Robot()
field = FieldModel()
tower_range = field.tower_range_from_origin()
rotation = FakeRotation(field, robot)
heading, sweep_range = Analyzer.range_at_heading(rotation.polar_data(), (-10,11))
# closest point should be dead ahead
assert heading == 0
assert sweep_range == tower_range
movement = 100
robot.move(movement)
rotation = FakeRotation(field, robot)
heading, sweep_range = Analyzer.range_at_heading(rotation.polar_data(), (-10,11))
# closest point should be dead ahead
assert heading == 0
assert sweep_range == (tower_range - movement)
示例2: Rotation
# 需要导入模块: from analyzer import Analyzer [as 别名]
# 或者: from analyzer.Analyzer import range_at_heading [as 别名]
current_time = 0
seconds_per_output = 1
SECONDS_PER_MINUTE = 60.0
rotations = []
while 1:
try:
rotation = Rotation(lasr.gather_full_rotation())
rotations = rotations[-4:]
rotations.append(rotation)
# rotation = OldRotation(lasr.gather_full_rotation())
#
# For now, we just output a lidar data snapshot every 10 seconds
# We will want this for debugging (maybe every second instead)
# change the "seconds_per_output" to tune that.
#
tgt_heading, tgt_range = Analyzer.range_at_heading(rotation.polar_data(), (Analyzer.start, Analyzer.stop))
logger.info(
"{:d} points yields {:.2f} inches at {:2d} degrees)".format(
len(rotation.polar_data()), tgt_range, tgt_heading
)
)
# push the newly calculated data into the message
range_at_heading_message.heading = tgt_heading
range_at_heading_message.range = tgt_range
channel.send_to(range_at_heading_message.encode_message())
# push periodic message to the bot
periodic_message.status = "ok"
periodic_message.rpm = rotation.rpm()
channel.send_to(periodic_message.encode_message())