コード例 #1
0
    def start_test(self, challenge):
        vals = self.parseChallenge(challenge)

        if 'd1' not in vals or 'd2' not in vals:
            raise CourseraException(
                "Unknown challenge format. Please contact developers for assistance."
            )

        d1 = vals['d1']
        d2 = vals['d2']

        from supervisors.week2 import QuickBotSupervisor
        from robots.quickbot import QuickBot, QuickBot_IRSensor
        from pose import Pose

        bot = QuickBot(Pose())
        sensor = QuickBot_IRSensor(Pose(), bot)

        id1 = sensor.distance_to_value(d1)
        id2 = sensor.distance_to_value(d2)

        info = bot.get_info()
        info.color = 0
        s = QuickBotSupervisor(Pose(), info)
        # Just in case a student iterates in a weird way
        s.robot.ir_sensors.readings = [id1, id2, id1, id2, id1]
        ird = s.get_ir_distances()

        self.testsuite.respond("{:0.3f},{:0.3f}".format(
            abs((d1 - ird[0]) / d1), abs((d2 - ird[1]) / d2)))
コード例 #2
0
 def start_test(self,challenge):
     m = self.RX.match(challenge)
     if m is None:
         raise CourseraException("Unknown challenge format. Please contact developers for assistance.")
     try:
         d1 = float(m.group('d1'))
         d2 = float(m.group('d2'))
     except ValueError:
         raise CourseraException("Unknown challenge format. Please contact developers for assistance.")
                 
     from supervisors.week2 import QuickBotSupervisor
     from robots.quickbot import QuickBot, QuickBot_IRSensor
     from pose import Pose
     
     bot = QuickBot(Pose())
     sensor = QuickBot_IRSensor(Pose(),bot)
     
     id1 = sensor.distance_to_value(d1)
     id2 = sensor.distance_to_value(d2)
     
     info = bot.get_info()
     info.color = 0
     s = QuickBotSupervisor(Pose(),info)
     # Just in case a student iterates in a weird way
     s.robot.ir_sensors.readings = [id1,id2,id1,id2,id1]
     ird = s.get_ir_distances()
                 
     self.testsuite.respond("{:0.3f},{:0.3f}".format(abs((d1-ird[0])/d1), abs((d2-ird[1])/d2)))
コード例 #3
0
    def start_test(self,challenge):
        vals = self.parseChallenge(challenge)
        
        if 'd1' not in vals or 'd2' not in vals:
            raise CourseraException("Unknown challenge format. Please contact developers for assistance.")

        d1 = vals['d1']
        d2 = vals['d2']
                    
        from supervisors.week2 import QuickBotSupervisor
        from robots.quickbot import QuickBot, QuickBot_IRSensor
        from pose import Pose
        
        bot = QuickBot(Pose())
        sensor = QuickBot_IRSensor(Pose(),bot)
        
        id1 = sensor.distance_to_value(d1)
        id2 = sensor.distance_to_value(d2)
        
        info = bot.get_info()
        info.color = 0
        s = QuickBotSupervisor(Pose(),info)
        # Just in case a student iterates in a weird way
        s.robot.ir_sensors.readings = [id1,id2,id1,id2,id1]
        ird = s.get_ir_distances()
                    
        self.testsuite.respond("{:0.3f},{:0.3f}".format(abs((d1-ird[0])/d1), abs((d2-ird[1])/d2)))
コード例 #4
0
    def start_test(self, challenge):
        m = self.RX.match(challenge)
        if m is None:
            raise CourseraException(
                "Unknown challenge format. Please contact developers for assistance."
            )
        try:
            d1 = float(m.group('d1'))
            d2 = float(m.group('d2'))
        except ValueError:
            raise CourseraException(
                "Unknown challenge format. Please contact developers for assistance."
            )

        from supervisors.week2 import QuickBotSupervisor
        from robots.quickbot import QuickBot, QuickBot_IRSensor
        from pose import Pose

        bot = QuickBot(Pose())
        sensor = QuickBot_IRSensor(Pose(), bot)

        id1 = sensor.distance_to_value(d1)
        id2 = sensor.distance_to_value(d2)

        info = bot.get_info()
        info.color = 0
        s = QuickBotSupervisor(Pose(), info)
        # Just in case a student iterates in a weird way
        s.robot.ir_sensors.readings = [id1, id2, id1, id2, id1]
        ird = s.get_ir_distances()

        self.testsuite.respond("{:0.3f},{:0.3f}".format(
            abs((d1 - ird[0]) / d1), abs((d2 - ird[1]) / d2)))