=== Instruction 1 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving a robotic gripper interacting with drawers. It begins by setting up the environment and resetting the task to its initial state. It optionally initializes video recording for the simulation. The function retrieves the positions of various drawer components and then executes a series of steps to manipulate the bottom drawer. 

First, it rotates the gripper to the correct orientation. Next, it moves the gripper to the side position of the bottom drawer, followed by moving to the anchor position of the same drawer. The gripper then picks up the bottom drawer and finally pulls it open. Throughout the process, the function checks if the task is completed at each step and prints relevant messages. After the task execution, it ensures the environment is properly shut down. The function is executed when the script is run as the main program.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK defines a planning domain and problem for opening a drawer using PDDL, while CODE_FUNC describes a specific implementation of a simulation task involving a robotic gripper.
2. **Format**: TASK is structured in PDDL format, which is used for defining planning problems, whereas CODE_FUNC is written in a programming language (likely Python) and describes procedural steps.
3. **Components**: TASK includes definitions of types, predicates, and actions, while CODE_FUNC focuses on the execution of a sequence of actions in a simulation context.
4. **Execution**: TASK does not execute actions but defines how they can be executed in a planning context, while CODE_FUNC explicitly describes the execution of actions in a simulation.
5. **State Representation**: TASK uses predicates to represent the state of the world (e.g., whether a drawer is locked or open), while CODE_FUNC operates on the state through function calls and procedural logic.
6. **Action Specification**: TASK specifies actions with preconditions and effects, while CODE_FUNC describes the steps taken without formal precondition and effect definitions.
7. **Environment Setup**: TASK defines the initial state of the environment in a declarative manner, while CODE_FUNC describes the procedural setup and teardown of the simulation environment.
8. **Output**: TASK does not produce output directly; it is meant for planning, while CODE_FUNC includes print statements to provide feedback during execution.
9. **Flexibility**: TASK is more abstract and can be used with different planners, while CODE_FUNC is a concrete implementation that may not be easily adaptable to other contexts without modification.

Refined Code Generated:
-------------------
import numpy as np
from env import setup_environment, shutdown_environment
from skill_code import *
from video import init_video_writers, recording_step, recording_get_observation
from object_positions import get_object_positions

