=== 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. It optionally initializes video recording for the simulation. The function retrieves the positions of various objects, including a drawer and two tomatoes.

The task consists of a series of steps where the gripper rotates, moves to specific positions, picks up a drawer, pulls it open, 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 the environment is properly shut down after the task is finished. 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. **Purpose**: 
   - **TASK**: Describes a specific instruction for a robotic action involving opening a drawer and placing tomatoes on a plate.
   - **CODE_FUNC**: Describes a function that simulates a series of actions performed by a robotic gripper, including setup, execution, and shutdown.

2. **Level of Detail**:
   - **TASK**: Provides a high-level instruction without implementation details.
   - **CODE_FUNC**: Includes detailed steps of the simulation process, including initialization, action sequences, and status checks.

3. **Context**:
   - **TASK**: Focuses on a single task involving physical manipulation of objects.
   - **CODE_FUNC**: Encompasses a broader context of running a simulation, including environment setup and task management.

4. **Components**:
   - **TASK**: Involves specific actions (open drawer, place tomatoes) without elaboration on the mechanics.
   - **CODE_FUNC**: Involves multiple components such as environment setup, object retrieval, action execution, and task completion checks.

5. **Execution**:
   - **TASK**: Implies a direct execution of actions based on the instruction.
   - **CODE_FUNC**: Describes a procedural execution of actions within a simulation framework, including potential video recording.

6. **Outcome**:
   - **TASK**: The outcome is the successful placement of tomatoes on a plate.
   - **CODE_FUNC**: The outcome includes not only the placement of tomatoes but also the completion of the simulation and proper shutdown of the environment.

7. **Action Sequence**:
   - **TASK**: Specifies a sequence of actions in a straightforward manner.
   - **CODE_FUNC**: Details a more complex sequence of actions, including checks and status updates after each action.

8. **Error Handling**:
   - **TASK**: Does not mention error handling or contingencies.
   - **CODE_FUNC**: Implies checks for task completion and possibly error handling through status messages.

9. **Environment Interaction**:
   - **TASK**: Focuses solely on the actions to be performed.
   - **CODE_FUNC**: Involves interaction with the simulation environment, including initialization and shutdown processes.

10. **Robotic Gripper Role**:
    - **TASK**: Mentions the gripper implicitly as the agent performing actions.
    - **CODE_FUNC**: Explicitly describes the gripper's actions and its state throughout the simulation.

11. **Initialization**:
    - **TASK**: Assumes an initialized state without detailing it.
    - **CODE_FUNC**: Explicitly includes initialization steps for the simulation environment.

12. **Feedback Mechanism**:
    - **TASK**: Does not provide feedback mechanisms.
    - **CODE_FUNC**: Includes feedback through status messages indicating the progress of the task.

13. **Simulation Aspect**:
    - **TASK**: Does not mention simulation; it is a direct instruction.
    - **CODE_FUNC**: Clearly states that it is a simulation task, involving a controlled environment.

14. **Object Management**:
    - **TASK**: Focuses on the tomatoes and the drawer.
    - **CODE_FUNC**: Involves managing multiple objects and their states throughout the simulation.

15. **Complexity**:
    - **TASK**: Simple and straightforward.
    - **CODE_FUNC**: More complex due to the inclusion of multiple steps, checks, and environment management.

16. **Language**:
    - **TASK**: Uses imperative language for instructions.
    - **CODE_FUNC**: Uses descriptive language to explain the function and its components.

17. **Completion Criteria**:
    - **TASK**: Implies completion when tomatoes are placed on the plate.
    - **CODE_FUNC**: Specifies checks for task completion and provides status updates.

18. **Recording**:
    - **TASK**: Does not mention recording or monitoring.
    - **CODE_FUNC**: Mentions optional video recording for the simulation.

19. **State Management**:
    - **TASK**: Does not address state management.
    - **CODE_FUNC**: Involves managing the state of the environment and objects throughout the simulation.

