def test_reliability_003(dcm, mem, motion, motion_wake_up, parameters,
                         direction):
    """
    Test : bumper detects step.
    Return True if bumper detects obstacles and robot stops
    Return False if bumper detects obstacle but robot moves again

    @dcm                : proxy to DCM (object)
    @mem                : proxy to ALMemory (object)
    @motion             : proxy to ALMotion (object)
    @motion_wake_up     : robot does it wakeUp
    @parameters         : dictionnary {"parameter":value} from config file
                            (dictionnary)
    @directions         : dictionnary {"direction":value} (dictionnary)
    """
    # Objects creation
    right_bumper = subdevice.Bumper(dcm, mem, "FrontRight")
    left_bumper = subdevice.Bumper(dcm, mem, "FrontLeft")
    back_bumper = subdevice.Bumper(dcm, mem, "Back")
    wheelfr_speed_act = subdevice.WheelSpeedActuator(dcm, mem, "WheelFR")
    wheelfl_speed_act = subdevice.WheelSpeedActuator(dcm, mem, "WheelFL")

    log = Log(dcm, mem, direction + "-" + parameters["Speed"][0])
    log.start()

    print "Go move"
    move(
        motion, float(parameters["Speed"][0]),
        qha_tools.read_section("reliability_003.cfg", "Direction" + direction))
    print "Move finish"

    flag = 0
    while flag < int(parameters["Nbcycles"][0]):
        if right_bumper.value or left_bumper.value or back_bumper.value:
            print "Bumper"
            time.sleep(3)  # Time to wait wheel actuators reaction...
            if wheelfr_speed_act.value == 0 and wheelfl_speed_act.value == 0:
                print "Stop OK"
                flag += 1
                time.sleep(5)  # Robot forget mapping
                moveto(
                    motion, float(parameters["MoveBackDistance"][0]),
                    qha_tools.read_section("reliability_003.cfg",
                                           "Direction" + direction))
                print "Move back OK"
                time.sleep(2)
                move(
                    motion, float(parameters["Speed"][0]),
                    qha_tools.read_section("reliability_003.cfg",
                                           "Direction" + direction))
                print "Move"
            else:
                print flag
                break

    log.stop()

    assert flag == int(parameters["Nbcycles"][0])
Esempio n. 2
0
def test_sensors_env_004(robot_ip, dcm, mem, motion, session, motion_wake_up,
                         parameters, direction, speed):
    """
    Docstring
    """
    expected = {"ALMotion/MoveFailed": 1}
    module_name = "EventChecker_{}_".format(uuid.uuid4())
    movefailed = EventModule(mem)
    module_id = session.registerService(module_name, movefailed)
    movefailed.subscribe(module_name, expected)

    flag_test = False

    # Sensors
    sensors_list = qha_tools.read_section("sensors.cfg", "Sensors")
    ir_right = subdevice.InfraredSpot(dcm, mem, "Right")
    ir_left = subdevice.InfraredSpot(dcm, mem, "Left")

    log = multi_logger.Logger(
        robot_ip, "multi_logger.cfg", 0.1,
        "Direction" + str(direction) + " - " + str(speed) + ".csv")
    log.log()

    # Movement
    move(motion, speed,
         qha_tools.read_section("env_004.cfg", "Direction" + direction))

    time.sleep(1)

    while not movefailed.flag and not flag_test:
        for sensor in sensors_list:
            if mem.getData(sensor) < float(parameters["distance"][0]):
                print(sensor)
                motion.stopMove()
                flag_test = True
        # if ir_right.value == 1:
        #     print("IR_Right")
        #     motion.stopMove()
        #     flag_test = True
        # if ir_left.value == 1:
        #     print("IR_Left")
        #     motion.stopMove()
        #     flag_test = True

    log.stop()

    session.unregisterService(module_id)

    assert flag_test
Esempio n. 3
0
def allowed_temperature_emergencies():
    """
    Reads allowed temperature emergencies from configuration file.
    It returns a dictionnary with allowed temperature emergency for each joint.
    """
    print "reading allowed temperature emergencies..."
    return qha_tools.read_section(CONFIG_FILE, "AllowedTemperatureEmergencies")
Esempio n. 4
0
def test_parameters_dico(request, motion, offset_protection):
    """
    @returns : Dictionary of motion parameters
    @rtype : dictionary

    It returns as many dictionaries as arguments in params [len(params)]
    """
    dico = qha_tools.read_section(CONFIG_FILE, request.param)
    return dico
