def test_leg_enslavement(self, dcm, mem, zero_pos, test_leg_dico,
                             test_time, test_limit):
        """
        Test joint enslavement for HipPitch and KneePitch.
        Error must be lower than a fixed limit.
        """
        # Objects creation
        hippitch_position_actuator = test_leg_dico["hipActuator"]
        hippitch_position_sensor = test_leg_dico["hipSensor"]
        kneepitch_position_actuator = test_leg_dico["kneeActuator"]
        kneepitch_position_sensor = test_leg_dico["kneeSensor"]
        logger = test_leg_dico["logger"]

        # Flag initialization
        logger.flag = True

        # Going to initial position
        subdevice.multiple_set(dcm, mem, zero_pos, wait=True)

        # Behavior of the tested part
        hippitch_position_actuator.explore(2 * test_time)
        kneepitch_position_actuator.explore(2 * test_time, max_to_min=False)

        # Timer creation just before test loop
        timer = qha_tools.Timer(dcm, 4 * test_time)

        # Test loop
        while timer.is_time_not_out():
            hip_act_rad = hippitch_position_actuator.value
            hip_act_deg = math.degrees(hip_act_rad)
            hip_sensor_rad = hippitch_position_sensor.value
            hip_sensor_deg = math.degrees(hip_sensor_rad)

            knee_act_rad = kneepitch_position_actuator.value
            knee_act_deg = math.degrees(knee_act_rad)
            knee_sensor_rad = kneepitch_position_sensor.value
            knee_sensor_deg = math.degrees(knee_sensor_rad)

            error_hip = hip_act_deg - hip_sensor_deg
            error_knee = knee_act_deg - knee_sensor_deg

            logger.log(("Time", timer.dcm_time() / 1000.),
                       ("HipPitchActuator", hip_act_deg),
                       ("HipPitchSensor", hip_sensor_deg),
                       ("ErrorHip", error_hip),
                       ("KneePitchActuator", knee_act_deg),
                       ("KneePitchSensor", knee_sensor_deg),
                       ("ErrorKnee", error_knee), ("Eps", test_limit),
                       ("-Eps", test_limit * -1.),
                       ("HipPitchActuator+Eps", hip_act_deg + test_limit),
                       ("HipPitchActuator-Eps", hip_act_deg - test_limit),
                       ("KneePitchActuator+Eps", knee_act_deg + test_limit),
                       ("KneePitchActuator-Eps", knee_act_deg - test_limit))

            if abs(error_hip) > test_limit or abs(error_knee) > test_limit:
                logger.flag = False

        assert logger.flag
    def test_wheels_enslavement(self, dcm, mem, zero_pos, test_wheels_dico,
                                stiff_robot_wheels, test_time,
                                test_wheels_limit):
        """
        Test wheels enslavement.
        Error must be lower than a fixed limit (here test_wheels_limit).
        """
        # Objects creation
        wheel_speed_actuator = test_wheels_dico["wheelActuator"]
        wheel_speed_sensor = test_wheels_dico["wheelSensor"]
        logger = test_wheels_dico["logger"]
        sliding_avg = qha_tools.SlidingAverage(3)

        # Flag initialization
        logger.flag = True

        # Going to initial position
        #subdevice.multiple_set(dcm, mem, zero_pos, wait=True)

        # Behavior of the tested part
        wheel_speed_actuator.trapeze(0.1,
                                     1000.,
                                     2000.,
                                     sens="positive",
                                     second_invert_trapeze=True)

        # Timer creation just before test loop
        timer = qha_tools.Timer(dcm, 4 * test_time)

        # Test loop
        while timer.is_time_not_out():
            speed_actuator = wheel_speed_actuator.value
            speed_sensor = wheel_speed_sensor.value

            # Calculating an averaged sensor value on 3 points. The error can
            # dynamically be high because of the wheel mechanic.
            sliding_avg.point_add(speed_sensor)
            speed_sensor_sa = sliding_avg.calc()

            error = speed_actuator - speed_sensor
            error_sa = speed_actuator - speed_sensor_sa
            actuator = wheel_speed_actuator.value

            # Logging usefull information
            logger.log(("Time", timer.dcm_time() / 1000.),
                       ("Actuator", actuator), ("Sensor", speed_sensor),
                       ("SpeedSA", speed_sensor_sa), ("Error", error),
                       ("ErrorSA", error_sa), ("Eps", test_wheels_limit),
                       ("-Eps", test_wheels_limit * -1.),
                       ("Actuator+Eps", actuator + test_wheels_limit),
                       ("Actuator-Eps", actuator - test_wheels_limit))

            # Checking that enslavement is good
            if abs(error_sa) > test_wheels_limit:
                logger.flag = False

        assert logger.flag
    def test_joint_enslavement(self, dcm, mem, zero_pos, test_objects_dico,
                               test_time):
        """
        Test joint enslavement.
        Error must be lower than a fixed limit.

        @type  dcm        : object
        @param dcm        : proxy to DCM
        @type mem         : object
        @param mem        : proxy to ALMemory
        @type zero_pos    : dictionnary
        @param zero_pos   : dictionnary {"ALMemory key":value} from config file.
        @type joint       : string
        @param joint      : string describing the current joint.
        @type test_time   : integer
        @param test_time  : time to wait to test a joint enslavement [ms].
        """
        # Objects creation
        joint_position_actuator = test_objects_dico["jointActuator"]
        joint_position_sensor = test_objects_dico["jointSensor"]
        logger = test_objects_dico["logger"]
        test_limit = test_objects_dico["joint_test_limit"]

        # Flag initialization
        logger.flag = True

        # Going to initial position
        subdevice.multiple_set(dcm, mem, zero_pos, wait=True)

        # Going to min position to have a complete exploration
        joint_position_actuator.go_to(dcm, "min")

        # Behavior of the tested part
        joint_position_actuator.explore(2 * test_time)

        # Timer creation just before test loop
        timer = qha_tools.Timer(dcm, 4 * test_time)

        # Test loop
        while timer.is_time_not_out():
            error = joint_position_actuator.value - joint_position_sensor.value
            actuator_degrees = math.degrees(joint_position_actuator.value)
            logger.log(("Time", timer.dcm_time() / 1000.),
                       ("Actuator", actuator_degrees),
                       ("Sensor", math.degrees(joint_position_sensor.value)),
                       ("Error", math.degrees(error)), ("Eps", test_limit),
                       ("-Eps", test_limit * -1.),
                       ("Actuator+Eps", actuator_degrees + test_limit),
                       ("Actuator-Eps", actuator_degrees - test_limit))

            if abs(error) > math.radians(test_limit):
                logger.flag = False

        assert logger.flag
