=== 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 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 function retrieves the positions of relevant objects, including the drawer and gripper.

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 top drawer, followed by moving to the anchor position of the drawer. The gripper then attempts to pick up the top drawer and finally pulls the drawer open. After each step, 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 domain and problem for a planning system, while CODE_FUNC describes a function for simulating a 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 types, predicates, and actions, while CODE_FUNC focuses on procedural steps and function calls.
4. **Execution**: TASK is meant to be executed by a planner that interprets PDDL, while CODE_FUNC is executed as a program that runs a simulation.
5. **Detail Level**: TASK provides a formal representation of actions and their preconditions/effects, while CODE_FUNC describes a high-level overview of the simulation process without formal action definitions.
6. **Environment Setup**: TASK specifies the initial state and conditions in a declarative manner, while CODE_FUNC describes the setup and execution in an imperative manner.
7. **Output**: TASK does not specify output messages, while CODE_FUNC includes print statements to indicate task completion and progress.
8. **Focus**: TASK focuses on the logical relationships and constraints of actions, while CODE_FUNC emphasizes the sequence of operations and their execution in a simulation context.

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 the positions for the drawer and gripper
        top_anchor_pos = positions['top_anchor_pos']
        side_pos_top = positions['top_side_pos']

        # === Execute the Plan ===
        # Step 1: Rotate the gripper to the correct orientation
        print("[Task] Rotating gripper to ninety degrees.")
        obs, _, 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 the gripper!")
            return

        # Step 2: Move to the side position of the top drawer
        print("[Task] Moving to side position of the top drawer.")
        obs, _, done = move(env, task, target_pos=side_pos_top, 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 top drawer
        print("[Task] Moving to anchor position of the top drawer.")
        obs, _, done = move(env, task, target_pos=top_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 top drawer
        print("[Task] Picking the top drawer.")
        obs, _, done = pick(env, task, target_pos=top_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 top drawer to open it
        print("[Task] Pulling the top drawer to open it.")
        obs, _, done = pull(env, task, pull_distance=0.2, 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:
        # 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 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. Video recording is optionally initialized to capture the simulation. The positions of various objects, including drawer anchors, are retrieved.

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 of the same drawer. The gripper then attempts to pick up the bottom drawer and finally pulls it out a specified distance. After each action, the code checks if the task has been completed successfully. Regardless of the outcome, the environment is shut down at the end of the process. The function prints status messages throughout to indicate progress and completion.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK describes a specific instruction for a robotic gripper to perform (pulling an unlocked drawer), while CODE_FUNC outlines a broader function that simulates a series of actions involving the gripper and drawers.
2. **Detail Level**: TASK is a high-level instruction with a focus on a single action, whereas CODE_FUNC provides a detailed sequence of actions and checks involved in the simulation.
3. **Context**: TASK is presented in a PDDL format, which is used for planning in AI, while CODE_FUNC is a narrative description of a programming function.
4. **Action Sequence**: TASK specifies only the action of pulling an unlocked drawer, while CODE_FUNC includes multiple actions (rotation, movement, picking, and pulling) as part of a complete task.
5. **Environment Setup**: TASK does not mention any setup or initialization, while CODE_FUNC describes the setup of the environment and the initial state of the task.
6. **Feedback Mechanism**: TASK does not include any feedback or status updates, while CODE_FUNC mentions printing status messages to indicate progress and completion.
7. **Completion Check**: TASK does not specify how to determine if the action was successful, whereas CODE_FUNC includes checks to see if the task has been completed successfully.
8. **Video Recording**: TASK does not mention video recording, while CODE_FUNC includes an optional step for video recording the simulation.
9. **Shutdown Process**: TASK does not include any shutdown or cleanup process, while CODE_FUNC explicitly states that the environment is shut down at the end of the process.

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():
    print("===== Starting Skeleton Task =====")
    
    env, task = setup_environment()
    try:
        _, 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_anchor_pos = positions['bottom_anchor_pos']

        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

        print("[Task] Moving to side position of the bottom drawer.")
        obs, reward, done = move(env, task, target_pos=positions['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.")
        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:
        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 optionally initialized to capture the simulation. The function retrieves the positions of various objects, specifically the positions of the drawers.

The task consists of several key steps: first, the gripper is rotated to a 90-degree angle. 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 picks up the middle drawer and finally pulls it to open it. After each step, the function checks if the task has ended prematurely and handles the environment shutdown at the end of the task. The process is logged with print statements to indicate progress.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK defines a domain and problem for a planning system, while CODE_FUNC describes a function for simulating the task in a programming context.
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 types, predicates, and actions, while CODE_FUNC focuses on procedural steps and function calls.
4. **Execution**: TASK outlines a theoretical framework for planning actions, while CODE_FUNC describes the actual 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 state management in an imperative manner.
6. **Logging and Feedback**: CODE_FUNC includes print statements for logging progress, which is not present in TASK.
7. **Simulation Control**: CODE_FUNC mentions handling the environment shutdown and checking for premature task completion, which is not addressed in TASK.
8. **Action Sequence**: TASK defines actions in a general sense, while CODE_FUNC specifies a concrete sequence of actions to be performed in a simulation.

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

        # === Task Plan Execution ===
        # Step 1: Rotate the gripper to the correct angle (90 degrees)
        print("[Task] Rotating gripper to 90 degrees.")
        obs, _, 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 middle drawer
        print("[Task] Moving to side position of the middle drawer.")
        obs, _, done = move(env, task, target_pos=middle_side_pos, 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 middle drawer
        print("[Task] Moving to anchor position of the middle drawer.")
        obs, _, done = move(env, task, target_pos=middle_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 the middle drawer
        print("[Task] Picking the middle drawer.")
        obs, _, 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 during pick!")
            return

        # Step 5: Pull the middle drawer to open it
        print("[Task] Pulling the middle drawer to open it.")
        obs, _, 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

    finally:
        # Always ensure the environment is properly shutdown
        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. It optionally initializes video recording for the simulation. The function retrieves the positions of objects in the environment, specifically the positions related to a top drawer.

The task consists of several key steps: first, the gripper rotates to a specified angle; next, it moves to the side position of the top drawer; then, it moves to the anchor position of the drawer. After reaching the anchor position, the gripper attempts to pick up the drawer, followed by pulling the drawer to unlock a cabinet. Each step checks if the task is completed, and if so, it exits early. Finally, the environment is shut down properly after the task execution. The function prints status messages throughout the process to indicate progress and completion.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK describes a specific instruction to unlock a cabinet by opening a drawer.
   - CODE_FUNC outlines a function that simulates the execution of the task involving a robotic gripper.

2. **Level of Detail**:
   - TASK provides a high-level description of the action to be performed.
   - CODE_FUNC details the procedural steps and logic involved in executing the task.

3. **Context**:
   - TASK is presented in a domain-specific language (PDDL) format, focusing on planning and actions.
   - CODE_FUNC is written in a programming context, describing a function that runs a simulation.

4. **Components**:
   - TASK includes definitions of actions, preconditions, and effects related to the drawer and gripper.
   - CODE_FUNC includes procedural steps, environment setup, and status messages, focusing on the simulation process.

5. **Execution**:
   - TASK is a declarative representation of actions to be taken in a planning context.
   - CODE_FUNC is an imperative representation that describes how to perform the task programmatically.

6. **Output**:
   - TASK does not specify any output; it focuses on the actions and their effects.
   - CODE_FUNC includes status messages and potentially visual output from the simulation.

7. **Environment Interaction**:
   - TASK defines interactions in terms of predicates and actions within a planning domain.
   - CODE_FUNC describes interactions in terms of function calls and simulation steps.

8. **State Management**:
   - TASK uses predicates to represent the state of the world (e.g., whether a drawer is locked or open).
   - CODE_FUNC manages state through procedural logic and function parameters.

9. **Error Handling**:
   - TASK does not address error handling or task completion checks.
   - CODE_FUNC includes checks for task completion and handles early exits.

10. **Initialization**:
    - TASK assumes an initial state defined in the PDDL problem.
    - CODE_FUNC explicitly initializes the environment and resets the task state.

11. **Simulation Aspect**:
    - TASK does not imply any simulation; it is purely about the action to be taken.
    - CODE_FUNC explicitly mentions running a simulation and may include video recording.

12. **Focus**:
    - TASK focuses on the logical structure of actions and their relationships.
    - CODE_FUNC focuses on the execution flow and the sequence of operations in a simulation context.

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 =====")
    
    # === Environment Setup ===
    env, task = setup_environment()
    try:
        # Reset the task to its initial state
        descriptions, 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 drawer
        top_anchor_pos = positions['top_anchor_pos']
        side_pos_top = positions['top_side_pos']

        # === Execute the Plan ===
        # Step 1: Rotate the gripper to ninety degrees
        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 top drawer
        print("[Task] Moving to side position of the top drawer.")
        obs, reward, done = move(env, task, target_pos=side_pos_top, 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 top drawer
        print("[Task] Moving to anchor position of the top drawer.")
        obs, reward, done = move(env, task, target_pos=top_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 top drawer
        print("[Task] Picking the top drawer.")
        obs, reward, done = pick(env, task, target_pos=top_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 top drawer to unlock the cabinet
        print("[Task] Pulling the top drawer to unlock the cabinet.")
        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 a specific orientation. Next, it moves to the side position of the bottom drawer, followed by moving to the anchor position of the same drawer. After reaching the anchor position, it attempts to pick up the bottom drawer and then pulls it to open it. Throughout these steps, the function checks if the task is completed after each action and prints relevant messages indicating the 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 an action (sliding open a drawer) while CODE_FUNC outlines a function that simulates a series of actions to manipulate 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 (Planning Domain Definition Language) format, focusing on the planning aspects of the task. CODE_FUNC describes a procedural implementation, likely in a programming language, detailing how to execute the task.

4. **Structure**: 
   - TASK is structured as a domain and problem definition with predicates and actions, while CODE_FUNC is structured as a function with procedural steps and checks.

5. **Execution**: 
   - TASK does not specify how the actions are executed or the order of execution, while CODE_FUNC explicitly outlines the sequence of actions and checks for task completion.

6. **Feedback Mechanism**: 
   - TASK does not include any feedback or logging mechanism, whereas CODE_FUNC mentions printing messages to indicate progress and checking for task completion.

7. **Error Handling**: 
   - TASK does not address error handling, while CODE_FUNC includes a mechanism to ensure proper shutdown in case of errors.

8. **Initialization**: 
   - TASK does not detail the initialization of the environment, while CODE_FUNC mentions resetting the task to its initial state and optionally initializing video recording.

9. **Object Interaction**: 
   - TASK focuses on the logical conditions and effects of actions on the drawer, while CODE_FUNC describes the physical manipulation of the drawer through specific actions.

10. **Simulation Aspect**: 
    - TASK is purely a planning description, while CODE_FUNC explicitly states that it runs a simulation task, indicating a focus on practical execution rather than theoretical planning.

11. **Action Specificity**: 
    - TASK defines actions in a general sense (e.g., rotate, move-to-side), while CODE_FUNC specifies the exact sequence of these actions in a simulation context.

12. **State Management**: 
    - TASK uses predicates to define the state of the world, while CODE_FUNC manages state through procedural checks and updates during execution.

13. **Output**: 
    - TASK does not produce output beyond the logical effects of actions, while CODE_FUNC includes print statements to provide feedback during execution.

14. **Focus on Completion**: 
    - TASK does not explicitly mention task completion, while CODE_FUNC includes checks to determine if the task is completed after each action.

15. **Environment Shutdown**: 
    - TASK does not address the shutdown of the environment, while CODE_FUNC ensures that the environment is properly shut down after task completion or error occurrence.

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_anchor_pos = positions['bottom_anchor_pos']

        print("[Task] Rotating gripper to ninety degrees.")
        obs, _, 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

        print("[Task] Moving to side position of the bottom drawer.")
        obs, _, 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 side position!")
            return

        print("[Task] Moving to anchor position of the bottom drawer.")
        obs, _, 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

        print("[Task] Picking the bottom drawer.")
        obs, _, 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

        print("[Task] Pulling the bottom drawer to open it.")
        obs, _, 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! 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()
-------------------

