=== 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. 

The function retrieves the positions of various objects, including two tomatoes and a plate. It then executes a series of steps: rotating the gripper, moving to specific positions, picking and pulling a drawer, and picking and placing two tomatoes onto a plate. After each action, it checks if the task is completed and exits if so. 

Finally, the environment is shut down properly, and the task's completion is indicated. 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 a sequence of actions involving opening a drawer and placing tomatoes on a plate.
   - **CODE_FUNC**: Describes a function that simulates the execution of a robotic task, including setup, execution, and shutdown processes.

2. **Detail Level**: 
   - **TASK**: Provides a high-level instruction without implementation details.
   - **CODE_FUNC**: Includes implementation details such as environment setup, video recording, and checking task completion.

3. **Action Specification**: 
   - **TASK**: Specifies actions in a sequential manner (open drawer, put tomatoes on plate).
   - **CODE_FUNC**: Describes a series of steps that include rotating the gripper, moving to positions, and performing actions like picking and placing.

4. **Context**: 
   - **TASK**: Focuses on a specific scenario involving tomatoes and a plate.
   - **CODE_FUNC**: Generalizes the task to a function that can be executed in a simulation environment.

5. **Execution Flow**: 
   - **TASK**: Implies a linear execution of actions based on the instruction.
   - **CODE_FUNC**: Describes a more complex flow that includes checking for task completion and handling the environment.

6. **Output Handling**: 
   - **TASK**: Does not mention any output or feedback mechanism.
   - **CODE_FUNC**: Mentions capturing video recordings and indicating task completion.

7. **Environment Management**: 
   - **TASK**: Does not address the management of the simulation environment.
   - **CODE_FUNC**: Includes steps for setting up and shutting down the environment.

8. **Object Interaction**: 
   - **TASK**: Focuses on the interaction with tomatoes and a plate.
   - **CODE_FUNC**: Involves multiple interactions, including with the gripper and drawer, and specifies the order of operations.

9. **Functionality**: 
   - **TASK**: Represents a single task instruction.
   - **CODE_FUNC**: Represents a complete function that can be executed, including multiple tasks and checks.

10. **Implementation**: 
    - **TASK**: Does not provide any implementation details or code.
    - **CODE_FUNC**: Contains code that implements the task in a simulation environment.

