=== Instruction 1 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving a robotic gripper. It begins by setting up the environment and resetting the task to its initial state. The task captures video recordings of the simulation if needed. It retrieves the positions of various objects, including two tomatoes and a plate.

The task consists of a series of steps where the robotic gripper performs specific actions. First, it rotates to a specified angle, then moves to the side and anchor positions of a middle drawer. Next, it picks and pulls the middle drawer. After that, it picks the first tomato and places it on the plate, followed by picking the second tomato and placing it on the plate as well. 

At each step, the task checks if it has completed successfully and prints messages indicating the progress. Finally, the environment is shut down properly after the task is completed or if any step fails. The function is executed when the script is run directly.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Nature of Content**: 
   - TASK is a formal representation of a planning problem using PDDL (Planning Domain Definition Language), while CODE_FUNC is a description of a procedural function that outlines a simulation task involving a robotic gripper.

2. **Structure**: 
   - TASK is structured in a domain/problem format with types, predicates, and actions defined in a formal syntax, whereas CODE_FUNC is written in a narrative format describing the steps of a function without formal syntax.

3. **Purpose**: 
   - TASK is designed to define a planning problem for a robot to solve, focusing on the actions and states involved in manipulating objects. CODE_FUNC describes the execution of a simulation task, detailing how the robot interacts with the environment.

4. **Level of Abstraction**: 
   - TASK operates at a higher level of abstraction, focusing on the logical relationships and requirements for actions. CODE_FUNC provides a lower-level, step-by-step procedural description of how those actions are implemented in a simulation.

5. **Execution Context**: 
   - TASK is intended for use in a planning system that can interpret PDDL, while CODE_FUNC is meant to be executed as part of a programming script, likely in a programming language like Python.

6. **Action Specification**: 
   - In TASK, actions are defined with preconditions and effects, specifying what must be true before an action can occur and what changes after it occurs. CODE_FUNC describes actions in a sequential manner without formal preconditions and effects.

7. **Feedback Mechanism**: 
   - TASK does not include feedback mechanisms or success checks within its structure, while CODE_FUNC explicitly mentions checking for successful completion and printing progress messages.

8. **Environment Interaction**: 
   - TASK defines the environment and objects in a static manner, while CODE_FUNC describes dynamic interactions with the environment, including video recording and environment shutdown procedures.

9. **Object Handling**: 
   - TASK specifies how objects are manipulated through predicates and actions, while CODE_FUNC describes the sequence of picking and placing objects in a more narrative form.

10. **Error Handling**: 
    - CODE_FUNC includes a mechanism for handling failures during execution, whereas TASK does not address error handling or recovery.

11. **Output**: 
    - TASK does not produce output in the form of messages or logs, while CODE_FUNC includes print statements to indicate progress and completion.

12. **Simulation vs. Planning**: 
    - TASK is focused on planning actions based on logical conditions, while CODE_FUNC is focused on simulating those actions in a controlled environment.

13. **Initialization**: 
    - TASK initializes the state of the world through the `:init` section, while CODE_FUNC describes the initialization process in a procedural manner without formal syntax.

14. **Object Types**: 
    - TASK defines specific types for objects, drawers, and positions, while CODE_FUNC refers to these objects in a more general sense without explicit type definitions.

15. **Action Order**: 
    - TASK defines actions in a way that can be interpreted by a planner to determine the order of execution based on preconditions, while CODE_FUNC specifies a fixed order of actions to be executed sequentially.

16. **Robotic Gripper Interaction**: 
    - TASK includes specific predicates related to the gripper's state (e.g., `holding`, `gripper-at`), while CODE_FUNC describes the gripper's actions in a more descriptive manner without formal predicates.

17. **Domain Specificity**: 
    - TASK is specific to a combined domain of disposal and drawer manipulation, while CODE_FUNC is more focused on the simulation of a specific task involving those domains.

18. **Language**: 
    - TASK uses a specialized language (PDDL) for defining planning problems, while CODE_FUNC is written in a general programming language narrative.

