Beispiel #1
0
    def get_experiment_feedback(session_id, robot_id):
        global data_thread
        experiment_ongoing = True
        feedback_received = False
        black_box_id = BBUtils.get_bb_id(robot_id)
        robot_smart_wheel_count = config.get_robot_smart_wheel_count(robot_id)
        diagnostic_vars = DataUtils.expand_var_names(
            experiment_diagnostic_vars, robot_smart_wheel_count)

        zyre_communicator.reset_experiment_feedback(robot_id)
        while experiment_ongoing:
            feedback_msg = zyre_communicator.get_experiment_feedback(robot_id)
            if feedback_msg and feedback_msg['robot_id'] == robot_id:
                feedback_received = True
            experiment_ongoing = send_experiment_feedback(
                robot_id, feedback_msg, feedback_received)

            if experiment_ongoing:
                with data_thread_lock:
                    if not data_thread:
                        data_thread = threading.Thread(
                            target=send_diagnostic_data,
                            kwargs={
                                'session_id': session_id,
                                'black_box_id': black_box_id,
                                'diagnostic_vars': diagnostic_vars
                            })
                        data_thread.start()

        global feedback_thread
        feedback_thread = None
    def setup_robot_query_params(robots):
        for robot in robots:
            # for each robot, we expand the smart wheel variable names
            # depending on the robot's smart wheel count, combine the
            # query variables into a single list, and generate a robot-specific
            # data query message
            black_box_id = BBUtils.get_bb_id(robot)
            robot_smart_wheel_count = config.get_robot_smart_wheel_count(robot)
            expanded_wheel_vars = DataUtils.expand_var_names(
                wheel_vars, robot_smart_wheel_count)
            query_vars = expanded_wheel_vars + cmd_vel_vars
            query_msg = DataUtils.get_bb_latest_data_query_msg(
                session['uid'].hex, black_box_id, query_vars)
            robot_data_query_msgs[robot] = query_msg

            # for each robot, we get a short variable name mapping for the smart wheel variables
            robot_wheel_var_name_mapping[robot] = []
            for i in range(robot_smart_wheel_count):
                robot_wheel_var_name_mapping[robot].append({})
                for var in wheel_var_name_mapping:
                    var_name = var.replace('*', str(i + 1))
                    robot_wheel_var_name_mapping[robot][i][
                        var_name] = wheel_var_name_mapping[var]