=== Instruction 1 ===
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 specific objects, namely two tomatoes and a plate.

The task consists of a series of steps: first, it pulls a drawer, then picks the first tomato and places it on the plate, followed by picking the second tomato and placing it on the plate as well. After each action, it checks if the task is completed and prints appropriate messages. Finally, it ensures that the environment is properly shut down 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 robot to perform, while CODE_FUNC outlines a function that implements a series of actions to achieve a task in a simulation environment.
2. **Structure**: TASK is presented in a natural language format, while CODE_FUNC is structured as a programming function with defined steps and logic.
3. **Detail Level**: TASK provides a high-level overview of the actions to be taken, whereas CODE_FUNC includes detailed procedural steps and checks for task completion.
4. **Execution Context**: TASK is a directive for action, while CODE_FUNC is a script that runs in a programming environment to simulate the task.
5. **Action Sequence**: TASK specifies a single action (open a drawer and place tomatoes), while CODE_FUNC outlines multiple sequential actions (pull drawer, pick tomatoes, place on plate).
6. **Feedback Mechanism**: CODE_FUNC includes checks and messages for task completion, which are not present in TASK.
7. **Initialization**: CODE_FUNC includes setup and initialization steps for the simulation environment, which are absent in TASK.
8. **Environment Management**: CODE_FUNC mentions shutting down the environment after execution, while TASK does not address environmental considerations.

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 positions for the tomatoes and the plate
        tomato1_pos = positions['item1']
        tomato2_pos = positions['item2']
        plate_pos = positions['plate']
        
        # Step 1: Pull the top drawer
        print("[Task] Pulling the top drawer.")
        obs, reward, done = pull(env, task, pull_distance=0.1, pull_axis='y')
        if done:
            print("[Task] Task ended after pulling the drawer!")
            return

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

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

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

        # Step 5: Place the second tomato on the plate
        print("[Task] Placing tomato2 on the plate.")
        obs, reward, done = place(env, task, target_pos=plate_pos, approach_distance=0.15)
        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 to run a simulation task involving object manipulation. It begins by setting up the environment and resetting the task to its initial state. It optionally initializes video recording for the simulation. The function retrieves the positions of objects in the environment, specifically a plate and a top drawer. 

The task consists of three main steps: first, it attempts to pull open the top drawer, checking if the action is successful. Next, it places the first tomato onto the plate, again verifying the success of the action. Finally, it places a second tomato onto the plate, with a similar success check. 

Regardless of the outcome of these actions, the environment is ensured to be properly shut down at the end of the task. The function prints messages to indicate the progress and success of each step throughout the process.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK describes a specific sequence of actions to be performed (pulling a drawer and placing tomatoes), while CODE_FUNC outlines a function that simulates this task programmatically.

2. **Structure**: 
   - TASK is presented in a PDDL format defining a domain and problem, whereas CODE_FUNC is described in a narrative format detailing the steps of a function.

3. **Action Verification**: 
   - TASK includes preconditions and effects for actions in a formal way, while CODE_FUNC mentions success checks for actions but does not specify them in a formal manner.

4. **Environment Setup**: 
   - TASK defines the initial state and objects in a structured way using PDDL, while CODE_FUNC describes the setup in a more general programming context.

5. **Output**: 
   - TASK does not specify any output or feedback mechanism, while CODE_FUNC explicitly mentions printing messages to indicate progress and success.

6. **Error Handling**: 
   - TASK does not address error handling or failure conditions, whereas CODE_FUNC implies that it checks for success and handles outcomes accordingly.

7. **Simulation Aspect**: 
   - TASK is focused on the logical sequence of actions without simulation context, while CODE_FUNC explicitly states that it runs a simulation task.

8. **Recording**: 
   - CODE_FUNC mentions the option to initialize video recording, which is not present in TASK.

9. **Finalization**: 
   - CODE_FUNC ensures the environment is properly shut down at the end of the task, while TASK does not mention any finalization steps.