Esempio n. 5
0
def hippitch_cycling(dcm, mem, max_joint_temperature):
    """ HipPitch cycling"""
    # Objects creation
    kneepitch_position_actuator = subdevice.JointPositionActuator(
        dcm, mem, "KneePitch")
    kneepitch_position_sensor = subdevice.JointPositionSensor(
        dcm, mem, "KneePitch")
    kneepitch_hardness_actuator = subdevice.JointHardnessActuator(
        dcm, mem, "KneePitch")
    hippitch_position_actuator = subdevice.JointPositionActuator(
        dcm, mem, "HipPitch")
    hippitch_temperature = subdevice.JointTemperature(
        dcm, mem, "HipPitch")
    hiproll_position_actuator = subdevice.JointPositionActuator(
        dcm, mem, "HipRoll")

    parameters = qha_tools.read_section("test_pod.cfg", "DynamicCycling")

    # Initial position
    kneepitch_position_actuator.qvalue = (0.,
        int(parameters["time_go_initial_position"][0]) * 1000)
    hiproll_position_actuator.qvalue = (0.,
        int(parameters["time_go_initial_position"][0]) * 1000)
    qha_tools.wait(dcm, int(parameters["time_go_initial_position"][0]) * 1000)
    kneepitch_hardness_actuator.qqvalue = 0.

    while hippitch_temperature.value < max_joint_temperature:
        hippitch_position_actuator.qvalue = (
            float(parameters["amplitude_hippitch"][0]),
            int(parameters["time_movement_hippitch"][0]) * 1000
        )
        qha_tools.wait(dcm, int(parameters["time_movement_hippitch"][0]) * 1000)
        hippitch_position_actuator.qvalue = (
            -float(parameters["amplitude_hippitch"][0]),
            int(parameters["time_movement_hippitch"][0]) * 1000
        )
        qha_tools.wait(dcm, int(parameters["time_movement_hippitch"][0]) * 1000)
        print(str(hippitch_temperature.value))

        if abs(kneepitch_position_sensor.value) > \
                float(parameters["angle_slipping"][0]):
            print "KneePitch slip"
            kneepitch_hardness_actuator.qqvalue = 1.
            kneepitch_position_actuator.qvalue = (0.,
                int(parameters["time_after_slipping"][0]) * 1000)
            hippitch_position_actuator.qvalue = (0.,
                int(parameters["time_after_slipping"][0]) * 1000)
            qha_tools.wait(dcm, int(parameters["time_after_slipping"][0]) * 1000)
            kneepitch_hardness_actuator.qqvalue = 0.

    hippitch_position_actuator.qvalue = (0.,
        int(parameters["time_go_initial_position"][0]) * 1000)
    qha_tools.wait(dcm, int(parameters["time_go_initial_position"][0]) * 1000)
    kneepitch_hardness_actuator.qqvalue = 1.
Esempio n. 6
0
def sa_objects():
    """
    Returns a dictionnary of sliding average objects with the correct number
    of points for each joint.
    It reads the test configuration file.
    """
    sa_nb_points = qha_tools.read_section(CONFIG_FILE,
                                          "SlidingAverageNbPoints")
    dico_object = dict()
    for joint, nb_points in sa_nb_points.items():
        dico_object[joint] = qha_tools.SlidingAverage(int(nb_points[0]))
    return dico_object
def test_sensors_safety_001(robot_ip, dcm, mem, motion, session,
                            motion_wake_up, direction, speed):
    """
    Docstring
    """
    expected = {"ALMotion/MoveFailed": 1}
    module_name = "EventChecker_{}_".format(uuid.uuid4())
    obstacledetected = EventModule(mem)
    module_id = session.registerService(module_name, obstacledetected)
    obstacledetected.subscribe(module_name, expected)

    # Objects creation
    wheelb_speed_act = subdevice.WheelSpeedActuator(dcm, mem, "WheelB")
    wheelfr_speed_act = subdevice.WheelSpeedActuator(dcm, mem, "WheelFR")
    wheelfl_speed_act = subdevice.WheelSpeedActuator(dcm, mem, "WheelFL")

    flag_test = True

    log = multi_logger.Logger(
        robot_ip,
        "multi_logger.cfg",
        0.1,
        "Direction" + direction + " - " + str(speed) + ".csv")
    log.log()

    # Movement
    move(motion, speed,
         qha_tools.read_section("safety_001.cfg", "Direction" + direction)
         )

    time.sleep(1)

    while not obstacledetected.flag:
        if wheelb_speed_act.value == 0 and \
                wheelfr_speed_act.value == 0 and \
                wheelfl_speed_act.value == 0:
            flag_test = False

    log.stop()

    session.unregisterService(module_id)

    assert flag_test