Example #4
0
def test_head_sensor_detection(dcm, mem, location, time_to_touch):
    flag_expected = False
    timer = qha_tools.Timer(dcm, time_to_touch)
    sensor = subdevice.HeadTouchSensor(dcm, mem, location)
    print
    print
    print "Touch " + location + " Head sensor"
    while timer.is_time_not_out() and flag_expected is False:
        if sensor.value == 1.0:
            flag_expected = True
    assert flag_expected
    time.sleep(0.2)
Example #5
0
    def logging(thread_flag, plot, plot_server, max_allowed_temperatures):
        """Logging temperatures while the test class is not finished."""
        timer = qha_tools.Timer(dcm, 1000)
        while not thread_flag.is_set():
            loop_time = timer.dcm_time() / 1000.
            list_of_param = [("Time", loop_time)]
            for joint_temperature in joint_temperature_object.values():
                measured_temperature = joint_temperature.value
                sa_object = sa_objects[joint_temperature.short_name]
                temperature_header = joint_temperature.header_name
                temperature_sa_header = temperature_header + "_sa"
                temperature_max_header = temperature_header + "_max"
                temperature_max = max_allowed_temperatures[
                    joint_temperature.short_name]

                sa_object.point_add(measured_temperature)
                sa_temperature = sa_object.calc()

                new_tuple = (temperature_header, measured_temperature)
                sa_tuple = (temperature_sa_header, sa_temperature)
                max_tmp_tuple = (temperature_max_header, temperature_max)

                list_of_param.append(new_tuple)
                list_of_param.append(sa_tuple)
                list_of_param.append(max_tmp_tuple)

                # real time plot
                if plot:
                    plot_server.add_point(temperature_sa_header, loop_time,
                                          sa_temperature)
                    plot_server.add_point(temperature_max_header, loop_time,
                                          temperature_max)

            logger.log_from_list(list_of_param)

            time.sleep(5.0)
def test_hands(st_hands, dcm, left_hand_sensor, right_hand_sensor,
               test_time_fp):
    timer = qha_tools.Timer(dcm, test_time_fp)
    while timer.is_time_not_out():
        assert left_hand_sensor.value == 0
        assert right_hand_sensor.value == 0
    def test_joint_current_limitation(self, dcm, mem, parameters, joint,
                                      result_base_folder, rest_pos,
                                      stiffness_off, plot, plot_server):
        # logger initialization
        log = logging.getLogger('test_joint_current_limitation')

        # erasing real time plot
        plot_server.curves_erase()

        # flags initialization
        flag_loop = True  # test loop stops when this flag is False
        flag_joint = True  # giving test result
        flag_current_limit_low_exceeded = False

        # checking that ALMemory key MinMaxChange Allowed = 1
        if int(mem.getData("RobotConfig/Head/MinMaxChangeAllowed")) != 1:
            flag_loop = False
            log.error("MinMaxChangeAllowed ALMemory key missing")

        # test parameters
        test_params = parameters
        joint_position_actuator = joint.position.actuator
        joint_position_sensor = joint.position.sensor
        joint_temperature_sensor = joint.temperature
        joint_current_sensor = joint.current
        slav = qha_tools.SlidingAverage(test_params["sa_nb_points"])
        logger = qha_tools.Logger()

        # Going to initial position
        subdevice.multiple_set(dcm, mem, rest_pos, wait=True)
        # unstiffing all the other joints to avoid leg motors overheat
        subdevice.multiple_set(dcm, mem, stiffness_off, wait=False)
        time.sleep(0.1)

        # stiffing the joint we want to test
        joint.hardness.qqvalue = 1.0

        # keeping initial joint min and max
        joint_initial_maximum = joint_position_actuator.maximum
        joint_initial_minimum = joint_position_actuator.minimum

        # put joint to its initial maximum in 3 seconds
        if joint_position_actuator.short_name in\
         ("HipPitch", "RShoulderRoll", "RElbowRoll"):
            joint_position_actuator.qvalue = (joint_initial_minimum, 3000)
        else:
            joint_position_actuator.qvalue = (joint_initial_maximum, 3000)
        qha_tools.wait(dcm, 3000)

        # setting current limitations
        joint_max_current = joint_current_sensor.maximum
        joint_min_current = joint_current_sensor.minimum
        delta_current = joint_max_current - joint_min_current
        k_sup = test_params["limit_factor_sup"]
        k_inf = test_params["limit_factor_inf"]
        current_limit_high = joint_max_current + k_sup * delta_current
        current_limit_low = joint_max_current - k_inf * delta_current

        # setting temperature limitatons
        joint_temperature_min = joint_temperature_sensor.minimum

        # setting new min and max out of the mechanical stop
        joint_new_maximum = \
            joint_initial_maximum + \
            math.radians(test_params["limit_extension"])

        joint_new_minimum = \
            joint_initial_minimum - \
            math.radians(test_params["limit_extension"])

        joint_position_actuator.maximum = [[[
            joint_new_maximum, dcm.getTime(0)
        ]], "Merge"]
        joint_position_actuator.minimum = [[[
            joint_new_minimum, dcm.getTime(0)
        ]], "Merge"]

        if joint_position_actuator.short_name in\
         ("HipPitch", "RShoulderRoll", "RElbowRoll"):
            joint_position_actuator.qvalue = (joint_new_minimum, 1000)
        else:
            joint_position_actuator.qvalue = (joint_new_maximum, 1000)

        timer = qha_tools.Timer(dcm, test_params["test_time"])
        timer_limit = qha_tools.Timer(dcm, test_params["test_time_limit"])

        # test loop
        while flag_loop and timer.is_time_not_out():
            try:
                loop_time = timer.dcm_time() / 1000.
                joint_temperature = joint_temperature_sensor.value
                joint_current = joint_current_sensor.value
                slav.point_add(joint_current)
                joint_current_sa = slav.calc()

                if not flag_current_limit_low_exceeded and\
                    joint_current_sa > current_limit_low:
                    flag_current_limit_low_exceeded = True
                    log.info("Current limit low exceeded")

                if joint_current_sa > current_limit_high:
                    flag_joint = False
                    log.warning("Current limit high overshoot")

                if flag_current_limit_low_exceeded and\
                    joint_current_sa < current_limit_low:
                    flag_joint = False
                    log.warning("Current lower than current limit low")

                if timer_limit.is_time_out() and not \
                    flag_current_limit_low_exceeded:
                    flag_joint = False
                    log.info("Timer limit finished and "+\
                        "current limit low not exceeded")

                # out of test loop if temperature is higher than min temperature
                if joint_temperature >= joint_temperature_min:
                    flag_loop = False
                    log.info("Temperature higher than Min temperature")
                    log.info("Test finished")

                logger.log(("Time", timer.dcm_time() / 1000.),
                           ("Current", joint_current),
                           ("CurrentSA", joint_current_sa),
                           ("CurrentLimitHigh", current_limit_high),
                           ("CurrentLimitLow", current_limit_low),
                           ("MaxAllowedCurrent", joint_max_current),
                           ("Temperature", joint_temperature),
                           ("TemperatureMin", joint_temperature_min),
                           ("Command", joint_position_actuator.value),
                           ("Position", joint_position_sensor.value))

                if plot:
                    plot_server.add_point("Current", loop_time, joint_current)
                    plot_server.add_point("CurrentSA", loop_time,
                                          joint_current_sa)
                    plot_server.add_point("CurrentLimitHigh", loop_time,
                                          current_limit_high)
                    plot_server.add_point("CurrentLimitLow", loop_time,
                                          current_limit_low)
                    plot_server.add_point("MaxAllowedCurrent", loop_time,
                                          joint_max_current)
                    plot_server.add_point("Temperature", loop_time,
                                          joint_temperature)
                    plot_server.add_point("TemperatureMin", loop_time,
                                          joint_temperature_min)

            except KeyboardInterrupt:
                flag_loop = False  # out of test loop
                log.info("KeyboardInterrupt from user")

        log.info("OUT OF TEST LOOP")

        result_file_path = "/".join([
            result_base_folder, joint_position_actuator.subdevice_type,
            joint_position_actuator.short_name + "_" + str(flag_joint)
        ]) + ".csv"
        logger.log_file_write(result_file_path)

        joint_position_actuator.maximum = [[[
            joint_initial_maximum, dcm.getTime(0)
        ]], "Merge"]
        joint_position_actuator.minimum = [[[
            joint_initial_minimum, dcm.getTime(0)
        ]], "Merge"]

        plot_server.curves_erase()

        assert flag_joint
        assert flag_current_limit_low_exceeded