10. **Level of Detail**: 
    - TASK provides detailed definitions of actions, predicates, and types, while CODE_FUNC provides a high-level overview of the task without delving into the specifics of the actions.

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 =====")
    
    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()

        plate_pos = positions['plate']
        top_drawer_pos = positions['top_anchor_pos']  

        print("[Task] Attempting to pull 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] Drawer pulled successfully!")
        else:
            print("[Task] Failed to pull the drawer.")

        print("[Task] Placing tomato1 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] tomato1 placed successfully!")
        else:
            print("[Task] Failed to place tomato1.")

        print("[Task] Placing tomato2 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] tomato2 placed successfully!")
        else:
            print("[Task] Failed to place tomato2.")

    finally:
        shutdown_environment(env)

    print("===== End of Skeleton Task =====")

if __name__ == "__main__":
    run_skeleton_task()
-------------------

=== Instruction 3 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving object manipulation. 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 drawers and a plate. 

The task consists of three main steps: first, it pulls the top drawer; second, it picks up three tomatoes from specified positions; and finally, it places the tomatoes on a plate. After each step, it checks if the task is completed and prints appropriate messages. Regardless of the outcome, it ensures that the environment is properly shut down at the end of the task. The function is executed when the script is run as the main program.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Nature of Content**: 
   - TASK is a detailed description of a specific action sequence involving object manipulation in a PDDL format, while CODE_FUNC is a high-level description of a function that simulates a task involving object manipulation.

2. **Format**: 
   - TASK is structured in PDDL (Planning Domain Definition Language), which is used for defining planning problems and domains, whereas CODE_FUNC is a narrative description of a function in a programming context.

3. **Level of Detail**: 
   - TASK provides explicit details about the actions, preconditions, and effects in a formalized manner, while CODE_FUNC gives a general overview of the function's purpose and steps without specific implementation details.

4. **Purpose**: 
   - TASK is designed for defining a planning problem for automated reasoning, while CODE_FUNC is intended for executing a simulation of the task in a programming environment.

5. **Action Specification**: 
   - TASK specifies actions like `pick`, `place`, `pull`, and their respective preconditions and effects, while CODE_FUNC describes the overall flow of the task without detailing the individual actions or their conditions.

6. **Execution Context**: 
   - TASK is meant to be interpreted by a planner or a reasoning system, while CODE_FUNC is meant to be executed in a programming environment, likely involving a simulation framework.

7. **State Representation**: 
   - TASK uses predicates to represent the state of the world (e.g., `at`, `holding`, `is-open`), while CODE_FUNC describes the state in terms of object positions and task completion without formal predicates.

8. **Error Handling**: 
   - TASK does not mention error handling or task completion checks, while CODE_FUNC explicitly states that it checks if the task is completed and prints messages accordingly.

9. **Initialization**: 
   - TASK initializes the state through the `:init` section in PDDL, while CODE_FUNC describes an initialization process that may include setting up the environment and video recording.

10. **Execution Trigger**: 
    - TASK does not specify how it is triggered or executed, while CODE_FUNC explicitly states that it runs when the script is executed as the main program.

11. **Output**: 
    - TASK does not specify any output or feedback mechanism, while CODE_FUNC mentions printing messages based on task completion.

12. **Object Interaction**: 
    - TASK describes interactions with objects in a formalized way (e.g., picking up tomatoes), while CODE_FUNC describes these interactions in a more abstract manner without formal action definitions.

13. **Focus on Planning vs. Simulation**: 
    - TASK focuses on the planning aspect of the task, while CODE_FUNC emphasizes the simulation and execution aspect.

14. **Language**: 
    - TASK uses a formal language (PDDL) with specific syntax and semantics, while CODE_FUNC uses natural language to describe the function's behavior.

15. **Complexity**: 
    - TASK is more complex in terms of logical structure and requirements for planning, while CODE_FUNC is simpler and more straightforward in its description of a function.