19. **Complexity**: 
    - TASK may involve more complex logical relationships and conditions due to its planning nature, while CODE_FUNC is more straightforward and linear in its execution flow.

20. **Reusability**: 
    - TASK can be reused in different planning scenarios by modifying the PDDL definitions, while CODE_FUNC is more tailored to a specific simulation task and may require modifications for different tasks.

In summary, the semantic differences between TASK and CODE_FUNC are significant, reflecting their distinct purposes, structures, and contexts of use.

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 object positions
        tomato1_pos = positions['tomato1']
        tomato2_pos = positions['tomato2']
        plate_pos = positions['plate']
        
        # === 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, np.sin(np.pi/4), np.cos(np.pi/4)]))
        if done:
            print("[Task] Task ended after rotating gripper!")
            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['middle_side_pos'])
        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['middle_anchor_pos'])
        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_drawer(env, task, gripper='gripper', d='middle', p='middle_anchor_pos')
        if done:
            print("[Task] Task ended after picking the drawer!")
            return

        # Step 5: Pull the middle drawer
        print("[Task] Pulling the middle drawer.")
        obs, reward, done = pull(env, task, pull_distance=0.1)
        if done:
            print("[Task] Task ended after pulling the drawer!")
            return

        # Step 6: Pick the first tomato
        print("[Task] Picking the first tomato.")
        obs, reward, done = pick(env, task, target_pos=tomato1_pos)
        if done:
            print("[Task] Task ended after picking the first tomato!")
            return

        # Step 7: Place the first tomato on the plate
        print("[Task] Placing the first tomato on the plate.")
        obs, reward, done = place(env, task, target_pos=plate_pos)
        if done:
            print("[Task] Task ended after placing the first tomato!")
            return

        # Step 8: Pick the second tomato
        print("[Task] Picking the second tomato.")
        obs, reward, done = pick(env, task, target_pos=tomato2_pos)
        if done:
            print("[Task] Task ended after picking the second tomato!")
            return

        # Step 9: Place the second tomato on the plate
        print("[Task] Placing the second tomato on the plate.")
        obs, reward, done = place(env, task, target_pos=plate_pos)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
            return

    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. 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, including anchors, sides, and tomatoes.

The task consists of a series of steps where the gripper rotates to a specified orientation, moves to specific positions, picks up a drawer, pulls it open, and then picks and places two tomatoes onto a plate. After each action, the function checks if the task is complete and prints a message if it is. Finally, the environment is shut down properly after the task execution. 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 describes a specific instruction for a robotic action involving pulling a drawer and placing tomatoes on a plate.
   - CODE_FUNC outlines a function that simulates a series of robotic actions, including setup, execution, and completion checks.

2. **Structure**: 
   - TASK is presented in a PDDL format defining a domain and problem with types, predicates, and actions.
   - CODE_FUNC is described in a narrative format detailing the steps of a function without formal structure.

3. **Detail Level**: 
   - TASK includes detailed definitions of actions, preconditions, and effects in a formalized manner.
   - CODE_FUNC provides a high-level overview of the simulation process without specific details on preconditions or effects.

4. **Execution Context**: 
   - TASK is a declarative representation meant for planning and execution in a PDDL-based environment.
   - CODE_FUNC is an imperative representation that describes how to run a simulation programmatically.

5. **Action Specification**: 
   - TASK specifies actions like `pick`, `place`, `pull`, and their conditions explicitly.
   - CODE_FUNC describes a sequence of actions but does not specify the conditions or effects in detail.

6. **Output and Feedback**: 
   - TASK does not mention any output or feedback mechanism.
   - CODE_FUNC includes a mechanism to print messages upon task completion.

7. **Environment Management**: 
   - TASK does not address environment setup or teardown.
   - CODE_FUNC explicitly mentions initializing and shutting down the environment.

8. **Initialization**: 
   - TASK initializes objects and states within the PDDL framework.
   - CODE_FUNC describes initializing the simulation environment and optionally recording video.

