=== Instruction 1 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving the manipulation of a drawer. 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 relevant objects, specifically the middle drawer's anchor and side positions. 

The task is executed in a series of steps: first, the gripper is rotated to the correct orientation, then it moves to the side position of the middle drawer, followed by moving to the anchor position. Next, the gripper picks up the middle drawer and finally pulls it open by a specified distance. After each step, the function checks if the task is completed and prints appropriate messages. Regardless of the outcome, the environment is shut down at the end of the task.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Nature of Content**: TASK is a formal representation of a planning problem in PDDL, while CODE_FUNC describes a procedural function for executing a simulation task.
2. **Purpose**: TASK defines the domain and problem for planning actions, whereas CODE_FUNC outlines the steps to perform those actions in a simulation.
3. **Structure**: TASK is structured in terms of actions, preconditions, and effects, while CODE_FUNC is structured as a sequence of procedural steps.
4. **Level of Abstraction**: TASK operates at a higher level of abstraction focused on planning and logic, while CODE_FUNC is more concrete, detailing specific implementation steps.
5. **Execution Context**: TASK is designed for a planning system to derive a sequence of actions, while CODE_FUNC is intended for direct execution in a programming environment.
6. **Output**: TASK does not produce output directly; it defines conditions and effects, whereas CODE_FUNC includes print statements to provide feedback during execution.
7. **Initialization**: TASK initializes the state of the world through predicates, while CODE_FUNC initializes the environment and may include video recording setup.
8. **Action Representation**: In TASK, actions are defined with parameters and conditions, while in CODE_FUNC, actions are executed in a linear sequence without explicit preconditions.
9. **Error Handling**: TASK does not address error handling, while CODE_FUNC implies checking for task completion and managing the environment shutdown.
10. **Flexibility**: TASK can be adapted for different scenarios by changing the PDDL definitions, while CODE_FUNC is more rigid and specific to the described simulation task.

Refined Code Generated:
-------------------
import numpy as np
from env import setup_environment, shutdown_environment
from skill_code import *  # Importing predefined skills
from video import init_video_writers, recording_step, recording_get_observation

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 the positions for the drawers
        middle_anchor_pos = positions['middle_anchor_pos']
        side_pos_middle = positions['middle_side_pos']

        # === Execute the Plan ===
        # Step 1: Rotate the gripper to the correct orientation
        obs, _, done = rotate(env, task, target_quat=np.array([0, 0, 0, 1]))  # Assuming zero rotation is needed
        if done:
            print("[Task] Task ended after rotating!")
            return

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

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

        # Step 4: Pick the middle drawer
        obs, _, done = pick(env, task, target_pos=middle_anchor_pos)
        if done:
            print("[Task] Task ended after picking the drawer!")
            return

        # Step 5: Pull the middle drawer to open it
        obs, _, done = pull(env, task, pull_distance=0.1)  # Assuming a pull distance of 0.1 meters
        if done:
            print("[Task] Task completed successfully! Drawer is now open.")
        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 =====")
-------------------

=== Instruction 2 ===
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 middle 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 function retrieves the positions of various objects, specifically the middle drawer's anchor and side positions.