16. **Object Types**: 
    - TASK defines specific object types and their relationships in a domain context, while CODE_FUNC refers to objects in a more general sense without defining types.

17. **Preconditions and Effects**: 
    - TASK explicitly lists preconditions and effects for each action, while CODE_FUNC does not detail any preconditions or effects for the steps described.

18. **Domain Specificity**: 
    - TASK is specific to a domain (combined-domain) with defined types and predicates, while CODE_FUNC is more general and does not specify a domain.

19. **Action Naming**: 
    - TASK uses specific action names (e.g., `pick-drawer`, `pull`), while CODE_FUNC does not provide specific names for actions, instead describing them in a narrative form.

20. **State Changes**: 
    - TASK describes how the state changes with each action through effects, while CODE_FUNC describes the overall task flow without detailing state changes.

21. **Use of Variables**: 
    - TASK uses variables in a formalized way within the PDDL structure, while CODE_FUNC does not explicitly mention variable usage in its description.

22. **Task Structure**: 
    - TASK has a structured approach to defining tasks with clear sections for actions, predicates, and initial states, while CODE_FUNC has a more free-form narrative structure.

23. **Simulation vs. Planning**: 
    - TASK is focused on planning for future actions based on current states, while CODE_FUNC is focused on simulating actions in a predefined sequence.

24. **Feedback Mechanism**: 
    - TASK does not include any feedback mechanism, while CODE_FUNC includes a mechanism for printing messages based on task completion.

25. **Environment Management**: 
    - TASK does not mention environment management, while CODE_FUNC explicitly states that it ensures proper shutdown of the environment after task execution.

26. **Object Retrieval**: 
    - TASK specifies the retrieval of objects through actions, while CODE_FUNC describes the retrieval in a more abstract manner without detailing the actions involved.

27. **Task Completion**: 
    - TASK does not define what constitutes task completion, while CODE_FUNC explicitly checks for task completion and provides feedback.

28. **Action Order**: 
    - TASK defines a specific order of actions with preconditions, while CODE_FUNC describes a sequence of actions without detailing the order or dependencies.

29. **Use of Angles**: 
    - TASK includes specific angles as parameters for actions, while CODE_FUNC does not mention angles or their significance in the task.

30. **Object Types in Context**: 
    - TASK defines specific object types (e.g., drawer, gripper) in a planning context, while CODE_FUNC refers to objects in a more general context without type definitions.

31. **Task Complexity**: 
    - TASK involves a more complex set of interactions and conditions, while CODE_FUNC simplifies the task into a linear sequence of actions.

32. **Action Preconditions**: 
    - TASK specifies detailed preconditions for each action, while CODE_FUNC does not mention any preconditions for the steps described.

33. **Action Effects**: 
    - TASK specifies the effects of actions in a formalized manner, while CODE_FUNC does not detail the effects of actions.

34. **Object Interaction Details**: 
    - TASK provides detailed interaction mechanics (e.g., holding, moving), while CODE_FUNC abstracts these interactions into a narrative.

35. **Task Execution Context**: 
    - TASK is designed for a planning context, while CODE_FUNC is designed for a programming execution context.

36. **Use of Comments**: 
    - TASK does not include comments or explanations, while CODE_FUNC may include implicit comments through its narrative structure.

37. **Action Naming Conventions**: 
    - TASK uses specific naming conventions for actions to avoid conflicts, while CODE_FUNC does not specify naming conventions.

38. **State Initialization**: 
    - TASK initializes the state through a formalized section, while CODE_FUNC describes initialization in a more general narrative.

39. **Task Description Style**: 
    - TASK uses a formal, structured style, while CODE_FUNC uses a descriptive, narrative style.

40. **Focus on Object Types**: 
    - TASK emphasizes the types of objects and their relationships, while CODE_FUNC focuses on the actions performed with those objects.

41. **Task Flow**: 
    - TASK defines a flow of actions with logical dependencies, while CODE_FUNC describes a flow without detailing dependencies.

