def start_test(self, challenge): vals = self.parseChallenge(challenge) if 'v' not in vals or 'w' not in vals: raise CourseraException( "Unknown challenge format. Please contact developers for assistance." ) vd = vals['v'] wd = vals['w'] QuickBotSupervisor = helpers.load_by_name('week3.QBGTGSupervisor', 'supervisors') QuickBot = helpers.load_by_name('QuickBot', 'robots') from pose import Pose bot = QuickBot(Pose()) info = bot.get_info() info.color = 0 s = QuickBotSupervisor(Pose(), info) vld, vrd = s.uni2diff((vd, wd)) vl, vr = s.ensure_w((vld, vrd)) # Clamp to robot maxima vl = max(-info.wheels.max_velocity, min(info.wheels.max_velocity, vl)) vr = max(-info.wheels.max_velocity, min(info.wheels.max_velocity, vr)) v, w = bot.diff2uni((vl, vr)) self.testsuite.respond("{:0.3f}".format(abs(w - wd) / wd))
def start_test(self,challenge): vals = self.parseChallenge(challenge) if 'v' not in vals or 'w' not in vals: raise CourseraException("Unknown challenge format. Please contact developers for assistance.") vd = vals['v'] wd = vals['w'] QuickBotSupervisor = helpers.load_by_name('week3.QBGTGSupervisor','supervisors') QuickBot = helpers.load_by_name('QuickBot','robots') from pose import Pose bot = QuickBot(Pose()) info = bot.get_info() info.color = 0 s = QuickBotSupervisor(Pose(),info) vld, vrd = s.uni2diff((vd,wd)) vl, vr = s.ensure_w((vld,vrd)) # Clamp to robot maxima vl = max(-info.wheels.max_velocity, min(info.wheels.max_velocity, vl)) vr = max(-info.wheels.max_velocity, min(info.wheels.max_velocity, vr)) v, w = bot.diff2uni((vl,vr)) self.testsuite.respond("{:0.3f}".format(abs(w-wd)/wd))