9. **Completeness Check**: 
   - TASK does not include any checks for task completion.
   - CODE_FUNC includes checks after each action to determine if the task is complete.

10. **Execution Trigger**: 
    - TASK does not specify how or when the actions are triggered.
    - CODE_FUNC specifies that the function is executed when the script is run as the main program.

11. **Focus**: 
    - TASK focuses on the logical representation of actions and their relationships.
    - CODE_FUNC focuses on the procedural execution of a series of actions in a simulation.

12. **Language**: 
    - TASK uses PDDL, a domain-specific language for planning.
    - CODE_FUNC uses a general programming language narrative without specific syntax.

13. **Robotic Interaction**: 
    - TASK describes interactions with objects in a formalized way.
    - CODE_FUNC describes interactions in a more abstract manner without formal definitions.

14. **Action Order**: 
    - TASK defines actions in a way that can be interpreted by a planner.
    - CODE_FUNC describes a specific order of operations that must be followed in the simulation.

15. **Types and Predicates**: 
    - TASK defines types and predicates that are used to describe the state of the world.
    - CODE_FUNC does not define types or predicates, focusing instead on procedural steps.

16. **Flexibility**: 
    - TASK is designed for flexibility in planning various scenarios based on the defined actions and predicates.
    - CODE_FUNC is more rigid, following a specific sequence of actions without variation.

17. **Error Handling**: 
    - TASK does not address error handling or exceptions.
    - CODE_FUNC does not explicitly mention error handling but implies checks for task completion.

18. **User Interaction**: 
    - TASK does not involve user interaction.
    - CODE_FUNC may involve user interaction through printed messages or video recording.

19. **State Representation**: 
    - TASK represents the state of the world through predicates and initial conditions.
    - CODE_FUNC represents the state through variables and function parameters.

20. **Simulation vs. Planning**: 
    - TASK is focused on planning actions based on logical conditions.
    - CODE_FUNC is focused on simulating those actions in a controlled environment.

In summary, the semantic differences between TASK and CODE_FUNC are significant, reflecting their distinct purposes, structures, and contexts.

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 object positions
        bottom_anchor_pos = positions['bottom_anchor_pos']
        bottom_side_pos = positions['bottom_side_pos']
        plate_pos = positions['plate']
        tomato1_pos = positions['tomato1']
        tomato2_pos = positions['tomato2']

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

        # Step 2: Move to side position of the bottom drawer
        obs, reward, 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 anchor position of the bottom drawer
        obs, reward, 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, reward, done = pick_drawer(env, task, gripper='gripper', d='bottom', p=bottom_anchor_pos)
        if done:
            print("[Task] Task ended after picking the drawer!")
            return

        # Step 5: Pull the bottom drawer open
        obs, reward, done = pull(env, task, gripper='gripper', d='bottom')
        if done:
            print("[Task] Task ended after pulling the drawer!")
            return

        # Step 6: Pick the first tomato
        obs, reward, done = pick(env, task, target_pos=tomato1_pos)
        if done:
            print("[Task] Task ended after picking tomato1!")
            return

        # Step 7: Place the first tomato on the plate
        obs, reward, done = place(env, task, target_pos=plate_pos)
        if done:
            print("[Task] Task ended after placing tomato1!")
            return

        # Step 8: Pick the second tomato
        obs, reward, done = pick(env, task, target_pos=tomato2_pos)
        if done:
            print("[Task] Task ended after picking tomato2!")
            return

        # Step 9: Place the second tomato on the plate
        obs, reward, done = place(env, task, target_pos=plate_pos)
        if done:
            print("[Task] Task ended after placing tomato2!")
            return

    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. It begins by setting up the environment and resetting the task to its initial state. The simulation captures video recordings of the task's execution. 

The function retrieves the positions of various objects in the environment, including anchors, sides, and tomatoes. It then executes a series of steps where the gripper rotates, moves to specific positions, picks up a drawer, pulls it out, and picks up two tomatoes one at a time, placing each on a plate. 

