Esempio n. 1
0
def _sample_frames_get_command_dicts(robot_name, frames, animation_settings,
                                     time_interval_in_seconds, user_options):
    """
    Sample robot commands using a list of frames and user options.
    :param robot_name:
    :param frames:
    :param animation_settings:
    :param user_options:
    :return:
    """
    # Initialize output array.
    command_dicts = []
    time_index_count = 0

    for frame in frames:
        # Set the background to the current frame
        # TODO: Implement this! This rocks:
        # pm.currentTime(frame)
        # Create a dict of datatypes per frame
        command_dict = {}
        # Add this frame number/step/index to the dictionary
        command_dict['Frame'] = frame
        command_dict['Framerate'] = animation_settings['Framerate']
        command_dict[
            'Time Index'] = time_index_count * time_interval_in_seconds
        time_index_count += 1

        # Get motion parameters
        if not user_options.Ignore_motion:
            if user_options.Include_axes:
                axes = _sample_frame_get_axes(robot_name, frame)
                command_dict[postproc.AXES] = postproc.Axes(*axes)
            if user_options.Include_pose:
                pose = _sample_frame_get_pose(robot_name, frame)
                command_dict[postproc.POSE] = postproc.Pose(*pose)
            if user_options.Include_external_axes:
                external_axes = _sample_frame_get_external_axes(
                    robot_name, frame)
                command_dict[postproc.EXTERNAL_AXES] = postproc.ExternalAxes(
                    *external_axes)
            if user_options.Include_configuration:
                configuration = _sample_frame_get_configuration(
                    robot_name, frame)
                command_dict[postproc.CONFIGURATION] = postproc.Configuration(
                    *configuration)
        # Get IO parameters
        if not user_options.Ignore_IOs:
            if user_options.Include_digital_outputs:
                # TODO: Implement digital outputs
                # digital_output = None
                # command_dict[postproc.DIGITAL_OUTPUT] = postproc.DigitalOutput(*digital_output)
                pass
            if user_options.Include_digital_inputs:
                # TODO: Implement digital inputs
                # digital_input = None
                # command_dict[postproc.DIGITAL_INPUT'] = postproc.DigitalOutput(*digital_input)
                pass
            if user_options.Include_analog_outputs:
                # TODO: Implement analog outputs
                # analog_output = None
                # command_dict[postproc.ANALOG_OUTPUT] = postproc.DigitalOutput(*analog_output)
                pass
            if user_options.Include_analog_inputs:
                # TODO: Implement analog inputs
                # analog_input = None
                # command_dict[postproc.ANALOG_INPUT] = postproc.DigitalOutput(*analog_input)
                pass
        command_dicts.append(command_dict)

    # Reset current frame (just in case)
    pm.currentTime(frames[0])
    return command_dicts
Esempio n. 2
0
def _sample_frames_get_command_dicts(robot_name, frames, animation_settings,
                                     user_options, postproc_settings):
    """
    Sample robot commands using a list of frames and user options.
    :param robot_name:
    :param frames:
    :param animation_settings:
    :param user_options:
    :return:
    """
    # Initialize output array.
    command_dicts = []
    start_frame = animation_settings['Start Frame']
    end_frame = animation_settings['End Frame']

    preview_in_viewport = postproc_settings['Preview in Viewport']

    for frame in frames:

        if preview_in_viewport:
            # Set the background to the current frame
            pm.currentTime(frame)

        # Create a dict of datatypes per frame
        command_dict = {}
        # Add this frame number/step/index to the dictionary
        command_dict['Frame'] = frame
        command_dict['Framerate'] = animation_settings['Framerate']
        command_dict[postproc.TIME_INDEX] = (
            frame - start_frame) / animation_settings['Framerate']

        # Get motion parameters
        if not user_options.Ignore_motion:
            if user_options.Include_axes:
                axes = _sample_frame_get_axes(robot_name, frame)
                command_dict[postproc.AXES] = postproc.Axes(*axes)
            if user_options.Include_pose:
                pose = _sample_frame_get_pose(robot_name, frame)
                command_dict[postproc.POSE] = postproc.Pose(*pose)
            if user_options.Include_external_axes:
                external_axes = _sample_frame_get_external_axes(
                    robot_name, frame)
                command_dict[postproc.EXTERNAL_AXES] = postproc.ExternalAxes(
                    *external_axes)
            if user_options.Include_configuration:
                configuration = _sample_frame_get_configuration(
                    robot_name, frame)
                command_dict[postproc.CONFIGURATION] = postproc.Configuration(
                    *configuration)
        # Get IO parameters
        if not user_options.Ignore_IOs:
            if user_options.Include_digital_outputs:
                digital_output = _sample_frame_get_outs(
                    robot_name, frame, 'digital')
                command_dict[postproc.DIGITAL_OUTPUT] = digital_output
            if user_options.Include_digital_inputs:
                # TODO: Implement digital inputs
                # digital_input = None
                # command_dict[postproc.DIGITAL_INPUT'] = postproc.DigitalOutput(*digital_input)
                pass
            if user_options.Include_analog_outputs:
                analog_output = _sample_frame_get_outs(robot_name, frame,
                                                       'analog')
                command_dict[postproc.ANALOG_OUTPUT] = analog_output
            if user_options.Include_analog_inputs:
                # TODO: Implement analog inputs
                # analog_input = None
                # command_dict[postproc.ANALOG_INPUT] = postproc.DigitalOutput(*analog_input)
                pass
        command_dicts.append(command_dict)
        pm.refresh()
        _update_export_progress_bar(start_frame, end_frame, frame)
    # Reset current frame (just in case)
    pm.currentTime(frames[0])

    return command_dicts