当前位置: 首页>>代码示例>>Python>>正文


Python Driver.followPolyLineG方法代码示例

本文整理汇总了Python中driver.Driver.followPolyLineG方法的典型用法代码示例。如果您正苦于以下问题:Python Driver.followPolyLineG方法的具体用法?Python Driver.followPolyLineG怎么用?Python Driver.followPolyLineG使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在driver.Driver的用法示例。


在下文中一共展示了Driver.followPolyLineG方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_followLineG

# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import followPolyLineG [as 别名]
    def test_followLineG( self ):
        robot = MagicMock()
        robot.localisation.pose.return_value = (0, 0.3, 0)
        driver = Driver(robot, maxSpeed = 0.5)
        offsetDistance = 0.03
        gen = driver.followPolyLineG(pts = [(0, 0), (1.0, 0)],
                                     offsetDistance=offsetDistance)
        speed, angularSpeed = gen.next()
        self.assertAlmostEqual(angularSpeed, -4 * math.radians(20))
        self.assertAlmostEqual(speed, 0.444444444444)

        # now for closer distance reduce the turning angle
        robot.localisation.pose.return_value = (0, 1.5 * offsetDistance, 0)
        speed, angularSpeed = gen.next()
        self.assertAlmostEqual(angularSpeed, -4 * math.radians(10))
        self.assertAlmostEqual(speed, 0.4722222222222222)
开发者ID:robotika,项目名称:eduro,代码行数:18,代码来源:driver_test.py

示例2: __init__

# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import followPolyLineG [as 别名]

#.........这里部分代码省略.........
    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)):
                print "ESCAPING FROM", self.robot.localisation.pose()
                self.driver.stop()
                break
            if self.robot.time - start_time > timeout:
                print "TIMEOUT", self.robot.time - start_time
                self.driver.goStraight(-0.3, timeout=10)
                self.driver.turn(angle=math.radians(90), timeout=10)
                self.driver.turn(angle=math.radians(-90), timeout=10)
                self.place_cube()
                return  # demo - game3 experiment
        self.place_cube()

        # handle offset in case of blocked path
        print rev_pts
        route = Route(pts=rev_pts, conv=DummyConvertor())
        _, dist, signed_index = route.findNearestEx(self.robot.localisation.pose())
        rev_pts = rev_pts[max(0, abs(signed_index) - 1):]
        print "cut path", dist, signed_index, rev_pts

        self.driver.turn(angle=math.radians(180), timeout=30)

        for cmd in self.driver.followPolyLineG(rev_pts):
            self.robot.setSpeedPxPa(*cmd)
            self.robot.update()


    def ver1(self, verbose=False):
开发者ID:robotika,项目名称:eduro,代码行数:70,代码来源:sickday2016.py


注:本文中的driver.Driver.followPolyLineG方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。