Example #8
0
    def test_fan_01(self, dcm, mem, plot, test_time, cycle_number,
                    result_base_folder, threshold):
        """
        FanBoard basic specification check.
        When fan actuator = 1 and fan speed is lower than the hald of its
        nominal speed, fan status must be set to 1.
        """
        # flags initialization
        fan_state = True

        # plot_server initialisation
        if plot:
            plot_server = socket_connection.Server()

        # objects initialization
        fan_hardness_actuator = subdevice.FanHardnessActuator(dcm, mem)
        right_fan_frequency = subdevice.FanFrequencySensor(dcm, mem, "Right")
        middle_fan_frequency = subdevice.FanFrequencySensor(dcm, mem, "Mid")
        left_fan_frequency = subdevice.FanFrequencySensor(dcm, mem, "Left")
        fan = subdevice.FanStatus(dcm, mem)

        # creating fan cycling behavior thread
        fan_behavior = Thread(target=fan_utils.fan_cycle,
                              args=(dcm, mem, cycle_number))

        # starting behavior
        fan_behavior.start()

        # logger and timer objects creation
        logger = qha_tools.Logger()
        timer = qha_tools.Timer(dcm, 1000)

        # test loop
        while fan_behavior.isAlive():
            fan_hardness_value = fan_hardness_actuator.value
            right_fan_frequency_value = right_fan_frequency.value
            middle_fan_frequency_value = middle_fan_frequency.value
            left_fan_frequency_value = left_fan_frequency.value
            fan_status = fan.status
            dcm_time = timer.dcm_time() / 1000.

            # logging informations
            logger.log(
                ("Time", dcm_time),
                (fan_hardness_actuator.header_name, fan_hardness_value),
                (right_fan_frequency.header_name, right_fan_frequency_value),
                (middle_fan_frequency.header_name, middle_fan_frequency_value),
                (left_fan_frequency.header_name, left_fan_frequency_value),
                (fan.header_name, fan_status))

            # for real time graphs
            if plot:
                plot_server.add_point(fan_hardness_actuator.header_name,
                                      dcm_time, fan_hardness_value)
                plot_server.add_point(right_fan_frequency.header_name,
                                      dcm_time, right_fan_frequency_value)
                plot_server.add_point(middle_fan_frequency.header_name,
                                      dcm_time, middle_fan_frequency_value)
                plot_server.add_point(left_fan_frequency.header_name, dcm_time,
                                      left_fan_frequency_value)
                plot_server.add_point(fan.header_name, dcm_time, fan_status)

            # checking that fan status works well
            if fan_hardness_value == 1:
                if right_fan_frequency_value < threshold["RightFan"] and \
                    fan_status == 0:
                    fan_state = False
                if left_fan_frequency_value < threshold["LeftFan"] and \
                    fan_status == 0:
                    fan_state = False
                if middle_fan_frequency_value < threshold["MiddleFan"] and \
                    fan_status == 0:
                    fan_state = False

        file_name = "_".join(["Fan", str(fan_state)])
        result_file_path = "/".join([result_base_folder, file_name]) + ".csv"
        logger.log_file_write(result_file_path)

        assert fan_state