The task is executed in a series of steps: first, the gripper is rotated to a specific orientation. Next, the gripper moves to the side position of the middle drawer, followed by moving to the anchor position of the same drawer. The gripper then attempts to pick up the middle drawer and finally pulls it out a specified distance. After each action, the function checks if the task is completed and prints appropriate messages. Finally, the environment is shut down to ensure proper cleanup.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK describes a high-level instruction for a robotic system to perform, while CODE_FUNC outlines a specific implementation of a simulation task involving a robotic gripper.
2. **Level of Abstraction**: TASK is an abstract instruction without implementation details, whereas CODE_FUNC provides a concrete sequence of actions and interactions.
3. **Context**: TASK is presented in a domain-specific language (PDDL) format, focusing on the planning aspects, while CODE_FUNC describes procedural steps in a programming context.
4. **Detailing of Actions**: TASK specifies a single action (pulling an unlocked drawer), while CODE_FUNC details multiple actions (rotation, movement, picking, and pulling) in a sequence.
5. **Environment Setup**: TASK does not include any setup or initialization details, while CODE_FUNC describes the setup of the environment and the initial state of the task.
6. **Execution Flow**: TASK does not specify the order of operations or the flow of execution, whereas CODE_FUNC explicitly outlines the sequence of actions taken by the gripper.
7. **Feedback Mechanism**: TASK does not mention any feedback or completion checks, while CODE_FUNC includes checks for task completion and prints messages based on the execution status.
8. **Simulation Aspect**: TASK is a directive for action, while CODE_FUNC explicitly states that it runs a simulation, indicating a focus on testing or demonstration rather than just execution.