42. **Use of Logical Constructs**: 
    - TASK employs logical constructs (e.g., `and`, `not`) to define conditions, while CODE_FUNC does not use such constructs.

43. **Action Parameters**: 
    - TASK specifies parameters for actions in a formalized manner, while CODE_FUNC does not detail parameters for the actions described.

44. **Task Execution Logic**: 
    - TASK does not include execution logic, while CODE_FUNC describes the logic of executing the task in a programming context.

45. **Object Manipulation Details**: 
    - TASK provides detailed descriptions of how objects are manipulated, while CODE_FUNC abstracts these details into a high-level overview.

46. **Task Completion Criteria**: 
    - TASK does not define criteria for task completion, while CODE_FUNC explicitly checks for completion.

47. **Environment Setup**: 
    - TASK does not describe environment setup, while CODE_FUNC includes a description of setting up the environment.

48. **Use of Specific Terms**: 
    - TASK uses specific terms related to planning and actions, while CODE_FUNC uses more general terms related to programming and simulation.

49. **Action Execution**: 
    - TASK does not describe how actions are executed, while CODE_FUNC describes the execution of actions in a simulation context.

50. **Overall Structure**: 
    - TASK has a structured format with sections for actions, predicates, and initial states, while CODE_FUNC has a more free-form narrative structure.

EXACT

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 pick, place, 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 and the plate
        plate_pos = positions['plate']

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

        # Step 2: Pick up all tomatoes
        print("[Task] Picking up tomatoes.")
        for item in ['item1', 'item2', 'item3']:
            item_pos = positions[item]
            obs, reward, done = pick(env, task, item, item_pos)
            if done:
                print(f"[Task] Task ended after picking {item}!")
                return

        # Step 3: Place all tomatoes on the plate
        print("[Task] Placing tomatoes on 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 =====")
-------------------

=== Instruction 4 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving object manipulation. 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 table, a plate, and two tomatoes.

The task consists of a series of steps: first, it pulls a top drawer to unlock a cabinet. Next, it picks the first tomato from the table and places it onto the plate. Then, it repeats the process for the second tomato, picking it from the table and placing it onto the plate as well. After each action, the code checks if the action was successful and prints the corresponding message.

Finally, the environment is shut down to ensure proper cleanup after the task is completed. 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 sequence of actions to achieve a goal (unlocking a cabinet and transferring tomatoes).
   - CODE_FUNC outlines a function that implements a simulation of the task described in TASK.

2. **Structure**: 
   - TASK is presented in a natural language format with clear instructions.
   - CODE_FUNC is structured as a programming function with defined steps and logic.

3. **Detail Level**: 
   - TASK provides high-level instructions without implementation details.
   - CODE_FUNC includes specific programming constructs, such as function calls and condition checks.

4. **Execution Context**: 
   - TASK is a conceptual description of what needs to be done.
   - CODE_FUNC is an executable piece of code that performs the actions described in TASK.

5. **Error Handling**: 
   - TASK does not mention error handling or success checks.
   - CODE_FUNC includes checks for the success of each action and prints messages accordingly.

6. **Initialization**: 
   - TASK assumes an initial state but does not specify how to set it up.
   - CODE_FUNC explicitly initializes the environment and resets the task state.

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

8. **Finalization**: 
   - TASK does not address cleanup or finalization after the task.
   - CODE_FUNC includes a step to shut down the environment after task completion.

9. **Repetition**: 
   - TASK describes a linear sequence of actions without repetition.
   - CODE_FUNC explicitly repeats the process for each tomato, indicating a loop structure.

10. **Language**: 
    - TASK uses natural language.
    - CODE_FUNC uses programming language syntax (e.g., function definitions, control structures).

11. **Object Interaction**: 
    - TASK describes interactions in a general sense.
    - CODE_FUNC specifies the exact sequence of object manipulations and checks.

12. **Output**: 
    - TASK does not specify any output.
    - CODE_FUNC includes print statements to provide feedback on the success of actions.

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 is a detailed implementation of that goal in a programming context.