Esempio n. 8
0
def set_position(dcm, mem, motion, section):
    """
    Put robot in initial position.
    No return.

    @dcm        : proxy to DCM (object)
    @mem        : proxy to ALMemory (object)
    @motion     : proxy to ALMotion (object)
    @section    : name of section to read in config file (string)
    """

    datas = qha_tools.read_section("touch_detection.cfg", section)

    for name, value in datas.items():
        if value[0] == "max":
            sub = subdevice.SubDevice(dcm, mem, name + "/Position/Actuator")
            angle = float(sub.maximum)
        elif value[0] == "min":
            sub = subdevice.SubDevice(dcm, mem, name + "/Position/Actuator")
            angle = float(sub.minimum)
        else:
            angle = float(value[0])
        move_joint(name, angle, 0.1, motion)
Esempio n. 9
0
 def __init__(self, dcm, mem):
     """
     Initialisation de la class
     """
     self.dcm = dcm
     self.mem = mem
     self.parameters = qha_tools.read_section("test_config.cfg",
                                              "DockCyclingParameters")
     self.wheel_motion = subdevice.WheelsMotion(
         self.dcm, self.mem, float(self.parameters["speed"][0]))
     self.robot_on_charging_station = subdevice.ChargingStationSensor(
         self.dcm, self.mem)
     self.back_bumper_sensor = subdevice.Bumper(dcm, mem, "Back")
     self.nb_cycles = self.parameters["nb_cycles"][0]
     self.log_file = open(self.parameters["cycling_cvs_name"][0], 'w')
     self.check_temperature_thread = threading.Thread(
         target=self._check_temperature_thread, args=())
     self.check_bumper_thread = threading.Thread(
         target=self._check_bumper_thread, args=())
     self.check_bumper = True
     self.check_bumper_pause = True
     self.check_temperature = None
     self.wheel_hot = None
     self.bumper_state = None
Esempio n. 10
0
def parameters():
    return qha_tools.read_section("perf_001.cfg", "TestParameters")
Esempio n. 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
Esempio n. 12
0
def main():
    """Main function"""
    parser = argparse.ArgumentParser(description="Log datas from ALMemory")

    parser.add_argument(dest="robot_ip", help="Robot IP or name")

    args = parser.parse_args()

    general = qha_tools.read_section("slip.cfg", "general")

    robot_ip = args.robot_ip
    result_folder = general["resultsFolder"][0]

    # Create result folder if not existing
    try:
        os.mkdir(result_folder)
    except OSError:
        pass

    dcm = ALProxy("DCM", robot_ip, 9559)
    mem = ALProxy("ALMemory", robot_ip, 9559)

    # Get Body ID
    body_id = mem.getData("Device/DeviceList/ChestBoard/BodyId")

    # Kill motion (if not already done)
    try:
        mot = ALProxy("ALMotion", robot_ip, 9559)
        mot.exit()
    except RuntimeError:
        pass

    print "[I] ALMotion is now killed"

    # Ask the operator to write his name
    name = raw_input("Please enter your name and press Enter : ")

    while name == "":
        name = raw_input("Please enter your name and press Enter : ")

    nb_of_trials = int(general["numberOfTrials"][0])

    stiffness_on = qha_tools.read_section("slip.cfg",
                                          "stiffnessOnWithoutWheels")

    stiffness_off = qha_tools.read_section("slip.cfg", "stiffnessOff")

    rest_pos = qha_tools.read_section("slip.cfg", "restPosition")

    force_list = []

    for i in range(nb_of_trials):
        # Set Stiffness on
        subdevice.multiple_set(dcm, mem, stiffness_on)

        # Go to rest position
        subdevice.multiple_set(dcm, mem, rest_pos, wait=True)
        time.sleep(1)

        # Set Stiffness off
        subdevice.multiple_set(dcm, mem, stiffness_off)

        if (nb_of_trials - i - 1) <= 1:
            trial_string = "trial"
        else:
            trial_string = "trials"

        force = raw_input("Please push the robot, write the force (in Newton) "
                          "and press Enter. (" + str(nb_of_trials - i - 1) +
                          " " + trial_string + " left) : ")

        while not is_number(force):
            force = raw_input("Please push the robot, write the force"
                              "(in Newton) and press Enter. (" +
                              str(nb_of_trials - i - 1) + " " + trial_string +
                              " left) : ")

        force_list.append(force)

    print("Thank you !")

    # At the end of the test, put the robot in initial position
    # Set Stiffness on
    subdevice.multiple_set(dcm, mem, stiffness_on)

    # Go to rest position
    subdevice.multiple_set(dcm, mem, rest_pos, wait=True)
    time.sleep(1)

    # Set Stiffness off
    subdevice.multiple_set(dcm, mem, stiffness_off)

    # Write results file
    file_path = result_folder + "/" + body_id + ".dat"
    my_file = open(file_path, 'a')

    string_to_print = name + " " + " ".join(force_list) + "\n"

    my_file.write(string_to_print)
