def start_test(self,challenge): vals = self.parseChallenge(challenge) if 'v' not in vals or 'theta' not in vals: raise CourseraException("Unknown challenge format. Please contact developers for assistance.") v = vals['v'] theta = vals['theta'] from supervisors.week2 import QuickBotSupervisor from robots.quickbot import QuickBot from pose import Pose from helpers import Struct from math import pi bot = QuickBot(Pose()) info = bot.get_info() info.color = 0 s = QuickBotSupervisor(Pose(),info) params = Struct() params.goal = theta*180/pi params.velocity = v params.pgain = 1 s.set_parameters(params) tc = 0.033 # 0.033 sec' is the SimIAm time step for step in range(25): # 25 steps bot.move(tc) bot.set_inputs(s.execute(bot.get_info(), tc)) xe,ye,te = s.pose_est xr,yr,tr = bot.get_pose() self.testsuite.respond("{:0.3f},{:0.3f},{:0.3f}".format(abs((xr-xe)/xr), abs((yr-ye)/yr), abs(abs(tr-te)%(2*pi)/tr)))
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: v = float(m.group('v')) theta = float(m.group('theta')) except ValueError: raise CourseraException( "Unknown challenge format. Please contact developers for assistance." ) from supervisors.week2 import QuickBotSupervisor from robots.quickbot import QuickBot from pose import Pose from helpers import Struct from math import pi bot = QuickBot(Pose()) info = bot.get_info() info.color = 0 s = QuickBotSupervisor(Pose(), info) params = Struct() params.goal = theta * 180 / pi params.velocity = v params.pgain = 1 s.set_parameters(params) tc = 0.033 # 0.033 sec' is the SimIAm time step for step in range(25): # 25 steps bot.move(tc) bot.set_inputs(s.execute(bot.get_info(), tc)) xe, ye, te = s.pose_est xr, yr, tr = bot.get_pose() if xr == 0: xr = 0.0000001 if yr == 0: yr = 0.0000001 if tr == 0: tr = 0.0000001 self.testsuite.respond("{:0.3f},{:0.3f},{:0.3f}".format( abs((xr - xe) / xr), abs((yr - ye) / yr), abs(abs(tr - te) % (2 * pi) / tr)))
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 '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)))
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 '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)))
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)))
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)))
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: v = float(m.group('v')) theta = float(m.group('theta')) except ValueError: raise CourseraException("Unknown challenge format. Please contact developers for assistance.") from supervisors.week2 import QuickBotSupervisor from robots.quickbot import QuickBot from pose import Pose from helpers import Struct from math import pi bot = QuickBot(Pose()) info = bot.get_info() info.color = 0 s = QuickBotSupervisor(Pose(),info) params = Struct() params.goal = theta*180/pi params.velocity = v params.pgain = 1 s.set_parameters(params) tc = 0.033 # 0.033 sec' is the SimIAm time step for step in range(25): # 25 steps bot.move(tc) bot.set_inputs(s.execute(bot.get_info(), tc)) xe,ye,te = s.pose_est xr,yr,tr = bot.get_pose() if xr == 0: xr = 0.0000001 if yr == 0: yr = 0.0000001 if tr == 0: tr = 0.0000001 self.testsuite.respond("{:0.3f},{:0.3f},{:0.3f}".format(abs((xr-xe)/xr), abs((yr-ye)/yr), abs(abs(tr-te)%(2*pi)/tr)))
def start_test(self, challenge): vals = self.parseChallenge(challenge) if 'v' not in vals or 'theta' not in vals: raise CourseraException( "Unknown challenge format. Please contact developers for assistance." ) v = vals['v'] theta = vals['theta'] from supervisors.week2 import QuickBotSupervisor from robots.quickbot import QuickBot from pose import Pose from helpers import Struct from math import pi bot = QuickBot(Pose()) info = bot.get_info() info.color = 0 s = QuickBotSupervisor(Pose(), info) params = Struct() params.goal = theta * 180 / pi params.velocity = v params.pgain = 1 s.set_parameters(params) tc = 0.033 # 0.033 sec' is the SimIAm time step for step in range(25): # 25 steps bot.move(tc) bot.set_inputs(s.execute(bot.get_info(), tc)) xe, ye, te = s.pose_est xr, yr, tr = bot.get_pose() self.testsuite.respond("{:0.3f},{:0.3f},{:0.3f}".format( abs((xr - xe) / xr), abs((yr - ye) / yr), abs(abs(tr - te) % (2 * pi) / tr)))