In summary, the semantic differences between TASK and CODE_FUNC are significant, as TASK is a high-level instruction while CODE_FUNC is a detailed implementation of a robotic simulation 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 =====")
    
    # === 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
        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 bottom drawer
        print("[Task] Moving to side position of the bottom drawer.")
        obs, reward, done = move(env, task, target_pos=positions['side-pos-bottom'])
        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=positions['anchor-pos-bottom'])
        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 the bottom drawer
        print("[Task] Pulling the bottom 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 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 tomatoes and a plate.

The task consists of a series of steps where the robot performs specific actions. First, it rotates its gripper, then moves to the side and anchor positions of a bottom drawer. After that, it picks up the drawer and pulls it open. The robot then picks up two tomatoes sequentially and places each one onto a plate.

Throughout the process, the function checks if each action is completed successfully, and it prints messages indicating the progress of the task. Finally, the environment is shut down properly after the task is completed or if an error occurs. The function concludes by printing the end of the task.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Nature of Content**: 
   - TASK is a formal representation of a robotic task using PDDL (Planning Domain Definition Language), which includes definitions of actions, predicates, and the environment.
   - CODE_FUNC is a descriptive summary of a function that simulates a robotic task, detailing the steps and actions taken in a more narrative form.

2. **Level of Abstraction**:
   - TASK operates at a high level of abstraction, focusing on the logical structure and requirements of the task.
   - CODE_FUNC provides a lower-level, procedural description of how the task is executed in a programming context.

3. **Syntax and Structure**:
   - TASK uses PDDL syntax, which includes specific keywords and constructs for defining domains, actions, and predicates.
   - CODE_FUNC uses natural language and programming terminology to describe the function and its operations.

4. **Focus on Execution**:
   - TASK emphasizes the planning aspect, detailing preconditions and effects of actions without specifying how they are executed.
   - CODE_FUNC emphasizes the execution of the task, including the sequence of actions and checks for successful completion.

5. **Error Handling**:
   - TASK does not mention error handling or success checks explicitly; it focuses on the logical flow of actions.
   - CODE_FUNC includes references to checking the success of actions and handling errors during the task execution.

6. **Output and Feedback**:
   - TASK does not provide any feedback or output mechanisms; it is purely a planning document.
   - CODE_FUNC mentions printing messages to indicate progress, which implies a feedback mechanism during execution.

7. **Initialization and Environment Setup**:
   - TASK includes initialization of objects and their states in a declarative manner.
   - CODE_FUNC describes the initialization process in a procedural way, including setting up video recording capabilities.

8. **Sequential vs. Parallel Actions**:
   - TASK does not specify the order of actions beyond their logical dependencies.
   - CODE_FUNC outlines a specific sequence of actions that the robot takes, indicating a clear order of operations.

9. **Terminology**:
   - TASK uses specific terminology related to planning and robotics (e.g., predicates, actions, preconditions).
   - CODE_FUNC uses more general programming and task-related terminology (e.g., "rotate," "move," "pick up," "pull open").

10. **Contextual Information**:
    - TASK is context-free in terms of execution; it does not provide information about the environment beyond the initial state.
    - CODE_FUNC provides contextual information about the environment and the actions taken within it, including the robot's interactions with objects.

In summary, the semantic differences between TASK and CODE_FUNC are significant, reflecting their distinct purposes and formats in representing a robotic task.

Refined Code Generated:
-------------------
import numpy as np
from env import setup_environment, shutdown_environment
from skill_code import *
from video import init_video_writers, recording_step, recording_get_observation
from object_positions import get_object_positions

def run_skeleton_task():
    '''Generic skeleton for running any task in your simulation.'''
    print("===== Starting Skeleton Task =====")
    
    # === Environment Setup ===
    env, task = setup_environment()
    try:
        # Reset the task to its initial state
        _, obs = task.reset()

        # (Optional) Initialize video writers for capturing your simulation
        init_video_writers(obs)

        # Wrap the task steps for recording (if needed)
        original_step = task.step
        task.step = recording_step(original_step)
        original_get_obs = task.get_observation
        task.get_observation = recording_get_observation(original_get_obs)

        # === Retrieve Object Positions ===
        positions = get_object_positions()

        # Define 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 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 onto the plate
        print("[Task] Placing the first tomato onto 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 onto the plate
        print("[Task] Placing the second tomato onto 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 3 ===
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, including a drawer and two tomatoes.

The task consists of a series of steps where the robot performs actions in a specific order. It rotates its gripper, moves to the side and anchor positions of a bottom drawer, picks up the drawer, and pulls it out. Then, it picks up the first tomato and places it on a plate, followed by picking up the second tomato and placing it on the plate as well.

After each action, the function checks if the task has ended prematurely. Finally, it ensures that the environment is properly shut down before concluding the task. The overall behavior is to simulate a sequence of robotic manipulations involving picking and placing objects.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Nature of Content**: 
   - TASK is a formal representation of a robotic task using PDDL (Planning Domain Definition Language), while CODE_FUNC is a description of a function that simulates a task in a robotic environment.

2. **Format**: 
   - TASK is structured in a domain and problem definition format, including types, predicates, and actions, whereas CODE_FUNC is a narrative description of the function's behavior and steps.

3. **Level of Detail**: 
   - TASK provides detailed specifications of actions, preconditions, and effects, while CODE_FUNC gives a high-level overview of the task without specific details on preconditions or effects.

4. **Purpose**: 
   - TASK is designed for planning and execution in a robotic system, focusing on the logical structure of actions, while CODE_FUNC describes the implementation of a simulation of the task.

5. **Execution Context**: 
   - TASK is intended for use in a planning system that can interpret PDDL, while CODE_FUNC is meant for execution in a programming environment that simulates the task.

6. **Action Specification**: 
   - TASK explicitly defines actions with parameters, preconditions, and effects, while CODE_FUNC describes actions in a sequential manner without formal definitions.

7. **State Representation**: 
   - TASK uses predicates to represent the state of the world, while CODE_FUNC describes the state in terms of object positions and robot actions without formal predicate logic.

8. **Error Handling**: 
   - CODE_FUNC includes checks for premature task termination, which is not represented in TASK.

9. **Initialization**: 
   - CODE_FUNC mentions initializing video recording and resetting the task state, which is not addressed in TASK.

10. **Object Interaction**: 
    - TASK focuses on the logical relationships and conditions for actions, while CODE_FUNC describes the physical sequence of actions performed by the robot.

11. **Output**: 
    - TASK does not specify an output, while CODE_FUNC implies a simulation output through the completion of the task.

12. **Robotic Manipulation**: 
    - TASK outlines the logical framework for robotic manipulation, while CODE_FUNC describes the actual sequence of manipulations performed by the robot.

13. **Terminology**: 
    - TASK uses specific PDDL terminology (e.g., predicates, actions, preconditions), while CODE_FUNC uses more general programming and simulation terminology.

14. **Focus on Planning vs. Execution**: 
    - TASK is focused on planning the actions to achieve a goal, while CODE_FUNC is focused on executing those actions in a simulated environment.

15. **Complexity**: 
    - TASK is more complex in terms of logical structure and formalism, while CODE_FUNC is simpler and more straightforward in its description of the task.

16. **Environment Setup**: 
    - TASK does not detail the setup of the environment, while CODE_FUNC explicitly mentions setting up the environment for the simulation.

17. **Task Completion**: 
    - TASK does not define what constitutes task completion, while CODE_FUNC implies a conclusion to the task after all actions are performed.

18. **Sequential vs. Parallel Actions**: 
    - TASK does not specify the order of actions beyond logical dependencies, while CODE_FUNC describes a specific sequential order of actions.

19. **Use of Variables**: 
    - TASK uses variables in a formal way to define actions and states, while CODE_FUNC describes variables in a more informal context related to the simulation.

20. **Robotic State Management**: 
    - TASK focuses on the logical state of the robot and objects, while CODE_FUNC emphasizes the operational state during the simulation.

21. **Action Naming**: 
    - TASK includes specific action names and their definitions, while CODE_FUNC refers to actions in a more general sense without formal naming conventions.

22. **Preconditions and Effects**: 
    - TASK explicitly states preconditions and effects for each action, while CODE_FUNC does not detail these aspects.

23. **Simulation vs. Planning**: 
    - TASK is oriented towards planning for robotic actions, while CODE_FUNC is oriented towards simulating those actions in a controlled environment.

24. **Language**: 
    - TASK uses a formal language (PDDL), while CODE_FUNC uses natural language to describe the function.

25. **Focus on Objects**: 
    - TASK defines objects and their relationships in a formal manner, while CODE_FUNC describes objects in the context of actions without formal definitions.

26. **Robotic Control**: 
    - TASK outlines the logical control of the robot through planning, while CODE_FUNC describes the control flow of the function in a programming context.

27. **Task Steps**: 
    - TASK does not enumerate steps in a linear fashion, while CODE_FUNC describes a clear sequence of steps taken by the robot.

28. **Feedback Mechanism**: 
    - CODE_FUNC implies a feedback mechanism for checking task completion, which is not present in TASK.

29. **Action Dependencies**: 
    - TASK defines dependencies through preconditions, while CODE_FUNC describes dependencies through the sequence of actions.

30. **Robotic Environment**: 
    - TASK does not specify the environment setup, while CODE_FUNC describes the environment as part of the simulation process.

31. **Task Resetting**: 
    - CODE_FUNC mentions resetting the task, which is not a concept present in TASK.

32. **Video Recording**: 
    - CODE_FUNC includes an optional video recording feature, which is not mentioned in TASK.

33. **Finalization**: 
    - CODE_FUNC includes a finalization step to shut down the environment, which is not addressed in TASK.

34. **Object Retrieval**: 
    - TASK specifies the logical conditions for retrieving objects, while CODE_FUNC describes the physical act of retrieving objects in a sequence.

35. **Gripper Movement**: 
    - TASK defines the gripper's actions in terms of logical predicates, while CODE_FUNC describes the movement of the gripper in a more operational context.

36. **Task Complexity**: 
    - TASK may involve more complex planning scenarios, while CODE_FUNC focuses on a straightforward execution of a defined task.

37. **Action Parameters**: 
    - TASK specifies parameters for actions in a formal way, while CODE_FUNC describes actions without formal parameterization.

38. **State Changes**: 
    - TASK defines state changes through effects, while CODE_FUNC describes state changes in the context of actions performed.

39. **Robotic Behavior**: 
    - TASK outlines the logical behavior of the robot, while CODE_FUNC describes the actual behavior in a simulation.

40. **Task Description**: 
    - TASK is a formal task description for planning, while CODE_FUNC is a procedural description for execution.

41. **Object Interaction Logic**: 
    - TASK provides logical rules for object interaction, while CODE_FUNC describes the interaction in a practical context.

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

43. **Task Flow**: 
    - TASK does not specify a flow of actions, while CODE_FUNC outlines a clear flow of actions to complete the task.

44. **Robotic Task Definition**: 
    - TASK defines a robotic task in a planning context, while CODE_FUNC defines a task in a simulation context.

45. **Task Environment**: 
    - TASK does not specify the environment in which the task is performed, while CODE_FUNC describes the environment setup for the simulation.

46. **Action Logic**: 
    - TASK focuses on the logical structure of actions, while CODE_FUNC focuses on the practical implementation of those actions.

47. **Task Execution Context**: 
    - TASK is designed for a planning context, while CODE_FUNC is designed for a simulation context.

48. **Action Order**: 
    - TASK does not enforce a specific order of actions beyond logical dependencies, while CODE_FUNC specifies a strict order of actions.

49. **Task Completion Criteria**: 
    - TASK does not define criteria for task completion, while CODE_FUNC implies completion through the successful execution of all actions.

50. **Robotic Manipulation Framework**: 
    - TASK provides a framework for robotic manipulation, while CODE_FUNC provides a specific implementation of that framework in a simulation.

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 *
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 90 degrees.")
        obs, _, 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 during rotation!")
            return

        # Step 2: Move to the side position of the bottom drawer
        print("[Task] Moving to 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 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', 'anchor-pos-bottom')
        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.2)
        if done:
            print("[Task] Task ended during pulling drawer!")
            return

        # Step 6: Pick the first tomato
        print("[Task] Picking up tomato1.")
        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 tomato1 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 tomato2.")
        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 tomato2 on the plate.")
        obs, _, done = place(env, task, plate_pos)
        if done:
            print("[Task] Task ended during 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 4 ===
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 function initializes video recording capabilities and 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 first rotates its gripper, then moves to the side and anchor positions of a bottom drawer. After that, it picks up the drawer and pulls it out. The robot then picks the first tomato, places it on a plate, and repeats the process for a second tomato.

At each step, the function checks if the task is completed and prints messages indicating the progress. Finally, it ensures that the environment is properly shut down after the task is finished. The overall behavior is to simulate a sequence of object manipulation tasks in a controlled environment.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Nature of Content**: 
   - TASK is a formal representation of a robotic task using PDDL (Planning Domain Definition Language), while CODE_FUNC is a description of a function that simulates a robotic task in a programming context.

2. **Structure**: 
   - TASK is structured in a domain/problem format with types, predicates, and actions defined in PDDL, whereas CODE_FUNC is a narrative description of a function's behavior without formal syntax.

3. **Level of Detail**: 
   - TASK provides detailed specifications of actions, preconditions, and effects, while CODE_FUNC gives a high-level overview of the task without specific details on preconditions or effects.

4. **Purpose**: 
   - TASK is intended for planning and execution in a robotic system, focusing on the logical structure of actions, while CODE_FUNC describes the simulation of the task, focusing on the procedural execution of actions.

5. **Execution Context**: 
   - TASK is designed for a planning system that can interpret PDDL, while CODE_FUNC is likely intended for a programming environment that executes the described function.

6. **Action Representation**: 
   - In TASK, actions are defined with specific parameters and logical conditions, while CODE_FUNC describes actions in a more abstract manner without formal parameterization.

7. **Environment Setup**: 
   - TASK includes an explicit definition of the initial state and conditions of the environment, while CODE_FUNC mentions environment setup but does not detail the initial state in a formal way.

8. **Feedback Mechanism**: 
   - CODE_FUNC includes a mechanism for printing progress messages, which is not present in TASK, where the focus is on logical conditions rather than user feedback.

9. **Completion Check**: 
   - CODE_FUNC explicitly checks for task completion at each step, while TASK does not include such a mechanism, focusing instead on the logical flow of actions.

10. **Shutdown Procedure**: 
    - CODE_FUNC mentions ensuring the environment is properly shut down after task completion, which is not addressed in TASK.

11. **Use of Video Recording**: 
    - CODE_FUNC includes the initialization of video recording capabilities, which is not mentioned in TASK.

12. **Terminology**: 
    - TASK uses specific PDDL terminology (e.g., predicates, actions, preconditions), while CODE_FUNC uses more general programming terminology (e.g., function, steps, messages).

13. **Focus on Object Manipulation**: 
    - While both involve object manipulation, TASK emphasizes the logical conditions for actions, whereas CODE_FUNC emphasizes the sequence and procedural aspects of the manipulation.

14. **Robotic Control**: 
    - TASK is focused on the planning aspect of robotic control, while CODE_FUNC is focused on the execution aspect of a robotic simulation.

15. **Language**: 
    - TASK is written in a formal language (PDDL), while CODE_FUNC is written in a natural language description of a function.

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

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

        print("[Task] Rotating gripper to ninety degrees.")
        obs, reward, done = rotate(env, task, target_quat=np.array([0, 0, 1, 0]), max_steps=100, threshold=0.05, timeout=10.0)
        if done:
            print("[Task] Task ended after rotating the gripper!")
            return

        print("[Task] Moving to side position of the bottom drawer.")
        obs, reward, done = move(env, task, target_pos=positions['side-pos-bottom'], max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended after moving to side position!")
            return

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

        print("[Task] Picking the bottom drawer.")
        obs, reward, done = pick(env, task, target_pos=bottom_anchor_pos, approach_distance=0.15, max_steps=100, threshold=0.01, approach_axis='z', timeout=10.0)
        if done:
            print("[Task] Task ended after picking the drawer!")
            return

        print("[Task] Pulling the bottom drawer.")
        obs, reward, done = pull(env, task, pull_distance=0.2, pull_axis='x', max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended after pulling the drawer!")
            return

        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

        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

        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

        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:
        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. 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 gripper performs specific actions. First, it rotates to a specified angle, then moves to the side and anchor positions of a bottom drawer. Next, it picks up the drawer and pulls it open. After that, the gripper 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, the task checks if it has completed successfully. If any step results in completion, the task ends early. Finally, the environment is shut down properly, and the task concludes.
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 the TASK in a programming context.

2. **Structure**: 
   - TASK is presented in a natural language format with a clear sequence of actions.
   - 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 performed without technical specifics.
   - CODE_FUNC includes detailed procedural steps, including environment setup, action execution, and success checks.

4. **Execution Context**: 
   - TASK is a standalone instruction meant for a robot to follow.
   - CODE_FUNC is part of a larger codebase that likely interacts with a simulation environment.

5. **Outcome Handling**: 
   - TASK does not specify how to handle outcomes or errors.
   - CODE_FUNC includes checks for successful completion of actions and early termination of the task if needed.

6. **Environment Interaction**: 
   - TASK implies interaction with physical objects (drawers, tomatoes, plate) but does not detail the environment.
   - CODE_FUNC explicitly mentions setting up the environment and resetting it to an initial state.

7. **Recording**: 
   - TASK does not mention any form of recording or monitoring.
   - CODE_FUNC includes the option to capture video recordings of the simulation.

8. **Action Sequence**: 
   - TASK lists actions in a straightforward manner.
   - CODE_FUNC describes a more complex sequence of actions with specific order and conditions.

9. **Technical Language**: 
   - TASK uses everyday language to describe actions.
   - CODE_FUNC uses technical programming terminology and structure.

10. **Focus**: 
    - TASK focuses on what needs to be done.
    - CODE_FUNC focuses on how to implement those actions programmatically.

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

        # Step 2: Move to the side position of the bottom drawer
        print("[Task] Moving gripper to side position of the bottom drawer.")
        obs, reward, done = move(env, task, target_pos=positions['side-pos-bottom'])
        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 gripper to anchor position of the bottom drawer.")
        obs, reward, done = move(env, task, target_pos=positions['anchor-pos-bottom'])
        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 the bottom drawer open
        print("[Task] Pulling the bottom 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
        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()
-------------------