After each action, the function checks if the task is completed and prints a message indicating the status. Finally, it ensures that the environment is properly shut down after the task execution. The overall behavior is to simulate a sequence of actions performed by a robotic gripper in a controlled environment.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Nature of Content**: 
   - TASK is a detailed description of a specific instruction and the associated PDDL (Planning Domain Definition Language) domain and problem setup for a robotic task.
   - CODE_FUNC is a high-level overview of a function that simulates the execution of a robotic task, focusing on the procedural aspects rather than the formal definitions.

2. **Level of Detail**:
   - TASK includes specific predicates, actions, and their preconditions and effects, providing a comprehensive framework for planning and executing the task.
   - CODE_FUNC provides a summary of the function's purpose and actions without delving into the specifics of the implementation or the planning details.

3. **Purpose**:
   - TASK is designed to define a planning problem for a robot to solve, including the environment, objects, and actions.
   - CODE_FUNC is intended to describe the execution of a simulation of the task, focusing on the operational aspect rather than the planning aspect.

4. **Structure**:
   - TASK is structured in a formal way using PDDL syntax, which is specific to planning problems.
   - CODE_FUNC is written in a narrative style, summarizing the function's behavior and steps without formal syntax.

5. **Focus**:
   - TASK focuses on the definitions of actions, predicates, and the initial state of the environment necessary for planning.
   - CODE_FUNC focuses on the execution of the task, including the sequence of actions and the simulation environment.

6. **Execution vs. Planning**:
   - TASK is primarily concerned with the planning phase, where the robot's actions are defined and structured.
   - CODE_FUNC is concerned with the execution phase, where the defined actions are carried out in a simulated environment.

7. **Output**:
   - TASK does not specify any output or results from the execution of the actions; it is purely a planning document.
   - CODE_FUNC mentions capturing video recordings and printing status messages, indicating a focus on the results of the execution.

8. **Context**:
   - TASK is set in the context of defining a robotic task using PDDL, which is a formal language for representing planning problems.
   - CODE_FUNC is set in the context of a programming function that simulates the task, likely in a programming language environment.

9. **Action Representation**:
   - In TASK, actions are defined with specific parameters, preconditions, and effects in a formal manner.
   - In CODE_FUNC, actions are described in a more abstract way, focusing on the sequence rather than the formal definitions.

10. **Environment Setup**:
    - TASK includes detailed definitions of objects, their types, and initial conditions in the PDDL format.
    - CODE_FUNC describes the environment setup in a more general sense, without the formal structure of PDDL.

In summary, the semantic differences between TASK and CODE_FUNC are significant, as they serve different purposes and are structured in different ways.

