本文整理汇总了Python中driver.Driver.goStraightG方法的典型用法代码示例。如果您正苦于以下问题:Python Driver.goStraightG方法的具体用法?Python Driver.goStraightG怎么用?Python Driver.goStraightG使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类driver.Driver
的用法示例。
在下文中一共展示了Driver.goStraightG方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import goStraightG [as 别名]
#.........这里部分代码省略.........
tolerance = 0.05
angle = math.atan2(cube_y, cube_x)
turnStep = math.radians(10)
if abs(angle) > math.radians(10):
turnStep = math.radians(50)
if cube_y > tolerance:
angularSpeed = turnStep
elif cube_y < -tolerance:
angularSpeed = -turnStep
else:
angularSpeed = 0
speed = 0.1
if cube_x > 0.5:
speed = 0.3 # move faster toward further goals
if cube_x < 0.30:
return True
self.robot.setSpeedPxPa(speed, angularSpeed)
else:
self.robot.setSpeedPxPa(0.0, 0.0)
print "TIMEOUT"
return False
def ver0( self, verbose=False ):
# Go straight for 2 meters
print "ver0", self.robot.battery
prevRFID = None
self.load_cube()
for cmd in self.driver.goStraightG(2.0):
self.robot.setSpeedPxPa(*cmd)
if prevRFID != self.robot.rfu620Data:
prevRFID = self.robot.rfu620Data
posXY = combinedPose(self.robot.localisation.pose(), (-0.35, 0.14, 0))[:2]
for d in self.robot.rfu620Data[1]:
i = d[0] # i.e. 0x1000 0206 0000
x, y, zone = (i >> 24)&0xFF, (i >> 16)&0xFF, i&0xFF
print hex(i), (x, y)
if x == 1:
viewlog.dumpBeacon(posXY, color=(0, 0, 255))
elif x == 2:
viewlog.dumpBeacon(posXY, color=(255, 0, 255))
else:
viewlog.dumpBeacon(posXY, color=(255, 255, 255))
self.robot.update()
self.place_cube()
self.game_over()
def handle_single_cube(self, pts, rev_pts, timeout=60):
if self.find_cube(timeout=20.0):
self.load_cube()
print verify_loaded_cube(self.robot.laserData)
start_time = self.robot.time
for cmd in self.driver.followPolyLineG(pts, withStops=True):
self.robot.setSpeedPxPa(*cmd)
self.robot.update()
if (not is_in_loading_zone(self.robot.localisation.pose(),
self.robot.last_valid_rfid)
and is_path_blocked(self.robot.laserData, self.robot.remissionData)):