Example #1
0
def test_face_detection(robot_ip, dcm, mem, motion, session, motion_wake_up,
                        parameters):
    """
    Docstring
    """
    expected = {"FaceDetected": 1}
    module_name = "EventChecker_{}_".format(uuid.uuid4())
    face_detected = EventModule(mem)
    module_id = session.registerService(module_name, face_detected)
    face_detected.subscribe(module_name, expected)

    flag_end_face = False
    flag_face = False

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

    while not flag_end_face:
        try:
            if face_detected.flag_event:
                flag_face = True
            if flag_face and not face_detected.flag_event:
                flag_end_face = True
        except KeyboardInterrupt:
            break

    log.stop()

    session.unregisterService(module_id)

    assert face_detected.flag
Example #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
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
Example #4
0
 def __init__(self, ip):
     self.ip = ip
     # proxy creation
     self.motion = ALProxy("ALMotion", self.ip, 9559)
     self.system = ALProxy("ALSystem", self.ip, 9559)
     # test parameters
     self.nbcyles = 10000
     # logger parameters
     self.testType = "brakes_cycling_wakeUp_rest"
     self.extension = "csv"
     self.date = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
     self.robotName = self.system.robotName()
     self.filePath = "-".join([self.robotName, self.date, self.testType])
     self.confFilePath = "multi_logger.cfg"
     self.samplePeriod = 0.02
     self.output = ".".join([self.filePath, self.extension])
     self.decimal = 3
     self.logger = multi_logger.Logger(self.ip, self.confFilePath,
                                       self.samplePeriod, self.output,
                                       self.decimal)
Example #5
0
def main():
    """Call this function to try the multi_looger as an API."""

    # Init the logger
    #
    logger = multi_logger.Logger(IP_ROBOT, CONFIG_FILE_PATH, SAMPLE_PERIOD,
                                 OUTPUT, DECIMAL)

    # Start log
    #
    logger.log()

    #
    # DO YOUR STUFFS #
    # BLAH BLAH BLAH #
    #
    time.sleep(10)

    # Stop log
    #
    logger.stop()
def test_robollomes_with_dances(robot_ip, mem, session, packagemanager,
                                albehaviormanager, stop_bootconfig,
                                motion_wake_up, behavior):
    """
    Launch requested dances (cf associated config file).
    Assert True is no fall down detected.

    @mem            : proxy to ALMemory (object)
    @session        : Session in qi (object)
    @albehaviormanager  : proxy to ALBehavioManager (object)
    @motion_wake_up : robot does is wakeUp
    @behaviors          : dictionnary {"name":value} (dictionnary)
    """

    # Subcribe to module
    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)

    packagemanager.install("/home/nao/behaviors_pkg/" + behavior + ".pkg")

    log = multi_logger.Logger(robot_ip, "multi_logger.cfg", 0.1,
                              behavior + ".csv")
    log.log()

    run_behavior(albehaviormanager, behavior)

    log.stop()

    packagemanager.removePkg(behavior)

    session.unregisterService(module_id)

    if obstacledetected.flag:
        assert True

    assert False
def main():
    """
    Call this function to try the multi_looger as an API.
    While the script is running, move the robot's HeadPitch if you want the
    printed values to change.
    """

    # Init the logger
    #
    logger = multi_logger.Logger(IP_ROBOT, CONFIG_FILE_PATH, SAMPLE_PERIOD,
                                 OUTPUT, DECIMAL, RT_PLOT, CLASS_GETTER,
                                 QUEUE_SIZE)

    # Start log
    logger.log()

    initial_time = time.time()
    while (time.time() - initial_time) < LOOP_TIME:
        datas = logger.get_data()
        print datas["HeadPitchPositionSensorValue"]

    # Stop log
    logger.stop()
Example #8
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
Example #9
0
    def __init__(self, ip, jointName, direction, cyclingBrakingAngle,
                 cycleNumber):
        """Test parameters"""
        # attributes to be parsed in the main
        self.ip = ip
        self.jointName = jointName
        self.direction = direction
        self.cyclingBrakingAngleDegrees = cyclingBrakingAngle
        self.nbCyclingDynamicTest = cycleNumber
        # proxy creation
        self.motion = ALProxy("ALMotion", self.ip, 9559)
        self.mem = ALProxy("ALMemory", self.ip, 9559)
        self.system = ALProxy("ALSystem", self.ip, 9559)
        # logger parameters
        self.testType = "brakes_dynamic_test_ALMotion"
        self.extension = "csv"
        self.date = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
        self.robotName = self.system.robotName()
        self.filePath = "-".join(
            [self.robotName, self.date, self.testType, self.direction])
        self.confFilePath = "multi_logger.cfg"
        self.samplePeriod = 0.02
        self.output = ".".join([self.filePath, self.extension])
        self.decimal = 3
        self.logger = multi_logger.Logger(self.ip, self.confFilePath,
                                          self.samplePeriod, self.output,
                                          self.decimal)
        # ---------------------------------------------------------------------
        # TEST PARAMETERS - values which can be modified
        # ---------------------------------------------------------------------

        # speed
        self.slowSpeed = 0.2
        self.maxSpeed = 1.0
        # mechanical stop protection angles
        self.maxAngleHipDegrees = 55.0
        self.maxAngleKneeDegrees = 30.0
        # hip test start and stop angles
        self.angleMinHip = 30.0
        self.angleMaxHip = 50.0
        # knee test start and stop angles
        self.angleMinKnee = -1.0
        self.angleMaxKnee = 9.0
        # step
        self.step = 2.0
        # max temperature
        self.jointMaxTemperature = 70.0

        # ---------------------------------------------------------------------
        self.nbDynaTest = (self.angleMaxHip -
                           self.angleMinHip) / (self.step) + 1
        self.nbDynaTestKnee = (self.angleMaxKnee -
                               self.angleMinKnee) / (self.step) + 1

        # joints object creation
        self.principalJoint = Joint(self.motion, self.mem, self.jointName)
        if (self.jointName == "HipPitch"):
            self.secondJoint = Joint(self.motion, self.mem, "KneePitch")
        else:
            self.secondJoint = Joint(self.motion, self.mem, "HipPitch")
        # test parameters adaptation
        # max angle
        if self.jointName == "HipPitch":
            if self.direction == "Positive":
                self.angleMax = -self.angleMaxHip
            else:
                self.angleMax = self.angleMaxHip
        else:
            if direction == "Positive":
                self.angleMax = -self.angleMaxKnee
            else:
                self.angleMax = self.angleMaxKnee
        # min angle
        if self.jointName == "HipPitch":
            if self.direction == "Positive":
                self.angleMin = -self.angleMinHip
            else:
                self.angleMin = self.angleMinHip
        else:
            if self.direction == "Positive":
                self.angleMin = -self.angleMinKnee
            else:
                self.angleMin = self.angleMinKnee
        # step
        if self.direction == "Positive":
            self.step = -self.step
        # nbDynaTest
        if self.jointName == "KneePitch":
            self.nbDynaTest = self.nbDynaTestKnee

        # dynamicCyclingTest parameters adaptation
        if self.direction == "Positive":
            self.cyclingBrakingAngleDegrees *= -1