Refined Code Generated:
-------------------
import numpy as np
from pyrep.objects.shape import Shape
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:
        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']
        bottom_side_pos = positions['bottom_side_pos']
        plate_pos = positions['plate']
        tomato1_pos = positions['tomato1']
        tomato2_pos = positions['tomato2']

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

        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

        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

        obs, reward, done = pick_drawer(env, task, gripper='gripper', d='bottom', p='anchor-pos-bottom')
        if done:
            print("[Task] Task ended after picking the drawer!")
            return

        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 ended after pulling the drawer!")
            return

        obs, reward, done = pick(env, task, target_pos=tomato1_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 first tomato!")
            return

        obs, reward, done = place(env, task, target_pos=plate_pos, approach_distance=0.15, max_steps=100, threshold=0.01, approach_axis='z', timeout=10.0)
        if done:
            print("[Task] Task ended after placing the first tomato!")
            return

        obs, reward, done = pick(env, task, target_pos=tomato2_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 second tomato!")
            return

        obs, reward, done = place(env, task, target_pos=plate_pos, approach_distance=0.15, max_steps=100, threshold=0.01, approach_axis='z', 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 4 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function that simulates a task in a robotic environment. 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 needed for the task.

The task consists of a series of steps where the robot performs actions such as rotating its gripper, moving to specific positions, picking up a drawer, pulling it open, and picking and placing two tomatoes onto a plate. After each action, the function checks if the task is completed and prints a message accordingly. Finally, it ensures that the environment is properly shut down after the task is finished. The overall goal is to simulate the process of retrieving and placing items in a structured manner.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK describes a specific sequence of actions to achieve a goal (unlocking a cabinet and transferring tomatoes).
   - CODE_FUNC describes a function that simulates the execution of a task in a robotic environment.

2. **Structure**: 
   - TASK is presented in a natural language format with clear instructions.
   - CODE_FUNC is presented in a programming context, detailing the implementation of the task.

3. **Detail Level**: 
   - TASK provides high-level instructions without implementation specifics.
   - CODE_FUNC includes detailed steps, including initialization, action execution, and completion checks.

4. **Context**: 
   - TASK is focused on the actions to be performed in a physical or simulated environment.
   - CODE_FUNC is focused on the programming logic and structure to simulate the task.

5. **Outcome**: 
   - TASK specifies the desired outcome (transfer of tomatoes).
   - CODE_FUNC describes the process and checks for task completion, focusing on the simulation aspect.

6. **Language**: 
   - TASK uses imperative language to instruct actions.
   - CODE_FUNC uses descriptive language to explain the function and its operations.

7. **Execution**: 
   - TASK does not specify how the actions are executed.
   - CODE_FUNC outlines the execution flow, including initialization and shutdown procedures.

8. **Environment Interaction**: 
   - TASK implies interaction with physical objects (cabinet, tomatoes, plate).
   - CODE_FUNC explicitly mentions the simulation of these interactions within a programmed environment.

9. **Feedback Mechanism**: 
   - TASK does not include feedback or checks for success.
   - CODE_FUNC includes checks after each action to confirm task completion and provide feedback.

10. **Initialization and Cleanup**: 
    - TASK does not mention any setup or teardown processes.
    - CODE_FUNC includes initialization of the environment and ensures proper shutdown 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
        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 object positions
        bottom_anchor_pos = positions['bottom_anchor_pos']
        bottom_side_pos = positions['bottom_side_pos']
        plate_pos = positions['plate']
        tomato1_pos = positions['tomato1']
        tomato2_pos = positions['tomato2']

        # === Execute the Plan ===
        # Step 1: Rotate the 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

        # Step 2: Move to the 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 the side position!")
            return

        # Step 3: Move to the 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 the anchor position!")
            return

        # Step 4: Pick the bottom drawer
        obs, reward, done = pick_drawer(env, task, gripper='gripper', d='bottom', p=bottom_anchor_pos)
        if done:
            print("[Task] Task ended after picking the drawer!")
            return

        # Step 5: Pull the bottom drawer to open it
        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 ended after pulling the drawer!")
            return

        # Step 6: Pick the first tomato
        obs, reward, done = pick(env, task, target_pos=tomato1_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 first tomato!")
            return

        # Step 7: Place the first tomato on the plate
        obs, reward, done = place(env, task, target_pos=plate_pos, approach_distance=0.15, max_steps=100, threshold=0.01, approach_axis='z', timeout=10.0)
        if done:
            print("[Task] Task ended after placing the first tomato!")
            return

        # Step 8: Pick the second tomato
        obs, reward, done = pick(env, task, target_pos=tomato2_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 second tomato!")
            return

        # Step 9: Place the second tomato on the plate
        obs, reward, done = place(env, task, target_pos=plate_pos, approach_distance=0.15, max_steps=100, threshold=0.01, approach_axis='z', 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 a robotic gripper. 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, including tomatoes and a plate.

The task consists of a series of steps where the robot performs specific actions: it rotates the gripper, moves to designated positions, picks up a drawer, pulls it open, and picks up two tomatoes from a table, placing each onto a plate. After each action, the function checks if the task is completed and prints a message accordingly. Finally, it ensures that the environment is properly shut down after the task execution. The overall behavior is to simulate a sequence of actions performed by a robot in a controlled environment.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - **TASK** describes a specific instruction for a robot to perform a sequence of actions involving drawers and tomatoes.
   - **CODE_FUNC** outlines a function that simulates the execution of the TASK in a programming environment.

2. **Level of Abstraction**:
   - **TASK** is a high-level description of what needs to be done without detailing how it will be executed.
   - **CODE_FUNC** provides a low-level implementation that includes specific programming constructs and logic to carry out the TASK.

3. **Content**:
   - **TASK** includes a natural language instruction and a PDDL domain definition that specifies the types, predicates, and actions relevant to the task.
   - **CODE_FUNC** focuses on the procedural steps and logic required to simulate the task, including environment setup, action execution, and task completion checks.

4. **Execution Context**:
   - **TASK** is designed to be interpreted by a planner or a robot operating system that understands PDDL.
   - **CODE_FUNC** is meant to be executed within a programming environment, likely as part of a simulation framework.

5. **Action Specification**:
   - **TASK** specifies actions in terms of PDDL actions (e.g., `pick`, `place`, `rotate`, `move-to-side`, `move-to-anchor`, `pick-drawer`, `pull`).
   - **CODE_FUNC** describes the sequence of actions in a narrative form, detailing how the robot interacts with the environment (e.g., "rotates the gripper", "moves to designated positions").

6. **Feedback Mechanism**:
   - **TASK** does not include any feedback mechanism; it simply states what should happen.
   - **CODE_FUNC** includes checks after each action to determine if the task is completed and prints messages accordingly.

7. **Environment Management**:
   - **TASK** does not address the management of the simulation environment.
   - **CODE_FUNC** explicitly mentions resetting the environment and shutting it down after task execution.

8. **Initialization**:
   - **TASK** initializes the state of the world through PDDL's `:init` section.
   - **CODE_FUNC** includes procedural steps to set up the environment and optionally initialize video recording.

9. **Object Interaction**:
   - **TASK** describes interactions in terms of predicates and actions defined in PDDL.
   - **CODE_FUNC** describes interactions in a more narrative and procedural manner, detailing how the robot manipulates objects.

10. **Output**:
    - **TASK** does not produce output; it is a specification.
    - **CODE_FUNC** includes print statements to provide feedback on the task's progress and completion.

In summary, while both TASK and CODE_FUNC are related to the same underlying task, they differ significantly in purpose, abstraction level, content, execution context, action specification, feedback mechanisms, environment management, initialization, object interaction, and output.

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 object positions
        tomato1_pos = positions['tomato1']
        tomato2_pos = positions['tomato2']
        plate_pos = positions['plate']
        middle_anchor_pos = positions['middle_anchor_pos']
        middle_side_pos = positions['middle_side_pos']

        # === Execute the Plan ===
        # Step 1: Rotate the gripper to ninety degrees
        obs, reward, 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 after rotating!")
            return

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

        # Step 3: Move to the anchor position of the middle drawer
        obs, reward, 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, reward, done = pick_drawing(env, task, gripper='gripper', d='middle', p='anchor-pos-middle')
        if done:
            print("[Task] Task ended after picking the drawer!")
            return

        # Step 5: Pull the middle drawer open
        obs, reward, done = pull(env, task, pull_distance=0.1)
        if done:
            print("[Task] Task ended after pulling the drawer!")
            return

        # Step 6: Pick the first tomato from the table
        obs, reward, done = pick(env, task, target_pos=tomato1_pos)
        if done:
            print("[Task] Task ended after picking tomato1!")
            return

        # Step 7: Place the first tomato onto the plate
        obs, reward, done = place(env, task, target_pos=plate_pos)
        if done:
            print("[Task] Task ended after placing tomato1!")
            return

        # Step 8: Pick the second tomato from the table
        obs, reward, done = pick(env, task, target_pos=tomato2_pos)
        if done:
            print("[Task] Task ended after picking tomato2!")
            return

        # Step 9: Place the second tomato onto the plate
        obs, reward, done = place(env, task, target_pos=plate_pos)
        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()
-------------------