Refined Code Generated:
-------------------
import numpy as np
from env import setup_environment, shutdown_environment
from skill_code import pick, place, 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 object positions
        plate_pos = positions['plate']
        tomato1_pos = positions['item1']
        tomato2_pos = positions['item2']

        # Step 1: Pull the top drawer to unlock the cabinet
        print("[Task] Pulling the top drawer to unlock the cabinet.")
        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] Drawer pulled successfully!")
        else:
            print("[Task] Failed to pull the drawer.")

        # Step 2: Pick the first tomato from the table
        print("[Task] Picking tomato1 from the table.")
        obs, _, 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] Tomato1 picked successfully!")
        else:
            print("[Task] Failed to pick tomato1.")

        # Step 3: Place the first tomato onto the plate
        print("[Task] Placing tomato1 onto the plate.")
        obs, _, 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] Tomato1 placed successfully!")
        else:
            print("[Task] Failed to place tomato1.")

        # Step 4: Pick the second tomato from the table
        print("[Task] Picking tomato2 from the table.")
        obs, _, 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] Tomato2 picked successfully!")
        else:
            print("[Task] Failed to pick tomato2.")

        # Step 5: Place the second tomato onto the plate
        print("[Task] Placing tomato2 onto the plate.")
        obs, _, 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] Tomato2 placed successfully!")
        else:
            print("[Task] Failed to place tomato2.")

    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 object manipulation. It begins by setting up the environment and resetting the task to its initial state. Video recording is optionally initialized to capture the simulation. The function retrieves the positions of various objects needed for the task.

The task consists of a series of steps: first, it pulls open a bottom drawer, then picks up a tomato from a table, places it on a plate, picks up a second tomato, and finally places that tomato on the plate as well. After each action, the function checks if the task is completed and prints appropriate messages. If the task ends at any step, it exits early. Finally, the environment is shut down to ensure proper cleanup. The function is executed when the script is run directly.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK describes a specific instruction for a robot to perform, while CODE_FUNC outlines a function that implements a simulation of that task.
2. **Structure**: TASK is presented in a natural language format, whereas CODE_FUNC is structured as a programming function with defined steps and logic.
3. **Detail Level**: TASK provides a high-level overview of the actions to be taken, while CODE_FUNC includes detailed procedural steps and checks for task completion.
4. **Execution Context**: TASK is a directive for action, while CODE_FUNC is a script that executes the actions programmatically.
5. **Environment Setup**: CODE_FUNC includes initialization of the environment and optional video recording, which is not mentioned in TASK.
6. **Error Handling**: CODE_FUNC includes checks for task completion and early exit conditions, which are not present in TASK.
7. **Output**: CODE_FUNC specifies that it prints messages after actions, while TASK does not mention any output or feedback mechanism.
8. **Action Sequence**: TASK specifies the actions in a single instruction, while CODE_FUNC breaks down the actions into a sequence of steps with explicit order.
9. **State Management**: CODE_FUNC manages the state of the simulation (e.g., resetting, checking completion), which is not addressed in TASK.

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 =====")
    
    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['item1']
        tomato2_pos = positions['item2']

        print("[Task] Pulling open the bottom drawer.")
        obs, reward, done = pull(env, task, pull_distance=0.1, pull_axis='y')
        if done:
            print("[Task] Task ended after pulling the drawer!")
            return

        print("[Task] Picking tomato1 from the table.")
        obs, reward, done = pick(env, task, target_pos=tomato1_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking tomato1!")
            return

        print("[Task] Placing tomato1 onto the plate.")
        obs, reward, done = place(env, task, target_pos=plate_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after placing tomato1!")
            return

        print("[Task] Picking tomato2 from the table.")
        obs, reward, done = pick(env, task, target_pos=tomato2_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking tomato2!")
            return

        print("[Task] Placing tomato2 onto the plate.")
        obs, reward, done = place(env, task, target_pos=plate_pos, approach_distance=0.15)
        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()
-------------------