Example #9
0
def test_damage(dcm, mem, kill_motion):
    """
    Test robot docking/undocking to check damages
    """
    time.sleep(10)
    # Test parameters
    parameters = qha_tools.read_section("test_pod.cfg",
                                        "DockCyclingParameters")

    # Objects creation
    motion = subdevice.WheelsMotion(dcm, mem, float(parameters["speed"][0]))

    robot_on_charging_station = subdevice.ChargingStationSensor(dcm, mem)
    wheelfr_temperature_sensor = subdevice.WheelTemperatureSensor(
        dcm, mem, "WheelFR")
    wheelfl_temperature_sensor = subdevice.WheelTemperatureSensor(
        dcm, mem, "WheelFL")
    back_bumper_sensor = subdevice.Bumper(dcm, mem, "Back")

    # Internal flags
    cycles_done = 0
    cycles_with_bumper_ok = 0
    list_bumper_nok = []
    unlock_bumper_status = 0
    bumper_blocked_flag = False
    detection = 1
    loose_connexion_flag = 0
    stop_cycling_flag = False

    # Flag initialization
    flag_detection = True
    flag_bumper = True
    flag_keep_connexion = True

    timer = qha_tools.Timer(dcm, 10)
    log_file = open(parameters["cycling_cvs_name"][0], 'w')
    log_file.write(
        "CyclesDone,CyclesDoneWithBumperOk," +
        "Detection,LooseConnection,UnlockBumperStatus,LockBumperStatus\n")

    plot_log = Plot(dcm, mem, parameters["easy_plot_csv_name"][0])
    plot_log.start()

    # Cyclage
    # If the robot is not on the pod or bumper not activated, test don't start
    if robot_on_charging_station.value == 0:
        print "Put the robot on the pod\n"
        stop_cycling_flag = True
        flag_detection = False
        flag_bumper = False
        flag_keep_connexion = False

    while stop_cycling_flag == False:
        # Robot moves front
        cycles_done += 1
        motion.move_x(float(parameters["distance_front"][0]))
        qha_tools.wait(dcm, int(parameters["time_wait_out_the_pod"][0]) * 1000)
        unlock_bumper_status = back_bumper_sensor.value
        # Verification of bumper
        if back_bumper_sensor.value == 1:
            bumper_blocked_flag = True
        else:
            bumper_blocked_flag = False

        # Robot moves back
        motion.move_x(float(parameters["distance_back"][0]))
        motion.stiff_wheels(["WheelFR", "WheelFL", "WheelB"],
                            float(parameters["stiffness_wheels_value"][0]))
        qha_tools.wait(
            dcm,
            float(parameters["time_wait_before_verify_detection"][0]) * 1000)
        # Verification of connexion
        t_init = timer.dcm_time()
        test_time = 0
        while robot_on_charging_station.value == 1 and\
                test_time < int(parameters["time_wait_on_the_pod"][0]) * 1000:
            detection = 1
            loose_connexion_flag = 0
            test_time = timer.dcm_time() - t_init
        # If no detection
        if test_time == 0:
            detection = 0
        # If connexion is lost
        elif test_time < int(parameters["time_wait_on_the_pod"][0]) * 1000:
            loose_connexion_flag = 1
            flag_keep_connexion = False
        # Verification of bumper
        if back_bumper_sensor.value == 1 and bumper_blocked_flag == False:
            cycles_with_bumper_ok += 1
        else:
            list_bumper_nok.append(cycles_done)

        # Log data
        line_to_write = ",".join([
            str(cycles_done),
            str(cycles_with_bumper_ok),
            str(detection),
            str(loose_connexion_flag),
            str(unlock_bumper_status),
            str(back_bumper_sensor.value)
        ])
        line_to_write += "\n"
        log_file.write(line_to_write)
        log_file.flush()

        # Wait if temperature of wheels too hot
        while wheelfr_temperature_sensor.value > \
                int(parameters["wheels_temperature_limit"][0]) or\
                wheelfl_temperature_sensor.value > \
                int(parameters["wheels_temperature_limit"][0]):
            qha_tools.wait(dcm, int(parameters["time_wait_wheels cooled"][0]))

        # End if nb_cycles is reached
        if cycles_done == int(parameters["nb_cycles"][0]):
            stop_cycling_flag = True

    if len(list_bumper_nok) > cycles_done / 100:
        flag_bumper = False

    log_file.close()
    plot_log.stop()
    print("Cycles done = " + str(cycles_done))
    print("Cycles done with bumper ok = " + str(cycles_with_bumper_ok))

    assert flag_detection
    assert flag_bumper
    assert flag_keep_connexion
    def test_fuseboard_temperature(self, dcm, mem, fuse, wheel_objects,
                                   multi_fuseboard_ambiant_tmp,
                                   multi_fuseboard_total_current, test_time,
                                   joint_limit_extension, result_base_folder,
                                   plot, plot_server):
        """
        If on a fuse max temperature is reached, HAL is supposed to cut the
        stiffness on all the joints behind the considered fuse.
        To add in /media/internal/DeviveInternalHeadGeode.xml before the test:
        <Preference name="Key15"
        memoryName="RobotConfig/Head/MinMaxChangeAllowed" description=""
        value="1" type="string" />
        """
        # logger initialization
        log = logging.getLogger('MULTIFUSEBOARD_PERF_HW_01')

        # erasing real time curves
        if plot:
            plot_server.curves_erase()

        # flag initialization
        flag_loop = True
        flag_key = True
        fuse_state = True
        flag_ambiant_temperature = True
        flag_fuse_status = True
        flag_first_overshoot = False
        flag_protection_on = False

        # flags
        (flag1, flag2, flag3) = (False, False, False)

        # objects creation
        fuse_temperature = fuse["FuseTemperature"]
        fuse_current = fuse["FuseCurrent"]
        fuse_voltage = fuse["FuseVoltage"]
        fuse_resistor = fuse["FuseResistor"]
        battery = subdevice.BatteryChargeSensor(dcm, mem)

        log.info("")
        log.info("***********************************************")
        log.info("Testing fuse : " + str(fuse_temperature.part))
        log.info("***********************************************")
        log.info("")

        # checking that ALMemory key MinMaxChange Allowed = 1
        if int(mem.getData("RobotConfig/Head/MinMaxChangeAllowed")) != 1:
            flag_loop = False
            flag_key = False
            log.error("MinMaxChangeAllowed ALMemory key missing")

        # setting fuse temperature min and max
        fuse_temperature_max = fuse_temperature.maximum
        fuse_temperature_min = fuse_temperature.minimum
        fuse_temperature_mid = (fuse_temperature_max +
                                fuse_temperature_min) / 2.

        # setting fuse temperature min and max for hysteresis
        fuse_temperature_max_hyst = fuse_temperature_max - 10
        log.debug("fuse_temperature_max_hyst = " +
                  str(fuse_temperature_max_hyst))
        fuse_temperature_min_hyst = fuse_temperature_min - 10
        log.debug("fuse_temperature_min_hyst = " +
                  str(fuse_temperature_min_hyst))
        fuse_temperature_mid_hyst = fuse_temperature_mid - 10
        log.debug("fuse_temperature_mid_hyst = " +
                  str(fuse_temperature_mid_hyst))

        # position dictionnary creation with normal min or max
        state = \
            qha_tools.read_section(
                "multifuse_scenario4.cfg", fuse_temperature.part)
        # creating joint list
        joint_list = state.keys()
        log.info("Joints to use are : " + str(joint_list))

        # max stiffness is set on all joints except for LegFuse
        if fuse_temperature.part == "LegFuse":
            # stiff joints
            qha_tools.stiff_joints_proportion(dcm, mem, joint_list, 1.0)
            # stiff wheels

            for wheel in wheel_objects:
                wheel.stiffness.qqvalue = 1.0
                wheel.speed.actuator.qvalue = \
                (wheel.speed.actuator.maximum, 5000)
        else:
            qha_tools.stiff_joints_proportion(dcm, mem, joint_list, 1.0)

        # defining increment in radians
        increment = math.radians(joint_limit_extension)

        # modifying max or min position and put the joint in that position
        # it makes current rise a lot
        for joint, value in state.items():
            joint_object = subdevice.JointPositionActuator(dcm, mem, joint)
            if value[0] == 'max':
                new_maximum_angle = joint_object.maximum + increment
            else:
                new_maximum_angle = joint_object.minimum - increment
            joint_object.maximum = [[[new_maximum_angle,
                                      dcm.getTime(0)]], "Merge"]
            joint_object.qvalue = (new_maximum_angle, 10000)

        # logger creation
        logger = qha_tools.Logger()

        # list object creation
        joint_hardness_list = \
            [subdevice.JointHardnessActuator(dcm, mem, x) for x in joint_list]
        joint_current_list = \
            [subdevice.JointCurrentSensor(dcm, mem, joint)
             for joint in joint_list]

        # loop timer creation
        timer = qha_tools.Timer(dcm, test_time)

        # test loop
        while flag_loop and timer.is_time_not_out():
            try:
                loop_time = timer.dcm_time() / 1000.
                fuse_temperature_status = fuse_temperature.status
                fuse_temperature_value = fuse_temperature.value
                fuse_current_value = fuse_current.value
                fuse_voltage_value = fuse_voltage.value
                fuse_resistor_value = fuse_resistor.value
                fuse_resistor_calculated = fuse_voltage_value / \
                    fuse_current_value
                battery_total_voltage = battery.total_voltage
                multifuseboard_ambiant_tmp = \
                    multi_fuseboard_ambiant_tmp.value
                multifuseboard_total_current = \
                    multi_fuseboard_total_current.value
                stiffness_decrease = mem.getData(
                    "Device/SubDeviceList/FuseProtection/"+\
                    "StiffnessDecrease/Value")
                stiffness_decrease_immediate = mem.getData(
                    "Device/SubDeviceList/FuseProtection/"+\
                    "StiffnessDecreaseImmediate/Value")

                listeofparams = [("Time", loop_time),
                                 ("MultifuseBoardAmbiantTemperature",
                                  multifuseboard_ambiant_tmp),
                                 ("MultifuseBoardTotalCurrent",
                                  multifuseboard_total_current),
                                 ("FuseTemperature", fuse_temperature_value),
                                 ("FuseCurrent", fuse_current_value),
                                 ("FuseVoltage", fuse_voltage_value),
                                 ("FuseResistor", fuse_resistor_value),
                                 ("FuseResistorCalculated",
                                  fuse_resistor_calculated),
                                 ("BatteryVoltage", battery_total_voltage),
                                 ("Status", fuse_temperature_status),
                                 ("StiffnessDecrease", stiffness_decrease),
                                 ("StiffnessDecreaseImmediate",
                                  stiffness_decrease_immediate),
                                 ("FuseTemperatureMin", fuse_temperature_min),
                                 ("FuseTemperatureMid", fuse_temperature_mid),
                                 ("FuseTemperatureMax", fuse_temperature_max)]
                for joint_hardness in joint_hardness_list:
                    new_tuple = \
                        (joint_hardness.header_name, joint_hardness.value)
                    listeofparams.append(new_tuple)
                for joint_current in joint_current_list:
                    new_tuple = (joint_current.header_name,
                                 joint_current.value)
                    listeofparams.append(new_tuple)
                for wheel in wheel_objects:
                    new_tuple = (wheel.short_name + "_Current",
                                 wheel.current.value)
                    listeofparams.append(new_tuple)

                # Logging informations
                logger.log_from_list(listeofparams)

                # for real time plot
                if plot:
                    plot_server.add_point("MultifuseBoardAmbiantTemperature",
                                          loop_time,
                                          multifuseboard_ambiant_tmp)
                    plot_server.add_point("MultifuseBoardTotalCurrent",
                                          loop_time,
                                          multifuseboard_total_current)
                    plot_server.add_point("FuseTemperature", loop_time,
                                          fuse_temperature_value)
                    plot_server.add_point("FuseCurrent", loop_time,
                                          fuse_current_value)
                    plot_server.add_point("FuseVoltage", loop_time,
                                          fuse_voltage_value)
                    plot_server.add_point("FuseResistor", loop_time,
                                          fuse_resistor_value)
                    plot_server.add_point("FuseResistorCalculated", loop_time,
                                          fuse_resistor_calculated)
                    plot_server.add_point("BatteryVoltage", loop_time,
                                          battery_total_voltage)
                    plot_server.add_point("Status", loop_time,
                                          fuse_temperature_status)
                    plot_server.add_point("StiffnessDecrease", loop_time,
                                          stiffness_decrease)
                    plot_server.add_point("StiffnessDecreaseImmediate",
                                          loop_time,
                                          stiffness_decrease_immediate)

                # Checking REQ_FUSE_TEMPERATURE_002
                if fuse_temperature_value < multifuseboard_ambiant_tmp:
                    flag_ambiant_temperature = False
                    log.info("Fuse temperature is lower than MultiFuseBoard" +\
                     "ambiant temperature")

                # Checking REQ_FUSE_PERF_003
                # Fuse status evolves correctly with its estimated temperature
                # Hysteresis works correctly too
                if fuse_temperature_value >= fuse_temperature_min:
                    flag1 = True
                if fuse_temperature_mid < fuse_temperature_value <=\
                 fuse_temperature_max:
                    flag2 = True
                if fuse_temperature_value >= fuse_temperature_max:
                    flag3 = True

                if (flag1, flag2, flag3) == (False, False, False):
                    theorical_status = 0
                elif (flag1, flag2, flag3) == (True, False, False):
                    theorical_status = 1
                elif (flag1, flag2, flag3) == (True, True, False):
                    theorical_status = 2
                elif (flag1, flag2, flag3) == (True, True, True):
                    theorical_status = 3

                if theorical_status == 3 and fuse_temperature_value <=\
                 fuse_temperature_max_hyst:
                    theorical_status = 2
                    flag3 = False
                if theorical_status == 2 and fuse_temperature_value <=\
                 fuse_temperature_mid_hyst:
                    theorical_status = 1
                    flag2 = False
                if theorical_status == 1 and fuse_temperature_value <=\
                 fuse_temperature_min_hyst:
                    theorical_status = 0
                    flag1 = False

                if fuse_temperature_status != theorical_status:
                    log.warning("!!! Fuse status problem !!!")
                    log.info("fuse temperature = " +\
                     str(fuse_temperature_value))
                    log.info("fuse status = " + str(fuse_temperature_status))
                    log.info("fuse theorical status = " +
                             str(theorical_status))
                    flag_fuse_status = False

                # Indicating fuse first max temperature overshoot
                if fuse_temperature_value >= fuse_temperature_max and not\
                flag_first_overshoot:
                    flag_first_overshoot = True
                    log.info("First temperature overshoot")
                    timer_overshoot = qha_tools.Timer(dcm, 200)

                # Indicating that protection worked
                # Set stiffness actuator to 0 to let fuse cool down
                if flag_first_overshoot and timer_overshoot.is_time_out()\
                and not flag_protection_on and\
                (stiffness_decrease_immediate == 0 or\
                stiffness_decrease == 0):
                    log.info("Flag protection ON")
                    flag_protection_on = True
                    log.info("Concerned joints pluggin activated")
                    qha_tools.unstiff_joints(dcm, mem, joint_list)

                # Checking REQ_FUSE_PERF_004
                if flag_first_overshoot and\
                timer_overshoot.is_time_out() and not\
                flag_protection_on:
                    if fuse_temperature.part == "LegFuse":
                        if stiffness_decrease_immediate != 0:
                            fuse_state = False
                            log.warning("LegFuse protection NOK")
                    else:
                        if stiffness_decrease != 0:
                            fuse_state = False
                            log.warning(fuse_temperature.part +\
                             " protection NOK")

                if flag_protection_on and fuse_temperature_value < 80.0:
                    flag_loop = False
                    log.info("End of test, fuse is cold enough")

            except KeyboardInterrupt:
                flag_loop = False  # out of test loop
                log.info("KeyboardInterrupt from user")

        log.info("!!!! OUT OF TEST LOOP !!!!")

        file_name = "_".join([str(fuse_temperature.part), str(fuse_state)])
        result_file_path = "/".join([result_base_folder, file_name]) + ".csv"
        logger.log_file_write(result_file_path)

        # setting original min and max
        log.info("Setting orininal min and max position actuator values...")
        for joint, value in state.items():
            joint_object = subdevice.JointPositionActuator(dcm, mem, joint)
            if value[0] > 0:
                joint_object.maximum = value[0]
                joint_object.qvalue = (joint_object.maximum, 500)
            else:
                joint_object.minimum = value[0]
                joint_object.qvalue = (joint_object.minimum, 500)

        qha_tools.wait(dcm, 200)
        log.info("Unstiff concerned joints")
        qha_tools.unstiff_joints(dcm, mem, joint_list)
        if fuse_temperature.part == "LegFuse":
            for wheel in wheel_objects:
                wheel.speed.actuator.qvalue = (0.0, 3000)
                time.sleep(3.0)
                wheel.stiffness.qqvalue = 0.0

        assert flag_key
        assert fuse_state
        assert flag_fuse_status
        assert flag_ambiant_temperature