Esempio n. 13
0
def parameters():
    """
    Return parameters (config file).
    """
    return qha_tools.read_section("reliability_003.cfg", "TestParameters")
Esempio n. 14
0
def parameters():
    """
    Return parameters (config file).
    """
    return qha_tools.read_section("pod_perf_009.cfg", "TestParameters")
Esempio n. 15
0
def parameters():
    """
    Return parameters (config file).
    """
    return qha_tools.read_section("env_004.cfg", "TestParameters")
Esempio n. 16
0
def test_sensors_env_005(robot_ip, dcm, mem, motion, session, motion_wake_up,
                         parameters, speed):
    """
    Docstring
    """
    expected = {"ALMotion/MoveFailed": 1}
    module_name = "EventChecker_{}_".format(uuid.uuid4())
    movefailed = EventModule(mem)
    module_id = session.registerService(module_name, movefailed)
    movefailed.subscribe(module_name, expected)

    flag_test = False

    # Sensors
    sensors_list = qha_tools.read_section("sensors.cfg", "Sensors")
    # ir_right = subdevice.InfraredSpot(dcm, mem, "Right")
    # ir_left = subdevice.InfraredSpot(dcm, mem, "Left")

    log = multi_logger.Logger(robot_ip, "multi_logger.cfg", 0.1,
                              parameters["log_file_name"][0])
    log.log()

    log_file = open("ObstacleDetection.csv", 'w')
    line_to_write = ",".join(["Time", "Sensor", "Distance"]) + "\n"
    log_file.write(line_to_write)
    log_file.flush()

    # Movement
    motion.move(0, 0, speed)

    time.sleep(1)

    time_init = time.time()
    while True:
        elapsed_time = time.time() - time_init
        try:
            for sensor in sensors_list:
                if mem.getData(sensor) < float(parameters["distance2"][0]):
                    print(parameters["distance2"][0])
                    print(sensor)
                    line_to_write = ",".join(
                        [str(elapsed_time), sensor,
                         str(mem.getData(sensor))]) + "\n"
                    log_file.write(line_to_write)
                    log_file.flush()
                    flag_test = True
                elif mem.getData(sensor) < float(parameters["distance1"][0]):
                    print(parameters["distance1"][0])
                    print(sensor)
                    line_to_write = ",".join(
                        [str(elapsed_time), sensor,
                         str(mem.getData(sensor))]) + "\n"
                    log_file.write(line_to_write)
                    log_file.flush()
                    flag_test = True
                else:
                    line_to_write = ",".join(
                        [str(elapsed_time), "None", "None"]) + "\n"
                    log_file.write(line_to_write)
                    log_file.flush()
            # if ir_right.value == 1:
            #     print("IR_Right")
            #     flag_test = True
            # if ir_left.value == 1:
            #     print("IR_Left")
            #     flag_test = True
            time.sleep(0.1)
            motion.move(0, 0, 0.3)
        except KeyboardInterrupt:
            break

    log.stop()

    session.unregisterService(module_id)

    assert flag_test
Esempio n. 17
0
def parameters():
    return qha_tools.read_section("touch_detection.cfg", "TestParameters")
Esempio n. 18
0
def wake_up_pos():
    """
    Fixture which retrieves wakeUp joints position from a configuration file.
    """
    return qha_tools.read_section(PATH + "/global_test_configuration/"
                                  "juliette_positions.cfg", "wakeUp")
Esempio n. 19
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
Esempio n. 21
0
def stiffness_off():
    return qha_tools.read_section(PATH + "/global_test_configuration/"
                                  "juliette_configuration.cfg", "stiffnessOff")
Esempio n. 22
0
def zero_pos():
    """
    Fixture which retrieves zero joints position from a configuration file.
    """
    return qha_tools.read_section(PATH + "/global_test_configuration/"
                                  "juliette_positions.cfg", "zero")