20. **Finalization**:
    - **TASK**: Does not include finalization steps.
    - **CODE_FUNC**: Includes steps to ensure proper shutdown of the environment after task completion.

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
        _, 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']
        tomato1_pos = positions['tomato1']
        tomato2_pos = positions['tomato2']
        plate_pos = positions['plate']

        # === 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 bottom drawer
        obs, reward, done = move(env, task, 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, reward, done = move(env, task, 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', 'bottom', 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', 'bottom')
        if done:
            print("[Task] Task ended after pulling the drawer!")
            return

        # Step 6: Pick the first tomato
        obs, reward, done = pick(env, task, tomato1_pos, 'gripper')
        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, plate_pos)
        if done:
            print("[Task] Task ended after placing tomato1 on the plate!")
            return

        # Step 8: Pick the second tomato
        obs, reward, done = pick(env, task, tomato2_pos, 'gripper')
        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, 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()
-------------------

=== Instruction 2 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function that simulates a robotic task involving the manipulation of objects in a virtual environment. It begins by setting up the environment and resetting the task to its initial state. The function initializes video recording capabilities and retrieves the positions of various objects, including a drawer and tomatoes.

The task consists of a series of steps where the robot performs specific actions: it rotates its gripper, moves to designated positions, picks up a drawer, pulls it open, 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 relevant messages. Finally, it ensures that the environment is properly shut down after the task execution. The overall behavior is to automate the process of picking and placing items in a simulated environment.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - **TASK**: Describes a specific sequence of actions to be performed by a robot in a defined environment.
   - **CODE_FUNC**: Describes a function that simulates the robotic task, including setup, execution, and shutdown.

2. **Structure**: 
   - **TASK**: Presented in a formal PDDL (Planning Domain Definition Language) format, defining actions, predicates, and the environment.
   - **CODE_FUNC**: Described in a narrative format, outlining the function's behavior and steps without formal syntax.

3. **Detail Level**: 
   - **TASK**: Provides detailed definitions of actions, preconditions, and effects in a structured manner.
   - **CODE_FUNC**: Offers a high-level overview of the task without delving into the specifics of action definitions or preconditions.

4. **Execution Context**: 
   - **TASK**: Focuses on the logical representation of actions and their relationships in a planning context.
   - **CODE_FUNC**: Emphasizes the procedural execution of actions in a simulated environment, including video recording and message printing.

5. **Action Representation**: 
   - **TASK**: Actions are defined with parameters, preconditions, and effects in a declarative manner.
   - **CODE_FUNC**: Actions are described in a procedural manner, detailing the sequence of operations without formal action definitions.

6. **Environment Interaction**: 
   - **TASK**: Specifies the initial state and conditions for actions to be executed.
   - **CODE_FUNC**: Mentions the retrieval of object positions and the management of the environment during and after task execution.

7. **Output**: 
   - **TASK**: Does not specify output; focuses on the logical flow of actions.
   - **CODE_FUNC**: Includes printing messages to indicate task progress and completion.

8. **Initialization**: 
   - **TASK**: Initialization is defined within the PDDL problem setup.
   - **CODE_FUNC**: Initialization is described as part of the function's procedural steps, including video recording setup.

9. **Completion Check**: 
   - **TASK**: Does not include a mechanism for checking task completion.
   - **CODE_FUNC**: Explicitly checks if the task is completed after each action.

10. **Shutdown Procedure**: 
    - **TASK**: No shutdown procedure is mentioned.
    - **CODE_FUNC**: Includes a step to ensure proper shutdown of the environment after task execution.

