Open RobotprogrammerNS opened 6 years ago
def compute(self): print 'SpecificWorker.compute...' rot = 0.7 try: ldata = [] d = [] ldata = self.laser_proxy.getLaserData(); for i in range(0,len(ldata)): dis = ldata[i] y = dis.dist d.append(y) d.sort() distance = d[0] print distance if distance < 400: self.differentialrobot_proxy.setSpeedBase(0, rot) time.sleep(1) rot = rot+ 0.5 if rot > 3: rot = 1 self.differentialrobot_proxy.setSpeedBase(70, 0) time.sleep(1) else: self.differentialrobot_proxy.setSpeedBase(100, 0) time.sleep(1) except Ice.Exception, e: traceback.print_exc() print e return True
This is for algorithm. I worked on this with my father. In this coding checks if check if the condition is below the threshold distance If yes then rotate the bot If no proceed forward
def compute(self): print 'SpecificWorker.compute...' rot = 0.7 try: ldata = [] d = [] ldata = self.laser_proxy.getLaserData(); for i in range(0,len(ldata)): dis = ldata[i] y = dis.dist d.append(y) d.sort() distance = d[0] print distance if distance < 400: self.differentialrobot_proxy.setSpeedBase(0, rot) time.sleep(1) rot = rot+ 0.5 if rot > 3: rot = 1 self.differentialrobot_proxy.setSpeedBase(70, 0) time.sleep(1) else: self.differentialrobot_proxy.setSpeedBase(100, 0) time.sleep(1) except Ice.Exception, e: traceback.print_exc() print e return True