=== 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 objects in the environment, specifically the positions for the 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 and finally pulls it out. Each step checks if the task is completed, and if so, it exits early. The environment is ensured to shut down properly at the end of the task. The function prints status messages throughout the process to indicate progress and completion.
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 is a descriptive narrative of a function that simulates a task.
2. **Format**: TASK is structured in a formal syntax (PDDL), whereas CODE_FUNC is written in natural language.
3. **Purpose**: TASK defines the rules and actions for a planning domain, while CODE_FUNC describes the execution of a simulation task.
4. **Detail Level**: TASK includes specific predicates, actions, and preconditions, while CODE_FUNC provides a high-level overview of the steps without detailed conditions or effects.
5. **Execution vs. Planning**: TASK focuses on the planning aspect of the task (what needs to be done), while CODE_FUNC emphasizes the execution of the task (how it is done).
6. **State Representation**: TASK explicitly defines the initial state and conditions for actions, while CODE_FUNC does not provide a formal state representation.
7. **Action Specification**: TASK lists specific actions with parameters and effects, while CODE_FUNC describes actions in a more general sense without formal parameters.
8. **Feedback Mechanism**: CODE_FUNC mentions status messages for progress, which is not present in TASK.
9. **Environment Interaction**: CODE_FUNC includes details about video recording and environment shutdown, which are not addressed in TASK.

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()
        top_anchor_pos = positions['top_anchor_pos']
        side_pos_top = positions['top_side_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 after rotating the gripper!")
            return

        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

        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

        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

        print("[Task] Pulling the top 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 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. It optionally initializes video recording for the simulation. The function retrieves the positions of the drawers and then executes a series of steps: rotating the gripper, moving to the side and anchor positions of the top drawer, picking up the drawer, and finally pulling it out. After each step, it checks if the task is completed and prints relevant messages. Finally, it ensures the environment is properly shut down after the task execution.
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 function that implements a simulation of that task.
2. **Detail Level**: TASK provides a high-level instruction without implementation details, whereas CODE_FUNC includes procedural steps and logic for executing the task.
3. **Context**: TASK is presented in a planning domain description language (PDDL) format, focusing on the actions and predicates involved, while CODE_FUNC is a narrative description of a function's behavior in a programming context.
4. **Execution**: TASK does not specify how the actions are executed or in what order, while CODE_FUNC explicitly describes the sequence of actions taken by the gripper.
5. **Environment Setup**: TASK does not mention any setup or initialization, while CODE_FUNC includes details about setting up the environment and resetting the task state.
6. **Feedback Mechanism**: TASK does not include any feedback or completion checks, whereas CODE_FUNC mentions checking if the task is completed and printing messages.
7. **Video Recording**: CODE_FUNC includes an optional feature for video recording the simulation, which is not mentioned in TASK.
8. **Shutdown Procedure**: CODE_FUNC describes ensuring the environment is properly shut down after task execution, which is absent in TASK.

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 the positions for the drawers
        top_anchor_pos = positions['top_anchor_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=top_anchor_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 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!")
            return

        # Step 5: Pull the top drawer
        print("[Task] Pulling the top drawer.")
        obs, reward, done = pull(env, task, pull_distance=0.1, pull_axis='x', 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 drawers. It begins by setting up the environment and resetting the task to its initial state. The simulation can optionally record video of the task. 

The function retrieves the positions of various objects, specifically the positions of the drawers. It then executes a series of steps: rotating the 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 open. 

After each step, it checks if the task has ended prematurely. Regardless of the outcome, the environment is shut down properly at the end of the function. The entire process is encapsulated in a try-finally block to ensure cleanup occurs.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK defines a domain and problem for a planning task in PDDL, while CODE_FUNC describes a function for simulating the execution of that task in a programming context.
2. **Structure**: TASK is structured in PDDL format with actions, predicates, and types, whereas CODE_FUNC is written in a programming language format, outlining a procedural function.
3. **Execution**: TASK specifies the conditions and effects of actions in a planning context, while CODE_FUNC describes the sequential execution of those actions in a simulation.
4. **Environment Setup**: TASK includes the definition of the initial state and the requirements for the planning problem, while CODE_FUNC mentions setting up the environment and resetting the task state programmatically.
5. **Video Recording**: CODE_FUNC includes an option to record video of the task, which is not mentioned in TASK.
6. **Error Handling**: CODE_FUNC uses a try-finally block for cleanup, which is not a concept present in TASK.
7. **Premature Termination Check**: CODE_FUNC includes checks for premature task termination, which are not part of the TASK definition.
8. **Action Execution**: TASK defines actions with preconditions and effects, while CODE_FUNC describes the execution of those actions in a specific order without detailing preconditions and effects.
9. **Focus**: TASK focuses on the logical representation of the problem and solution space, while CODE_FUNC focuses on 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 *  
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 during rotation!")
            return

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

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

    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 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 components related to the drawer.

The task consists of a series of steps: first, it rotates a gripper to a specified orientation, then moves to the side position of the bottom drawer, followed by moving to the anchor position of the bottom drawer. Next, it picks up the bottom drawer and finally pulls it to open it. After each step, the function checks if the task is completed and prints a message accordingly. The environment is ensured to be properly shut down at the end of the task.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK describes a high-level instruction to unlock a cabinet by opening a drawer.
   - CODE_FUNC details a specific implementation of a simulation task that manipulates a drawer.

2. **Level of Abstraction**: 
   - TASK is an abstract instruction without implementation details.
   - CODE_FUNC provides a concrete sequence of actions and checks involved in executing the task.

3. **Components**: 
   - TASK includes PDDL domain and problem definitions, focusing on the actions and predicates relevant to the task.
   - CODE_FUNC describes a function that runs a simulation, including environment setup and task execution.

4. **Execution Flow**: 
   - TASK outlines the necessary actions to achieve the goal but does not specify the order or method of execution.
   - CODE_FUNC explicitly states the order of operations (rotate, move, pick, pull) and includes checks for task completion.

5. **Environment Interaction**: 
   - TASK does not mention any interaction with the environment beyond the actions needed to unlock the cabinet.
   - CODE_FUNC includes details about initializing the environment, resetting the task, and shutting down the environment after completion.

6. **Output**: 
   - TASK does not specify any output or feedback mechanism.
   - CODE_FUNC includes print statements to indicate task completion after each step.

7. **Simulation Aspect**: 
   - TASK is a theoretical description of a task.
   - CODE_FUNC explicitly mentions running a simulation, which involves additional considerations like video recording.

8. **State Management**: 
   - TASK defines initial conditions and predicates but does not detail how states are managed during execution.
   - CODE_FUNC describes resetting the task to its initial state and checking the task's completion status.

9. **Error Handling**: 
   - TASK does not address error handling or conditions that might prevent task completion.
   - CODE_FUNC implies a structured approach to ensure the environment is properly managed, which may include error handling.

10. **Implementation Language**: 
    - TASK is written in PDDL, a planning domain definition language.
    - CODE_FUNC is described in a programming context, likely in a programming language suitable for simulation (not specified).

In summary, the semantic differences between TASK and CODE_FUNC are significant, as TASK is a high-level description of a goal, while CODE_FUNC provides a detailed implementation of how to achieve that goal through 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
        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
        obs, _, done = rotate(env, task, target_quat=np.array([0, 0, 0, 1]))  # Assuming zero rotation
        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_side_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 up 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)  # Assuming a pull distance of 0.1
        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 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. The function then attempts to pick up the bottom drawer and finally pulls it open. After each action, it checks if the task is completed and prints appropriate messages. Regardless of the outcome, the environment is shut down at the end of the function. The overall behavior is to simulate the process of opening a drawer in a controlled environment.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK describes a specific instruction for a user to perform an action (slide open any available drawer).
   - CODE_FUNC describes a function that simulates the process of manipulating a drawer programmatically.

2. **Level of Detail**: 
   - TASK provides a high-level instruction without implementation details.
   - CODE_FUNC includes specific steps and actions taken within the simulation, detailing the sequence of operations.

3. **Context**: 
   - TASK is presented as a standalone instruction applicable in a real-world or simulated context.
   - CODE_FUNC is embedded within a programming context, focusing on the execution of a simulation.

4. **Action Sequence**: 
   - TASK does not specify the sequence of actions required to open the drawer.
   - CODE_FUNC outlines a specific sequence of actions (rotate, move to side position, move to anchor position, pick, pull) to achieve the goal.

5. **Outcome**: 
   - TASK implies a goal (to open a drawer) but does not specify how to verify success.
   - CODE_FUNC includes checks for task completion and prints messages based on the outcome of the actions.

6. **Environment Setup**: 
   - TASK does not mention any setup or initialization.
   - CODE_FUNC describes the setup of the environment and the initial state before performing actions.

7. **Recording**: 
   - TASK does not mention any form of recording or monitoring.
   - CODE_FUNC includes an optional step for initializing video recording during the simulation.

8. **Finalization**: 
   - TASK does not address what happens after the action is performed.
   - CODE_FUNC explicitly states that the environment is shut down at the end of the function.

9. **User Interaction**: 
   - TASK is directed towards a user or operator to perform the action.
   - CODE_FUNC is directed towards a program or system executing the defined function without direct user interaction.

10. **Implementation Language**: 
    - TASK is written in natural language.
    - CODE_FUNC is written in a programming context, likely in a specific programming language.

11. **Focus**: 
    - TASK focuses on the action to be taken.
    - CODE_FUNC focuses on the implementation and execution of that action within a simulation framework.

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 the gripper!")
            return

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