Refined Code Generated:
-------------------
import numpy as np
from env import setup_environment, shutdown_environment
from skill_code import rotate, move, pick, pull
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 the positions for the drawers
        middle_anchor_pos = positions['middle_anchor_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 middle drawer
        print("[Task] Moving to side position of the middle drawer.")
        obs, reward, done = move(env, task, target_pos=positions['side_pos_middle'], 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 middle drawer
        print("[Task] Moving to anchor position of the middle drawer.")
        obs, reward, done = move(env, task, target_pos=positions['anchor_pos_middle'], 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 middle drawer
        print("[Task] Picking the middle drawer.")
        obs, reward, done = pick(env, task, target_pos=middle_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!")
            return

        # Step 5: Pull the middle drawer
        print("[Task] Pulling the middle drawer.")
        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 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 drawer and the gripper.

The task consists of several key steps: first, the gripper rotates to a specified angle; next, it moves to a designated side position of the drawer; then, it moves to the anchor position of the drawer. After positioning, the gripper attempts to pick up the drawer and finally pulls the drawer open. Each step checks if the task is completed, and if so, it prints a message indicating the task's completion. The environment is ensured to shut down properly at the end of the task.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK defines a domain and problem for a planning scenario, while CODE_FUNC describes a procedural function for simulating the 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. **Focus**: TASK focuses on the definitions of actions, predicates, and the initial state for planning, while CODE_FUNC focuses on the execution of those actions in a simulation.
4. **Execution**: TASK does not execute any actions; it merely defines them, while CODE_FUNC describes the execution of actions in a sequence.
5. **Environment Setup**: TASK includes the setup of the domain and problem, while CODE_FUNC includes the setup of the simulation environment and video recording.
6. **State Management**: TASK defines the initial state and conditions for actions, while CODE_FUNC manages the state through procedural steps and checks during execution.
7. **Output**: TASK does not produce output messages; it is a formal definition, while CODE_FUNC includes print statements to indicate task completion.
8. **Action Representation**: In TASK, actions are defined with preconditions and effects, while in CODE_FUNC, actions are described in a linear sequence without formal preconditions and effects.
9. **Flexibility**: TASK allows for planning and reasoning about actions, while CODE_FUNC is a fixed sequence of operations that does not adapt to different scenarios.
10. **Language**: TASK uses a declarative language (PDDL), while CODE_FUNC uses an imperative programming language. 

In summary, the two serve different purposes and are structured differently, reflecting their roles in planning versus execution.

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()
        middle_anchor_pos = positions['middle_anchor_pos']
        side_pos_middle = positions['middle_side_pos']

        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

        obs, reward, done = move(env, task, target_pos=side_pos_middle, max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended after moving to side position!")
            return

        obs, reward, done = move(env, task, target_pos=middle_anchor_pos, max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended after moving to anchor position!")
            return

        obs, reward, done = pick(env, task, target_pos=middle_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

        obs, reward, done = pull(env, task, pull_distance=0.5, pull_axis='y', max_steps=100, threshold=0.01, timeout=10.0)
        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()
-------------------

=== 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 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 function retrieves the positions of relevant objects, specifically the drawer's anchor and side positions.

The task is executed in a series of 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 the drawer to unlock it. After each action, the function checks if the task is completed and prints appropriate messages. The environment is ensured to shut down properly at the end of the task.
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 for the planning problem, while CODE_FUNC includes setup for the simulation environment and optional video recording.
6. **Feedback Mechanism**: TASK does not include feedback or logging mechanisms, while CODE_FUNC mentions printing messages to indicate task completion and status.
7. **Action Representation**: In TASK, actions are defined with preconditions and effects, while CODE_FUNC describes the actions in a more narrative form without formal precondition/effect structure.
8. **Focus**: TASK focuses on the logical representation of the problem, while CODE_FUNC emphasizes the practical implementation and execution of the task.

Refined Code Generated:
-------------------
import numpy as np
from env import setup_environment, shutdown_environment
from skill_code import pick, pull, rotate, move
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 the positions for the drawer and gripper
        bottom_anchor_pos = positions['bottom_anchor_pos']
        side_pos_bottom = 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=side_pos_bottom, max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended during move 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 during move to anchor position!")
            return

        # Step 4: Pick up the bottom drawer
        print("[Task] Picking up 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

        # Step 5: Pull the bottom drawer to unlock it
        print("[Task] Pulling the bottom drawer to unlock 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 5 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving the manipulation of a drawer. 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 objects, specifically the positions of the drawers.

The task consists of several key steps: first, it rotates a gripper to the correct orientation. Next, it moves to the side position of the bottom drawer, then to the anchor position of the same drawer. After that, it picks up the bottom drawer and finally pulls it open by a specified distance. Throughout the process, the function checks if the task is completed after each step and prints appropriate messages based on the task's progress. Finally, it ensures that the environment is properly shut down after the task is completed or if an error occurs.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK describes a specific instruction for a user to perform (slide open any available drawer), while CODE_FUNC outlines a function that simulates the execution of a series of actions to manipulate a drawer programmatically.
2. **Level of Abstraction**: TASK is a high-level instruction without implementation details, whereas CODE_FUNC provides a detailed procedural description of how to achieve the task through code.
3. **Context**: TASK is presented in a domain-specific language (PDDL) format, focusing on the planning aspects of the task, while CODE_FUNC describes the operational steps in a programming context.
4. **Components**: TASK includes definitions of actions, preconditions, and effects in a formalized manner, while CODE_FUNC includes procedural steps, checks, and messages related to task execution.
5. **Execution**: TASK does not specify how the actions are executed or the order of operations, while CODE_FUNC explicitly outlines the sequence of actions taken to complete the task.
6. **Feedback Mechanism**: TASK does not include any feedback or progress reporting, whereas CODE_FUNC mentions printing messages based on the task's progress and completion status.
7. **Error Handling**: TASK does not address error handling, while CODE_FUNC includes a mechanism to ensure proper shutdown of the environment in case of errors.

Overall, the two serve different purposes and contexts, with TASK focusing on the planning aspect and CODE_FUNC on the execution aspect.

Refined Code Generated:
-------------------
import numpy as np
from env import setup_environment, shutdown_environment
from skill_code import rotate, move, pick, pull
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 the positions for the drawers
        bottom_anchor_pos = positions['bottom_anchor_pos']

        # === Execute the Plan ===
        # Step 1: Rotate the gripper to the correct orientation
        obs, _, done = rotate(env, task, target_quat=np.array([0, 0, 0, 1]))  
        if done:
            print("[Task] Task ended after rotating!")
            return

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

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

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

        # Step 5: Pull the bottom drawer to open it
        obs, _, done = pull(env, task, pull_distance=0.1)  
        if done:
            print("[Task] Task completed successfully! Drawer is open.")
        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()
-------------------

