def start_program(req): global prog_timer global current_item global state_manager global ph global art global iters program = art.load_program(req.program_id) if program is None: return startProgramResponse(success=False) if not ph.load(program): return startProgramResponse(success=False) current_item = ph.get_first_item_id() iters = 0 state_manager.set_system_state(InterfaceState.STATE_PROGRAM_RUNNING) prog_timer = rospy.Timer(rospy.Duration(4), timer_callback) return startProgramResponse(success=True)
def start_program(req): global prog_timer global program global current_item global state_manager prog_srv = rospy.ServiceProxy('/art/db/program/get', getProgram) try: resp = prog_srv(req.program_id) program = resp.program except rospy.ServiceException, e: print "Service call failed: " + str(e) program = None return startProgramResponse(success=False)
def program_start_cb(self, req): resp = startProgramResponse() if self.executing_program: resp.success = False resp.error = 'Program already running' return resp rospy.loginfo('Loading program ' + str(req.program_id) + ' from db...') prog_srv = rospy.ServiceProxy('/art/db/program/get', getProgram) try: presp = prog_srv(req.program_id) except rospy.ServiceException, e: rospy.logerr('Cannot get program :(') resp.success = False resp.error = 'Cannot get program' return resp
def program_start_cb(self, req): resp = startProgramResponse() if self.executing_program: resp.success = False resp.error = 'Program already running' return resp rospy.loginfo('Loading program ' + str(req.program_id) + ' from db...') program = self.art.load_program(req.program_id) if not self.ph.load(program): resp.success = False resp.error = 'Cannot get program' return resp rospy.loginfo('Starting program') self.executing_program = True resp.success = True return resp
prog_srv = rospy.ServiceProxy('/art/db/program/get', getProgram) try: resp = prog_srv(req.program_id) program = resp.program except rospy.ServiceException, e: print "Service call failed: " + str(e) program = None return startProgramResponse(success=False) current_item = 0 state_manager.set_system_state(InterfaceState.STATE_PROGRAM_RUNNING) prog_timer = rospy.Timer(rospy.Duration(4), timer_callback) return startProgramResponse(success=True) # def stop_program(req): # # global prog_timer # prog_timer.shutdown() # # TODO state_manager.set_syst_state() # return stopProgramResponse(success=True) def callback(old_state, new_state, flags): print "Got state update" def main(args):