In summary, the semantic differences between TASK and CODE_FUNC are significant, as they represent different aspects of the same robotic task: one in a formal planning context and the other in a procedural programming 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
        _, 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']
        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, 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
        print("[Task] Moving to side position of the bottom drawer.")
        obs, reward, done = move(env, task, target_pos=bottom_side_pos, max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended after moving to side position!")
            return

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

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

        # Step 5: Pull open the bottom drawer
        print("[Task] Pulling open the bottom 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 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, 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
        print("[Task] Placing 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
        print("[Task] Picking 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
        print("[Task] Placing 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 =====")
-------------------

=== Instruction 3 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving the manipulation of objects in an 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, including a drawer and two tomatoes.

The task consists of a series of steps: first, the gripper is rotated to the correct orientation. Then, the system moves to the side position of a bottom drawer, followed by moving to the anchor position of the drawer. The next step involves picking up the bottom drawer and pulling it out a specified distance. 

After that, the first tomato is picked up and placed on a plate, followed by the same actions for the second tomato. Throughout the process, the function checks if the task has ended after each step, ensuring that it can handle interruptions. Finally, the environment is shut down properly, and a message indicates the successful completion of the task.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Nature of Content**: TASK is a PDDL (Planning Domain Definition Language) representation of a task, while CODE_FUNC describes a procedural function for simulating the task.
2. **Format**: TASK is structured in a formal domain and problem definition format, whereas CODE_FUNC is written in a narrative style describing the steps of a simulation.
3. **Purpose**: TASK defines the rules and actions for a planning problem, while CODE_FUNC outlines the execution of those actions in a simulation context.
4. **Detail Level**: TASK includes detailed preconditions and effects for actions, while CODE_FUNC summarizes the actions without specifying preconditions or effects.
5. **Action Specification**: TASK explicitly defines actions like `pick`, `place`, `rotate`, etc., with parameters and conditions, while CODE_FUNC describes the actions in a more general way without formal definitions.
6. **Environment Setup**: TASK includes the initial state and object definitions in a structured format, while CODE_FUNC describes the setup in a more narrative manner.
7. **Execution Flow**: TASK does not specify the order of execution beyond the definitions of actions, while CODE_FUNC outlines a specific sequence of operations to be performed.
8. **Error Handling**: CODE_FUNC mentions checking if the task has ended and handling interruptions, which is not addressed in TASK.
9. **Output**: TASK does not specify an output or completion message, while CODE_FUNC concludes with a message indicating successful task completion.
10. **Simulation Aspect**: CODE_FUNC explicitly mentions simulation and video recording, which is not present in TASK. 

In summary, the two representations serve different purposes and are structured differently, leading to multiple semantic differences.

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

from env import setup_environment, shutdown_environment
from skill_code import *
from video import init_video_writers, recording_step, recording_get_observation
from object_positions import get_object_positions

def run_skeleton_task():
    '''Generic skeleton for running any task in your simulation.'''
    print("===== Starting Skeleton Task =====")
    
    # === 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 object positions
        bottom_anchor_pos = positions['bottom_anchor_pos']
        bottom_side_pos = positions['bottom_side_pos']
        tomato1_pos = positions['tomato1']
        tomato2_pos = positions['tomato2']
        plate_pos = positions['plate']

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

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

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

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

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

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

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

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

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

        print("[Task] All tomatoes have been placed on the plate successfully!")

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

    print("===== End of 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. 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 predefined positions for various objects, including anchors, sides, and tomatoes. It then executes a series of steps to manipulate these objects: rotating the gripper, moving to specific positions, picking and pulling a drawer, and picking and placing two tomatoes onto a plate. 

After each action, the function checks if the task is complete and prints a message indicating the status. Finally, it ensures that the environment is properly shut down after the task is finished. The overall goal is to simulate a sequence of actions involving object manipulation in a controlled environment.
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 involving a robotic gripper.

2. **Detail Level**: 
   - **TASK**: Provides detailed instructions on how to perform the task step-by-step.
   - **CODE_FUNC**: Provides a high-level overview of the function's purpose and actions without specific step-by-step instructions.

3. **Context**: 
   - **TASK**: Focuses on a physical task involving real-world objects (cabinet, tomatoes, plate).
   - **CODE_FUNC**: Focuses on a simulation environment and the execution of a function within that environment.

4. **Action Specification**: 
   - **TASK**: Specifies actions in a natural language format (e.g., "unlock the cabinet").
   - **CODE_FUNC**: Describes actions in terms of function calls and programming logic (e.g., "executing a series of steps").

5. **Outcome**: 
   - **TASK**: The outcome is the successful completion of the physical task.
   - **CODE_FUNC**: The outcome is the successful simulation of the task, including video recordings and status messages.

6. **Environment**: 
   - **TASK**: Implies a physical environment where the actions take place.
   - **CODE_FUNC**: Implies a virtual or simulated environment for executing the task.

7. **Feedback Mechanism**: 
   - **TASK**: Does not mention feedback or status updates during the task.
   - **CODE_FUNC**: Includes a mechanism to check task completion and print status messages.

8. **Initialization**: 
   - **TASK**: Does not specify how the initial state is set up.
   - **CODE_FUNC**: Mentions resetting the task to its initial state as part of the function.

9. **Object Interaction**: 
   - **TASK**: Focuses on the interaction with specific objects (drawer, tomatoes, plate).
   - **CODE_FUNC**: Mentions retrieving predefined positions for various objects but does not detail the interactions as explicitly.

10. **Shutdown Procedure**: 
    - **TASK**: Does not include any shutdown or cleanup procedures.
    - **CODE_FUNC**: Mentions ensuring the environment is properly shut down after the task is finished.

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:
        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: return

        obs, reward, done = move(env, task, target_pos=bottom_side_pos, max_steps=100, threshold=0.01, timeout=10.0)
        if done: return

        obs, reward, done = move(env, task, target_pos=bottom_anchor_pos, max_steps=100, threshold=0.01, timeout=10.0)
        if done: return

        obs, reward, done = pick_drawer(env, task, gripper='gripper', d='bottom', p=bottom_anchor_pos)
        if done: 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: 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: 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: 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: 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 5 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function that simulates a robotic task involving the manipulation of objects in an environment. It begins by setting up the environment and resetting the task to its initial state. The simulation can optionally record video of the task execution.

The function retrieves the positions of various objects, including a drawer and two tomatoes. It then executes a series of steps to complete the task. These steps include rotating a 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 relevant messages. Finally, it ensures that the environment is properly shut down after the task execution. The overall behavior is to automate the process of manipulating objects in a simulated environment.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK describes a specific instruction for a robotic action involving drawers and tomatoes.
   - CODE_FUNC outlines a function that simulates the execution of a robotic task, including setup and environment management.

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 and logic of a function without formal syntax.

3. **Detail Level**: 
   - TASK provides a detailed specification of actions, preconditions, and effects in a structured manner.
   - CODE_FUNC gives a high-level overview of the task execution process without specific details on preconditions or effects.

4. **Execution Context**: 
   - TASK is designed for planning and reasoning about actions in a formal domain.
   - CODE_FUNC is focused on the simulation and execution of those actions in a programming context.

5. **Output**: 
   - TASK does not specify any output or feedback mechanism.
   - CODE_FUNC mentions printing relevant messages after actions and checking task completion.

6. **Environment Management**: 
   - TASK does not address environment setup or teardown.
   - CODE_FUNC includes steps for resetting the environment and shutting it down after task execution.

7. **Action Sequence**: 
   - TASK lists actions in a formalized way with specific parameters and conditions.
   - CODE_FUNC describes a sequence of actions in a more narrative form, focusing on the flow of execution rather than formal action definitions.

8. **Flexibility**: 
   - TASK is rigidly defined by the PDDL structure, which may limit adaptability.
   - CODE_FUNC can be more easily modified or extended due to its programming nature.

9. **Simulation Aspect**: 
   - TASK does not imply any simulation or execution context.
   - CODE_FUNC explicitly states that it simulates the task execution.

10. **Video Recording**: 
    - TASK does not mention any form of recording or visualization.
    - CODE_FUNC includes an option to record video of the task execution.

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

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 object positions
        bottom_anchor_pos = positions['bottom_anchor_pos']
        bottom_side_pos = positions['bottom_side_pos']
        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, 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
        print("[Task] Moving to side position of the bottom drawer.")
        obs, reward, done = move(env, task, target_pos=bottom_side_pos, max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended after moving to side position!")
            return

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

        # Step 4: Pick the bottom drawer
        print("[Task] Picking the bottom drawer.")
        obs, reward, done = pick_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
        print("[Task] Pulling the bottom drawer open.")
        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
        print("[Task] Picking 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
        print("[Task] Placing 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
        print("[Task] Picking 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
        print("[Task] Placing 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()
-------------------

