def get_version_info(self): """ Getting and displaying information about current system installed on mirto robot :return: """ sys_info_service = self.robot.all_services.get("sys_info") if sys_info_service is not None: log.info("System version info: %s" % sys_info_service.system_version) else: log.warning("Service get_version_info is not enabled!")
def play_tone(self, frequency, duration): """ This function allows to play sound with specific frequency for give duration. :return: None """ tone = self.robot.all_services.get("tone") if tone is not None: tone.play_tone(frequency, duration) log.info("Finish playing tone") else: log.warning("Service tone is not enabled!")
def stop_motors(self) -> None: """ Sending speed value 0 to both motor will cause robot to stop :return: """ motor_1 = self.robot.all_services.get('motor_1') motor_2 = self.robot.all_services.get('motor_2') if motor_1 is not None or motor_1 is not None: motor_1.stop_motor() motor_2.stop_motor() log.info("Motors stopped") else: log.warning("One of the motors is not enabled!")
def set_motors(self, speed0: int, speed1: int) -> None: """ Input is a speed value which is send to robot. Range: -100 -> 100 :param speed0: :param speed1: :return: """ motor_1 = self.robot.all_services.get('motor_1') motor_2 = self.robot.all_services.get('motor_2') if motor_1 or motor_1 is not None: motor_1.set_motor(speed0) motor_2.set_motor(speed1) log.info("Setting motor: '{}': {} motor:'{}': {}".format(motor_1.name, speed0, motor_2.name, speed1)) else: log.warning("One of the motors is not enabled!")
def get_encoders_values(self, delta: bool=False) -> list: """ Function getting encoders count for both wheels. Please provide True if delta value is required. :return: Encoders counts :rtype: list """ encoders = self.robot.all_services.get('encoders') if encoders is not None: values_all = encoders.all_values if delta: return values_all else: return [values_all[0][1], values_all[1][1]] else: log.warning("Service encoders is not enabled!")
def get_right_encoder_values(self, delta: bool=False) -> list: """ Retrieving right wheel encoder values. Please provide True or False if delta values required :param delta: :return: """ encoders = self.robot.all_services.get('encoders') if encoders is not None: right_values_all = encoders.right_values if delta: return right_values_all else: return right_values_all[1] else: log.warning("Service encoders is not enabled!")
def get_ir_sensors_values(self) -> list: """ Receiving ir sensors values, then appending to the list and returning. Please amend the order list if sensors are positioned in different order. :return: """ ir_sensors = self.robot.all_services.get('ir_sensors') if ir_sensors is not None: ir_sensors_order = [0, 1, 2] ir_all_values = [] for num in ir_sensors_order: ir_all_values.append(ir_sensors.ir_all_values[num]) return ir_all_values else: log.warning("Service IR sensors is not enabled!")