Example #11
0
def test_pod_damage(dcm, mem, wake_up_pos, kill_motion, stiff_robot,
                    unstiff_parts):
    """
    Test robot moving in the pod to check damages
    """
    # Objects creation
    robot_on_charging_station = subdevice.ChargingStationSensor(dcm, mem)
    kneepitch_temperature = subdevice.JointTemperature(
        dcm, mem, "KneePitch")
    hippitch_temperature = subdevice.JointTemperature(
        dcm, mem, "HipPitch")
    hiproll_temperature = subdevice.JointTemperature(
        dcm, mem, "HipRoll")

    # Test parameters
    parameters = qha_tools.read_section("test_pod.cfg", "DynamicTestParameters")

    motion = subdevice.WheelsMotion(dcm, mem, 0.15)
    motion.stiff_wheels(
        ["WheelFR", "WheelFL", "WheelB"],
        int(parameters["stiffness_wheels_value"][0])
    )

    cycling_flag = 0
    cycling_step = 0

    # Going to initial position
    subdevice.multiple_set(dcm, mem, wake_up_pos, wait=True)

    # Flag initialization
    flag = True

    # Use plot class
    plot_log = Plot(dcm, mem, parameters["easy_plot_csv_name"][0])
    plot_log.start()

    timer = qha_tools.Timer(dcm, int(parameters["test_time"][0]) * 1000)

    # Use detection during movement class
    log_during_movement = DetectionDuringMovement(
        dcm, mem, timer,
        parameters["log_during_movement_csv_name"][0],
        parameters["lost_detection_csv_name"][0]
    )
    log_during_movement.start()

    if robot_on_charging_station.value == 0:
        print "Put the robot on the robot.\nVerify detection.\n"
        flag = False

    while timer.is_time_not_out() and flag == True:
        # Verify if robot moves
        if cycling_step == 3:
            log_during_movement.set_cycling_stop_flag_true()

        if cycling_flag == 0:
            if kneepitch_temperature.value < \
                    int(parameters["max_joint_temperature"][0]):
                print "KneePitch cycling"
                cycling_step = 0
                log_during_movement.set_cycling_stop_flag_false()
                kneepitch_cycling(dcm, mem,
                                  int(parameters["max_joint_temperature"][0]))
            else:
                cycling_step += 1
            cycling_flag = 1

        elif cycling_flag == 1:
            if hippitch_temperature.value < \
                    int(parameters["max_joint_temperature"][0]):
                print "HipPitch cycling"
                cycling_step = 0
                log_during_movement.set_cycling_stop_flag_false()
                hippitch_cycling(
                    dcm, mem,
                    int(parameters["max_joint_temperature"][0])
                )
            else:
                cycling_step += 1
            cycling_flag = 2
        else:
            if hiproll_temperature.value < \
                    int(parameters["max_joint_temperature"][0]):
                print "HipRoll cycling"
                cycling_step = 0
                log_during_movement.set_cycling_stop_flag_false()
                hiproll_cycling(
                    dcm, mem,
                    int(parameters["max_joint_temperature"][0])
                )
            else:
                cycling_step += 1
            cycling_flag = 0

    plot_log.stop()
    log_during_movement.stop()

    assert flag
    def test_wheel_temperature_protection(self, dcm, parameters, wheel,
                                          result_base_folder):
        # logger initialization
        log = logging.getLogger('MOTOR_LIMITATION_PERF_HW_002_Wheels')

        # flags initialization
        flag_wheel = True
        flag_loop = True
        flag_max_current_exceeded = False
        flag_max_temperature_exceeded = False
        flag_info = False
        flag_info2 = False
        flag_info3 = False
        flag_info4 = False

        wheel.stiffness.qvalue = (1.0, 5000)
        wheel.speed.actuator.qvalue = (wheel.speed.actuator.maximum, 10000)

        test_params = parameters
        timer = qha_tools.Timer(dcm, test_params["test_time"])
        slav = qha_tools.SlidingAverage(test_params["sa_nb_points"])
        logger = qha_tools.Logger()

        log.info("")
        log.info("*************************************")
        log.info("Testing : " + str(wheel.short_name))
        log.info("*************************************")
        log.info("")

        wheel_temperature_max = wheel.temperature.maximum
        wheel_temperature_min = wheel.temperature.minimum
        wheel_temperature_mid = \
        (wheel_temperature_max + wheel_temperature_min) * 0.5
        wheel_current_max = wheel.current.maximum
        current_limit_high = wheel_current_max * \
        (1.0 + test_params["limit_factor_sup"])
        current_limit_low = wheel_current_max * \
        (1.0 - test_params["limit_factor_inf"])

        while timer.is_time_not_out and flag_loop is True:
            try:
                wheel_temperature = wheel.temperature.value
                wheel_current = wheel.current.value
                slav.point_add(wheel_current)
                wheel_current_sa = slav.calc()
                wheel_speed_command = wheel.speed.actuator.value
                wheel_speed_sensor = wheel.speed.sensor.value
                wheel_stiffness = wheel.stiffness.value
                dcm_time = timer.dcm_time() / 1000.

                logger.log(
                    ("Time", dcm_time),
                    ("Stiffness", wheel_stiffness),
                    ("Current", wheel_current),
                    ("CurrentSA", wheel_current_sa),
                    ("MaxAllowedCurrent", wheel_current_max),
                    ("CurrentLimitHigh", current_limit_high),
                    ("CurrentLimitLow", current_limit_low),
                    ("Temperature", wheel_temperature),
                    ("TemperatureMin", wheel_temperature_min),
                    ("TemperatureMax", wheel_temperature_max),
                    ("SpeedActuator", wheel_speed_command),
                    ("SpeedSensor", wheel_speed_sensor),
                )

                # out of test loop if temperature is higher than MAX + 1 degree
                if wheel_temperature >= wheel_temperature_max + 5:
                    flag_loop = False

                # if joint temperature higher than a limit value,
                # joint current must be null after 100ms.
                if flag_max_temperature_exceeded is False and \
                wheel_temperature >= wheel_temperature_max:
                    flag_max_temperature_exceeded = True
                    timer_max = qha_tools.Timer(dcm, 1000)
                    log.info("max temperature exceeded a first time")

                if flag_max_temperature_exceeded and \
                wheel_temperature <= wheel_temperature_mid:
                    flag_loop = False
                    log.info("Motor windings are cold enough")

                # setting flag to True if 90 percent of max current is exceeded
                if wheel_current_sa > 0.9 * wheel_current_max and not \
                flag_max_current_exceeded and dcm_time > 0.4:
                    flag_max_current_exceeded = True
                    log.info("90 percent of max allowed currend reached")

                # averaged current has not to exceed limit high
                if wheel_current_sa > current_limit_high and not flag_info:
                    flag_wheel = False
                    flag_info = True
                    log.warning("current high limit exceeded")

                # once max current is exceeded, current hasn't to be lower than
                # limit low
                if flag_max_current_exceeded and \
                wheel_current_sa < current_limit_low and not \
                flag_max_temperature_exceeded and not flag_info2:
                    flag_wheel = False
                    flag_info2 = True
                    log.info("current has been lower than low limit")

                if flag_max_temperature_exceeded and\
                timer_max.is_time_out() and wheel_current != 0 and not\
                flag_info3:
                    flag_wheel = False
                    flag_info3 = True
                    log.critical("max temperature exceeded and current "+\
                            "is not null")

                if flag_max_temperature_exceeded and wheel_current == 0.0 and\
                not flag_info4:
                    flag_info4 = True
                    log.info("current null reached")

            except KeyboardInterrupt:
                flag_loop = False
                log.info("KeyboardInterrupt from user")
                wheel.speed.actuator.qvalue = (0.0, 1000)
                wheel.stiffness.qqvalue = 0.0

        # stop and unstiff wheel
        wheel.speed.actuator.qvalue = (0.0, 1000)
        wheel.stiffness.qqvalue = 0.0

        # writing logger results into a csv file
        result_file_path = "/".join([
            result_base_folder, wheel.temperature.subdevice_type,
            wheel.short_name + "_" + str(flag_wheel)
        ]) + ".csv"
        logger.log_file_write(result_file_path)

        assert flag_wheel
    def test_joint_temperature_protection(self, dcm, mem, parameters, joint,
                                          result_base_folder, rest_pos,
                                          stiffness_off, plot_server, plot):
        # logger initialization
        log = logging.getLogger('MOTOR_LIMITATION_PERF_HW_002')

        # flags initialization
        flag_joint = True
        flag_loop = True
        flag_max_current_exceeded = False
        flag_max_temperature_exceeded = False
        flag_low_limit = False
        flag_info = False
        flag_info2 = False
        flag_info3 = False
        flag_info4 = False

        # erasing real time curves
        if plot:
            plot_server.curves_erase()

        # Objects creation
        test_params = parameters
        joint_position_actuator = joint.position.actuator
        joint_position_sensor = joint.position.sensor
        joint_temperature_sensor = joint.temperature
        joint_hardness_actuator = joint.hardness
        joint_current_sensor = joint.current
        slav = qha_tools.SlidingAverage(test_params["sa_nb_points"])
        logger = qha_tools.Logger()

        log.info("")
        log.info("*************************************")
        log.info("Testing : " + str(joint.short_name))
        log.info("*************************************")
        log.info("")

        # Knowing the board, we can know if the motor is a MCC or DC Brushless
        joint_board = joint_position_actuator.device

        # Creating device object to acceed to its error
        joint_board_object = device.Device(dcm, mem, joint_board)

        # Going to initial position
        subdevice.multiple_set(dcm, mem, rest_pos, wait=True)
        # unstiffing all the other joints to avoid leg motors overheat
        subdevice.multiple_set(dcm, mem, stiffness_off, wait=False)
        time.sleep(0.1)

        # stiffing the joint we want to test
        joint.hardness.qqvalue = 1.0

        # keeping initial joint min and max
        joint_initial_maximum = joint_position_actuator.maximum
        joint_initial_minimum = joint_position_actuator.minimum

        # setting current limitations
        joint_current_max = joint_current_sensor.maximum

        # setting temperature limitatons
        joint_temperature_min = joint_temperature_sensor.minimum
        joint_temperature_max = joint_temperature_sensor.maximum
        delta_temperature = joint_temperature_max - joint_temperature_min

        # setting new min and max out of the mechanical stop
        if joint_initial_maximum >= 0.0:
            joint_new_maximum = \
                joint_initial_maximum + \
                math.radians(test_params["limit_extension"])
        else:
            joint_new_maximum = \
                joint_initial_maximum - \
                math.radians(test_params["limit_extension"])

        if joint_initial_minimum <= 0.0:
            joint_new_minimum = \
                joint_initial_minimum - \
                math.radians(test_params["limit_extension"])
        else:
            joint_new_minimum = \
                joint_initial_minimum + \
                math.radians(test_params["limit_extension"])

        joint_position_actuator.maximum = [[[
            joint_new_maximum, dcm.getTime(0)
        ]], "Merge"]
        joint_position_actuator.minimum = [[[
            joint_new_minimum, dcm.getTime(0)
        ]], "Merge"]

        # set timer limit
        timer_limit = qha_tools.Timer(dcm, test_params["test_time_limit"])

        # for Brushless motors, max test time is 60 seconds
        brushless_motors = ("KneePitch", "HipPitch", "HipRoll")
        if joint_position_actuator.short_name in brushless_motors:
            timer = qha_tools.Timer(dcm, 60000)
        else:
            timer = qha_tools.Timer(dcm, test_params["test_time"])

        # set position actuator out of the joint mechanical stop
        # going out of physical mechanical stop in 5 seconds
        if joint_position_actuator.short_name in \
            ("HipPitch", "RShoulderRoll", "HipRoll"):
            joint_position_actuator.qvalue = (joint_new_minimum, 5000)
        else:
            joint_position_actuator.qvalue = (joint_new_maximum, 5000)

        flag_first_iteration = True
        timer_current_decrease = qha_tools.Timer(dcm, 100)
        while flag_loop is True and timer.is_time_not_out():
            try:
                joint_temperature = joint_temperature_sensor.value
                joint_current = joint_current_sensor.value
                slav.point_add(joint_current)
                joint_position_command = joint_position_actuator.value
                joint_position = joint_position_sensor.value
                joint_hardness_value = joint_hardness_actuator.value
                joint_current_sa = slav.calc()
                firmware_error = joint_board_object.error
                dcm_time = timer.dcm_time() / 1000.

                # Max current adaptation if joint temperature higher than Min
                # No lower current for DC Brushless motors
                if joint_board not in \
                    ("HipBoard", "ThighBoard", "BackPlatformBoard"):
                    if joint_temperature > joint_temperature_min:
                        delta_max = joint_temperature_max - joint_temperature
                        max_allowed_current = (
                            (delta_max) / (delta_temperature)) *\
                        joint_current_max
                    else:
                        max_allowed_current = joint_current_max
                else:
                    max_allowed_current = joint_current_max

                # max allowed current can not be lower than 0.
                if max_allowed_current < 0.0:
                    max_allowed_current = 0.0

                # defining old max current as first calculated max current if
                # it is the first loop iteration
                if flag_first_iteration is True:
                    old_mac = max_allowed_current
                    flag_first_iteration = False

                # defining current regulation limits
                current_limit_high = max_allowed_current * \
                (1.0 + test_params["limit_factor_sup"])
                current_limit_low = max_allowed_current *\
                (1.0 - test_params["limit_factor_inf"])

                # setting flag to True if 90 percent of max current is exceeded
                if joint_current_sa > 0.9 * max_allowed_current and not\
                 flag_max_current_exceeded:
                    flag_max_current_exceeded = True
                    log.info("90 percent of max allowed currend reached")

                if max_allowed_current != old_mac:
                    timer_current_decrease = qha_tools.Timer(dcm, 100)

                # averaged current has not to exceed limit high
                if joint_current_sa > current_limit_high and \
                    timer_current_decrease.is_time_out() and not flag_info4:
                    flag_joint = False
                    flag_info4 = True
                    log.warning("current high limit exceeded")

                # once max current is exceeded, current hasn't to be lower than
                # limit low
                if flag_max_current_exceeded and \
                    joint_current_sa < current_limit_low and not \
                    flag_max_temperature_exceeded and not flag_low_limit:
                    flag_joint = False
                    flag_low_limit = True
                    log.info("current has been lower than low limit")

                # after time limit, current has to have exceeded max current
                # if it has not, it is written on time in log file
                if timer_limit.is_time_out() and not\
                 flag_max_current_exceeded and flag_info is False:
                    flag_joint = False
                    flag_info = True
                    log.info("current has not exceeded 90 percent of max "+\
                        "allowed current")

                # hardware protection
                if joint_temperature >= joint_temperature_max + 1:
                    flag_loop = False
                    log.warning("temperature too high (max+1 degree)")

                # if joint temperature higher than a limit value,
                # joint current must be null after 100ms.
                if flag_max_temperature_exceeded is False and \
                    joint_temperature >= joint_temperature_max:
                    flag_max_temperature_exceeded = True
                    timer_max = qha_tools.Timer(dcm, 100)
                    log.info("max temperature exceeded a first time")

                if flag_max_temperature_exceeded and\
                timer_max.is_time_out() and joint_current != 0 and not\
                flag_info2:
                    flag_joint = False
                    flag_info2 = True
                    log.critical("max temperature exceeded and current "+\
                        "is not null")

                if flag_max_temperature_exceeded and joint_current == 0.0 and\
                not flag_info3:
                    flag_info3 = True
                    log.info("current null reached")

                old_mac = max_allowed_current

                logger.log(
                    ("Time", dcm_time), ("Hardness", joint_hardness_value),
                    ("Current", joint_current),
                    ("CurrentSA", joint_current_sa),
                    ("MaxAllowedCurrent", max_allowed_current),
                    ("CurrentLimitHigh", current_limit_high),
                    ("CurrentLimitLow", current_limit_low),
                    ("Temperature", joint_temperature),
                    ("TemperatureMin", joint_temperature_min),
                    ("TemperatureMax", joint_temperature_max),
                    ("Command", joint_position_command),
                    ("Position", joint_position), ("FWError", firmware_error))

                # for real time plot
                if plot:
                    plot_server.add_point("Hardness", dcm_time,
                                          joint_hardness_value)
                    plot_server.add_point("CurrentSA", dcm_time,
                                          joint_current_sa)
                    plot_server.add_point("MaxAllowedCurrent", dcm_time,
                                          max_allowed_current)
                    plot_server.add_point("CurrentLimitHigh", dcm_time,
                                          current_limit_high)
                    plot_server.add_point("CurrentLimitLow", dcm_time,
                                          current_limit_low)
                    plot_server.add_point("Temperature", dcm_time,
                                          joint_temperature)
                    plot_server.add_point("TemperatureMin", dcm_time,
                                          joint_temperature_min)
                    plot_server.add_point("TemperatureMax", dcm_time,
                                          joint_temperature_max)
                    plot_server.add_point("Command", dcm_time,
                                          joint_position_command)
                    plot_server.add_point("Position", dcm_time, joint_position)

            except KeyboardInterrupt:
                flag_loop = False
                log.info("KeyboardInterrupt from user")

        # writing logger results into a csv file
        result_file_path = "/".join([
            result_base_folder, joint_position_actuator.subdevice_type,
            joint_position_actuator.short_name + "_" + str(flag_joint)
        ]) + ".csv"
        logger.log_file_write(result_file_path)

        # seting min and max joint software limits to their original values
        joint_position_actuator.maximum = [[[
            joint_initial_maximum, dcm.getTime(0)
        ]], "Merge"]
        joint_position_actuator.minimum = [[[
            joint_initial_minimum, dcm.getTime(0)
        ]], "Merge"]

        assert flag_joint