def _request_angular_move_(self, angle_ns, angle_ew): request = tracker_pb2.ControlRequest(\ authority_level = self.authority_level, description = self.description, \ move_type = tracker_pb2.ControlRequest.ANGLE) request.angle.ns = angle_ns request.angle.ew = angle_ew self._request_move_and_block_(request)
def _request_position_move_(self, pos_ns, pos_ew): request = tracker_pb2.ControlRequest(\ authority_level = self.authority_level, description = self.description, \ move_type = tracker_pb2.ControlRequest.POSITION) request.position.ns = pos_ns request.position.ew = pos_ew self._request_move_and_block_(request)
def _control_iterator_(self): self.logger.info("Sending initial control request") yield tracker_pb2.ControlRequest(authority_level = self.authority_level, description = self.description) while self._is_ok_() and self.retain_control: if self.control_requests_queue.empty(): time.sleep(1.0) else: request = self.control_requests_queue.get() yield request
def __init__(self, server, authority_level, description, client_response_cb = None, timeout = 10.0): self.authority_level = authority_level self.description = description self.stub = server self.have_tracker_control = False self._move_response_callback_ = None self.client_response_cb = client_response_cb self.logger = logging.getLogger(__name__) self.logger.propagate = True self.retain_control = True self.control_thread = Thread(target = self._tracker_control_, \ args=(self.on_response,)) self.control_requests_queue = Queue() self.control_thread.start() count = 0.0 while not self.have_tracker_control and count < timeout: count += 1 request = tracker_pb2.ControlRequest(authority_level = self.authority_level, description = self.description) self.control_requests_queue.put(request) time.sleep(1.0) if not self.have_tracker_control: raise ControlDisruption("Getting tracker control failed") self.logger.info("Tracker control succeeded")
def in_control(self): request = tracker_pb2.ControlRequest(\ authority_level = self.authority_level, description = self.description) self._request_move_and_block_(request) return self.have_tracker_control
def _request_direction_move_(self, direction): request = tracker_pb2.ControlRequest(\ authority_level = self.authority_level, description = self.description, \ move_type = tracker_pb2.ControlRequest.DURATION) request.direction = direction self._request_move_and_block_(request)
def _stop_(self): request = tracker_pb2.ControlRequest(\ authority_level = self.authority_level, description = self.description, \ move_type = tracker_pb2.ControlRequest.STOP) self._request_move_and_block_(request)