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 get_parameters(self): """Return a structure with current parameters""" p = Struct() p.wall = Struct() p.wall.direction = self.parameters.direction p.wall.distance = self.parameters.distance p.velocity = self.parameters.velocity p.gains = self.parameters.gains return p
def get_default_parameters(self): """Sets the default PID parameters, goal, and velocity""" p = Struct() p.goal = Struct() p.goal.x = 0.0 p.goal.y = 0.5 p.velocity = Struct() p.velocity.v = 0.2 p.gains = Struct() p.gains.kp = 10.0 p.gains.ki = 2.0 p.gains.kd = 0.0 return p
def init_default_parameters(self): """Sets the default PID parameters, goal, and velocity""" p = Struct() p.goal = Struct() p.goal.x = 1.0 p.goal.y = 1.0 p.velocity = Struct() p.velocity.v = 0.2 p.gains = Struct() p.gains.kp = 4.0 p.gains.ki = 0.1 p.gains.kd = 0.0 self.parameters = p
def init_default_parameters(self): """Sets the default PID parameters, goal, and velocity""" p = Struct() p.goal = Struct() p.goal.x = 1.0 p.goal.y = 1.0 p.velocity = Struct() p.velocity.v = 0.2 p.gains = Struct() p.gains.kp = 10.0 p.gains.ki = 2.0 p.gains.kd = 0.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 init_default_parameters(self): """Sets the default PID parameters, goal, and velocity""" p = Struct() p.goal = Struct() p.goal.x = 1.0 p.goal.y = 1.0 p.velocity = Struct() p.velocity.v = 0.2 p.gains = Struct() p.gains.kp = 4.0 p.gains.ki = 0.1 p.gains.kd = 0.0 p.ga_path = [] p.point_cnt = 0 self.parameters = p
def init_default_parameters(self): """Sets the default PID parameters, goal, and velocity""" p = Struct() p.goal = Struct() p.goal.x = 1.0 p.goal.y = 1.0 p.velocity = Struct() p.velocity.v = 0.2 p.gains = Struct() p.gains.kp = 10.0 p.gains.ki = 2.0 p.gains.kd = 0.0 p.ga_path = [] p.point_cnt = 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): 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)))