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 init_default_parameters(self): """Sets the default PID parameters, goal, and velocity""" p = Struct() p.goal = 45.0 p.velocity = 0.2 p.pgain = 3.0 self.parameters = p
def init_default_parameters(self): """Sets the default PID parameters, goal, and velocity""" p = Struct() p.goal = 45.0 p.velocity = 0.2 p.pgain = 3.0 self.parameters = p
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): 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)))