def run_skeleton_task():
    '''Generic skeleton for running any task in your simulation.'''
    print("===== Starting Skeleton Task =====")
    
    # === Environment Setup ===
    env, task = setup_environment()
    try:
        # Reset the task to its initial state
        _, obs = task.reset()

        # (Optional) Initialize video writers for capturing your simulation
        init_video_writers(obs)

        # Wrap the task steps for recording (if needed)
        original_step = task.step
        task.step = recording_step(original_step)
        original_get_obs = task.get_observation
        task.get_observation = recording_get_observation(original_get_obs)

        # === Retrieve Object Positions ===
        positions = get_object_positions()

        # Define positions for the drawers
        bottom_anchor_pos = positions['bottom_anchor_pos']
        bottom_side_pos = positions['bottom_side_pos']

        # === Execute the Plan ===
        # Step 1: Rotate the gripper to the correct orientation
        print("[Task] Rotating gripper to ninety degrees.")
        obs, reward, done = rotate(env, task, target_quat=np.array([0, 0, 1, 0]), max_steps=100, threshold=0.05, timeout=10.0)
        if done:
            print("[Task] Task ended during rotation!")
            return

        # Step 2: Move to the side position of the bottom drawer
        print("[Task] Moving to side position of the bottom drawer.")
        obs, reward, done = move(env, task, target_pos=bottom_side_pos, max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended during movement!")
            return

        # Step 3: Move to the anchor position of the bottom drawer
        print("[Task] Moving to anchor position of the bottom drawer.")
        obs, reward, done = move(env, task, target_pos=bottom_anchor_pos, max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended during movement!")
            return

        # Step 4: Pick the bottom drawer
        print("[Task] Picking the bottom drawer.")
        obs, reward, done = pick(env, task, target_pos=bottom_anchor_pos, approach_distance=0.15, max_steps=100, threshold=0.01, approach_axis='z', timeout=10.0)
        if done:
            print("[Task] Task ended during picking!")
            return

        # Step 5: Pull the bottom drawer to open it
        print("[Task] Pulling the bottom drawer to open it.")
        obs, reward, done = pull(env, task, pull_distance=0.1, pull_axis='y', max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
        else:
            print("[Task] Task not completed yet (done=False).")

    finally:
        # Always ensure the environment is properly shutdown
        shutdown_environment(env)

    print("===== End of Skeleton Task =====")

if __name__ == "__main__":
    run_skeleton_task()
-------------------

=== Instruction 2 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function that simulates a robotic task involving the manipulation of a drawer. It begins by setting up the simulation environment and resetting the task to its initial state. The function initializes video recording capabilities to capture the simulation process.

Next, it retrieves the positions of various components related to the drawers. The task consists of several key steps: rotating the robotic gripper to a specific orientation, moving to the side position of the bottom drawer, moving to the anchor position of the bottom drawer, picking up the bottom drawer, and finally pulling the drawer to open it.

After each step, the function checks if the task is completed and prints appropriate messages. If the task is completed successfully, it outputs a reward value. Regardless of the outcome, the function ensures that the environment is properly shut down at the end of the simulation.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Nature of Content**: TASK is a formal representation of a problem in PDDL (Planning Domain Definition Language), while CODE_FUNC is a description of a function that simulates a robotic task in a programming context.
2. **Purpose**: TASK defines the actions, preconditions, and effects for a planning problem, whereas CODE_FUNC describes the implementation of a simulation for executing those actions.
3. **Structure**: TASK is structured in a domain and problem format with predicates and actions, while CODE_FUNC is a narrative description of a procedural function.
4. **Level of Abstraction**: TASK operates at a higher level of abstraction focused on planning and logic, while CODE_FUNC is more concrete, detailing the execution of tasks in a programming environment.
5. **Execution vs. Planning**: TASK is concerned with the planning of actions to achieve a goal, while CODE_FUNC focuses on the execution of those actions in a simulated environment.
6. **Output**: TASK does not specify outputs in terms of rewards or messages, while CODE_FUNC explicitly mentions outputting reward values and messages based on task completion.
7. **Environment Setup**: TASK does not include details about setting up a simulation environment, whereas CODE_FUNC mentions initializing video recording and resetting the task state.
8. **Feedback Mechanism**: CODE_FUNC includes a feedback mechanism (printing messages and outputting rewards), which is not present in TASK.

Overall, the two serve different purposes in the context of robotics and planning, with TASK focusing on the theoretical aspects of planning and CODE_FUNC on practical implementation.

Refined Code Generated:
-------------------
import numpy as np
from env import setup_environment, shutdown_environment
from skill_code import *
from video import init_video_writers, recording_step, recording_get_observation
from object_positions import get_object_positions

def run_skeleton_task():
    '''Generic skeleton for running any task in your simulation.'''
    print("===== Starting Skeleton Task =====")
    
    # === Environment Setup ===
    env, task = setup_environment()
    try:
        # Reset the task to its initial state
        _, obs = task.reset()

        # (Optional) Initialize video writers for capturing your simulation
        init_video_writers(obs)

        # Wrap the task steps for recording (if needed)
        original_step = task.step
        task.step = recording_step(original_step)
        original_get_obs = task.get_observation
        task.get_observation = recording_get_observation(original_get_obs)

        # === Retrieve Object Positions ===
        positions = get_object_positions()

        # Define positions for the drawers
        bottom_anchor_pos = positions['bottom_anchor_pos']
        bottom_side_pos = positions['bottom_side_pos']

        # === Execute the Plan ===
        # Step 1: Rotate the gripper to the correct orientation
        print("[Task] Rotating gripper to ninety degrees.")
        obs, reward, done = rotate(env, task, target_quat=np.array([0, 0, 1, 0]), max_steps=100, threshold=0.05, timeout=10.0)
        if done:
            print("[Task] Task ended after rotating!")
            return

        # Step 2: Move to the side position of the bottom drawer
        print("[Task] Moving to side position of the bottom drawer.")
        obs, reward, done = move(env, task, target_pos=bottom_side_pos, max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended after moving to side position!")
            return

        # Step 3: Move to the anchor position of the bottom drawer
        print("[Task] Moving to anchor position of the bottom drawer.")
        obs, reward, done = move(env, task, target_pos=bottom_anchor_pos, max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended after moving to anchor position!")
            return

        # Step 4: Pick the bottom drawer
        print("[Task] Picking the bottom drawer.")
        obs, reward, done = pick(env, task, target_pos=bottom_anchor_pos, approach_distance=0.15, max_steps=100, threshold=0.01, approach_axis='z', timeout=10.0)
        if done:
            print("[Task] Task ended after picking the drawer!")
            return

        # Step 5: Pull the bottom drawer to open it
        print("[Task] Pulling the bottom drawer to open it.")
        obs, reward, done = pull(env, task, pull_distance=0.1, pull_axis='y', max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
        else:
            print("[Task] Task not completed yet (done=False).")

    finally:
        # Always ensure the environment is properly shutdown
        shutdown_environment(env)

    print("===== End of Skeleton Task =====")

if __name__ == "__main__":
    run_skeleton_task()
-------------------

=== Instruction 3 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving a robotic gripper interacting with a bottom drawer. It begins by setting up the environment and resetting the task to its initial state. Video recording is optionally initialized to capture the simulation. The positions of relevant objects are retrieved, specifically for the bottom drawer.

The task consists of several key steps: first, the gripper is rotated to a specific orientation. Next, the gripper moves to the side position of the bottom drawer, followed by moving to the anchor position. The gripper then attempts to pick up the bottom drawer and finally pulls it to open it. After each action, the code checks if the task has completed successfully or if it ended prematurely. Regardless of the outcome, the environment is shut down at the end of the task. The overall behavior is to simulate the process of opening a drawer using a robotic gripper.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Nature of Content**: TASK is a formal representation of a planning problem in PDDL (Planning Domain Definition Language), while CODE_FUNC is a descriptive summary of a function that simulates a task.
2. **Format**: TASK is structured in a specific syntax (PDDL) with defined actions, predicates, and parameters, whereas CODE_FUNC is written in natural language.
3. **Purpose**: TASK defines the rules and conditions for a planning problem, while CODE_FUNC describes the implementation and execution of a simulation task.
4. **Detail Level**: TASK includes detailed specifications of actions, preconditions, and effects, while CODE_FUNC provides a high-level overview of the steps involved in the simulation without technical details.
5. **Context**: TASK is focused on the logical and procedural aspects of opening a drawer, while CODE_FUNC emphasizes the operational aspects of running a simulation.
6. **Execution**: TASK does not execute any actions but defines how they should be executed in a planning context, whereas CODE_FUNC describes the execution of actions in a simulation environment.
7. **Outcome Handling**: TASK does not specify how to handle outcomes or errors, while CODE_FUNC mentions checking for successful completion or premature ending of the task.

Overall, the two serve different purposes and are presented in different formats, leading to these semantic differences.

Refined Code Generated:
-------------------
import numpy as np
from pyrep.objects.shape import Shape
from pyrep.objects.proximity_sensor import ProximitySensor

from env import setup_environment, shutdown_environment

from skill_code import *  
from video import init_video_writers, recording_step, recording_get_observation
from object_positions import get_object_positions

def run_skeleton_task():
    '''Generic skeleton for running any task in your simulation.'''
    print("===== Starting Skeleton Task =====")
    
    env, task = setup_environment()
    try:
        descriptions, obs = task.reset()

        init_video_writers(obs)

        original_step = task.step
        task.step = recording_step(original_step)
        original_get_obs = task.get_observation
        task.get_observation = recording_get_observation(original_get_obs)

        positions = get_object_positions()

        bottom_side_pos = positions['bottom_side_pos']
        bottom_anchor_pos = positions['bottom_anchor_pos']

        print("[Task] Rotating gripper to 90 degrees.")
        obs, reward, done = rotate(env, task, target_quat=np.array([0, 0, 1, 0]), max_steps=100, threshold=0.05, timeout=10.0)
        if done:
            print("[Task] Task ended during rotation!")
            return

        print("[Task] Moving to side position of the bottom drawer.")
        obs, reward, done = move(env, task, target_pos=bottom_side_pos, max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended during move to side position!")
            return

        print("[Task] Moving to anchor position of the bottom drawer.")
        obs, reward, done = move(env, task, target_pos=bottom_anchor_pos, max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended during move to anchor position!")
            return

        print("[Task] Picking the bottom drawer.")
        obs, reward, done = pick(env, task, target_pos=bottom_anchor_pos, approach_distance=0.15, max_steps=100, threshold=0.01, approach_axis='z', timeout=10.0)
        if done:
            print("[Task] Task ended during pick!")
            return

        print("[Task] Pulling the bottom drawer to open it.")
        obs, reward, done = pull(env, task, pull_distance=0.1, pull_axis='y', max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended during pull!")
            return

        print("[Task] Successfully opened the bottom drawer.")

    finally:
        shutdown_environment(env)

    print("===== End of Skeleton Task =====")

if __name__ == "__main__":
    run_skeleton_task()
-------------------

=== Instruction 4 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving a robotic gripper interacting with a cabinet. It begins by setting up the environment and resetting the task to its initial state. It optionally initializes video recording for the simulation. The function retrieves the positions of objects in the environment and then executes a series of steps to complete the task. 

First, it rotates the gripper to a specific orientation. Next, it moves the gripper to the side position of the bottom drawer, followed by moving to the anchor position of the drawer. The gripper then picks up the bottom drawer and pulls it to unlock it. If any step results in the task being marked as done, the function exits early. Finally, the environment is shut down properly, and the task concludes.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK defines a planning domain and problem for unlocking a cabinet, while CODE_FUNC describes a function that simulates the execution of that task.
2. **Structure**: TASK is structured in PDDL (Planning Domain Definition Language) format, whereas CODE_FUNC is written in a programming language (likely Python or similar).
3. **Components**: TASK includes definitions of actions, predicates, and types, while CODE_FUNC focuses on the procedural steps to execute the task.
4. **Execution**: TASK outlines the preconditions and effects of actions in a planning context, while CODE_FUNC describes the sequential execution of those actions in a simulation.
5. **Environment Setup**: TASK specifies the initial state and conditions in a declarative manner, while CODE_FUNC describes the procedural setup and potential initialization of video recording.
6. **Task Completion**: TASK does not specify how to determine when the task is complete, while CODE_FUNC includes a mechanism to exit early if the task is marked as done.
7. **Shutdown Procedure**: TASK does not include any shutdown or cleanup procedures, whereas CODE_FUNC explicitly mentions shutting down the environment after task completion.

Refined Code Generated:
-------------------
import numpy as np
from env import setup_environment, shutdown_environment
from skill_code import *
from video import init_video_writers, recording_step, recording_get_observation
from object_positions import get_object_positions

def run_skeleton_task():
    '''Generic skeleton for running any task in your simulation.'''
    print("===== Starting Skeleton Task =====")
    
    # === Environment Setup ===
    env, task = setup_environment()
    try:
        # Reset the task to its initial state
        task.reset()

        # (Optional) Initialize video writers for capturing your simulation
        init_video_writers(task.get_observation())

        # Wrap the task steps for recording (if needed)
        original_step = task.step
        task.step = recording_step(original_step)
        original_get_obs = task.get_observation
        task.get_observation = recording_get_observation(original_get_obs)

        # === Retrieve Object Positions ===
        positions = get_object_positions()

        # Define object positions based on the provided object list
        bottom_anchor_pos = positions['bottom_anchor_pos']
        bottom_side_pos = positions['bottom_side_pos']
        
        # === Execute the Plan ===
        # Step 1: Rotate the gripper to the correct orientation (90 degrees)
        print("[Task] Rotating gripper to 90 degrees.")
        obs, _, done = rotate(env, task, target_quat=np.array([0, 0, np.sin(np.pi/4), np.cos(np.pi/4)]))
        if done:
            print("[Task] Task ended during rotation!")
            return

        # Step 2: Move to the side position of the bottom drawer
        print("[Task] Moving to side position of the bottom drawer.")
        obs, _, done = move(env, task, target_pos=bottom_side_pos)
        if done:
            print("[Task] Task ended during moving to side position!")
            return

        # Step 3: Move to the anchor position of the bottom drawer
        print("[Task] Moving to anchor position of the bottom drawer.")
        obs, _, done = move(env, task, target_pos=bottom_anchor_pos)
        if done:
            print("[Task] Task ended during moving to anchor position!")
            return

        # Step 4: Pick the bottom drawer
        print("[Task] Picking the bottom drawer.")
        obs, _, done = pick(env, task, target_pos=bottom_anchor_pos)
        if done:
            print("[Task] Task ended during picking!")
            return

        # Step 5: Pull the bottom drawer to unlock it
        print("[Task] Pulling the bottom drawer to unlock it.")
        obs, _, done = pull(env, task, pull_distance=0.1)  # Assuming a pull distance of 0.1
        if done:
            print("[Task] Task ended during pulling!")
            return

        print("[Task] Successfully unlocked the cabinet by opening the bottom drawer.")

    finally:
        # Always ensure the environment is properly shutdown
        shutdown_environment(env)

    print("===== End of Skeleton Task =====")

if __name__ == "__main__":
    run_skeleton_task()
-------------------

=== Instruction 5 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving a robotic gripper interacting with a drawer. It begins by setting up the environment and resetting the task to its initial state. Video recording is initialized to capture the simulation. The positions of relevant objects are retrieved, specifically for the bottom drawer.

The task consists of several key steps: first, the gripper is rotated to a specified orientation; next, it moves to the side position of the bottom drawer; then, it moves to the anchor position of the drawer. After reaching the anchor position, the gripper attempts to pick up the drawer and finally pulls the drawer open by a specified distance. 

Throughout the process, the task checks if it has completed successfully after each action, providing feedback on the task's status. Finally, the environment is shut down to ensure proper cleanup after the task execution.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK describes a specific instruction for an action (sliding open a drawer), while CODE_FUNC outlines a sequence of operations for a simulation involving a robotic gripper interacting with a drawer.
2. **Level of Detail**: TASK provides a high-level instruction without implementation details, whereas CODE_FUNC includes specific steps and procedures for executing the task.
3. **Context**: TASK is presented in a PDDL format, which is used for planning in AI, while CODE_FUNC describes a functional implementation in a programming context.
4. **Components**: TASK includes definitions of actions, preconditions, and effects in a formalized manner, while CODE_FUNC describes the flow of a simulation, including initialization, execution, and cleanup.
5. **Feedback Mechanism**: TASK does not mention any feedback or status checking, while CODE_FUNC explicitly states that it checks for successful completion after each action.
6. **Environment Management**: TASK does not address environment setup or teardown, whereas CODE_FUNC includes steps for initializing and shutting down the environment.
7. **Action Sequence**: TASK focuses on the actions required to open a drawer, while CODE_FUNC details the sequence of actions taken by the gripper, including rotation, movement, picking, and pulling.
8. **Simulation Aspect**: TASK is a theoretical description of actions, while CODE_FUNC is practical and involves running a simulation, including video recording and state management.

Refined Code Generated:
-------------------
import numpy as np
from env import setup_environment, shutdown_environment
from skill_code import *  
from video import init_video_writers, recording_step, recording_get_observation
from object_positions import get_object_positions

def run_skeleton_task():
    '''Generic skeleton for running any task in your simulation.'''
    print("===== Starting Skeleton Task =====")
    
    env, task = setup_environment()
    try:
        descriptions, obs = task.reset()

        init_video_writers(obs)

        original_step = task.step
        task.step = recording_step(original_step)
        original_get_obs = task.get_observation
        task.get_observation = recording_get_observation(original_get_obs)

        positions = get_object_positions()

        bottom_side_pos = positions['bottom_side_pos']
        bottom_anchor_pos = positions['bottom_anchor_pos']

        obs, reward, done = rotate(env, task, target_quat=np.array([0, 0, 0, 1]))  
        if done:
            print("[Task] Task ended after rotation!")
            return

        obs, reward, done = move(env, task, target_pos=bottom_side_pos)
        if done:
            print("[Task] Task ended after moving to side position!")
            return

        obs, reward, done = move(env, task, target_pos=bottom_anchor_pos)
        if done:
            print("[Task] Task ended after moving to anchor position!")
            return

        obs, reward, done = pick(env, task, target_pos=bottom_anchor_pos)
        if done:
            print("[Task] Task ended after picking the drawer!")
            return

        obs, reward, done = pull(env, task, pull_distance=0.1)  
        if done:
            print("[Task] Task completed successfully! Drawer is now open.")
        else:
            print("[Task] Task not completed yet (done=False).")

    finally:
        shutdown_environment(env)

    print("===== End of Skeleton Task =====")

if __name__ == "__main__":
    run_skeleton_task()
-------------------

