=== Instruction 1 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving a robotic gripper interacting with a drawer. It begins by setting up the environment and resetting the task to its initial state. It optionally initializes video recording for the simulation. The function retrieves the positions of objects in the environment, specifically the positions for the bottom drawer.

The task consists of several key steps: first, the gripper is rotated to the correct orientation; next, it moves to the side position of the bottom drawer; then, it moves to the anchor position of the drawer. After reaching the anchor position, the gripper attempts to pick up the drawer and finally pulls the drawer open by a specified distance. Throughout the process, the function checks if the task is completed after each step and prints appropriate messages. Finally, it ensures that the environment is properly shut down after the task execution.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Nature of Content**: TASK is a formal representation of a planning problem in PDDL, while CODE_FUNC is a description of a procedural function for simulating a task.
2. **Format**: TASK is structured in a domain-specific language (PDDL), whereas CODE_FUNC is written in natural language.
3. **Purpose**: TASK defines the rules and actions for a planning problem, while CODE_FUNC describes the implementation of a simulation task.
4. **Detail Level**: TASK includes specific predicates, actions, and preconditions, while CODE_FUNC provides a high-level overview of the steps involved in the simulation without detailed specifications.
5. **Execution**: TASK is meant to be executed by a planner that interprets PDDL, while CODE_FUNC is intended to be executed as a program or script in a programming environment.
6. **Focus**: TASK focuses on the logical structure and requirements of the task, while CODE_FUNC emphasizes the procedural steps and flow of execution in a simulation context.
7. **State Representation**: TASK explicitly defines the initial state and conditions for actions, while CODE_FUNC describes the process without formal state representation.
8. **Output**: TASK does not specify output messages or feedback, while CODE_FUNC mentions printing messages during execution.

Overall, the two serve different purposes and are structured differently, reflecting their distinct roles in task representation and execution.

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

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

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

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

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

        # Define the positions for the drawers
        bottom_anchor_pos = positions['bottom_anchor_pos']
        side_pos_bottom = positions['bottom_side_pos']

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

        # Step 2: Move to the side position of the bottom drawer
        obs, _, done = move(env, task, target_pos=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
        obs, _, done = move(env, task, target_pos=bottom_anchor_pos)
        if done:
            print("[Task] Task ended after moving to anchor position!")
            return

        # Step 4: Pick the bottom drawer
        obs, _, done = pick(env, task, target_pos=bottom_anchor_pos)
        if done:
            print("[Task] Task ended after picking the drawer!")
            return

        # Step 5: Pull the bottom drawer to open it
        obs, _, done = pull(env, task, pull_distance=0.1)  
        if done:
            print("[Task] Task completed successfully! Drawer opened.")
        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 a robotic gripper interacting with a bottom drawer. 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 relevant objects in the environment.

The task consists of several key steps: first, the gripper is rotated to a specific orientation. Next, the gripper moves to the side position of the bottom drawer, followed by moving to the anchor position of the drawer. The gripper then attempts to pick up the bottom drawer and finally pulls it out a specified distance. After each action, the function checks if the task has completed successfully. Regardless of the outcome, the environment is shut down at the end of the process. The function prints status messages throughout to indicate progress and completion.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Nature of Content**: 
   - TASK is a formal representation of a problem in PDDL (Planning Domain Definition Language) format, defining actions, predicates, and the structure of a planning problem.
   - CODE_FUNC is a descriptive summary of a function that implements a simulation task, detailing the steps and processes involved in executing the task.

2. **Purpose**:
   - TASK is designed to specify the conditions and actions for a planning problem, focusing on the logical structure and requirements for automated planning.
   - CODE_FUNC describes the procedural implementation of a task, focusing on the execution flow and operational details of a simulation.

3. **Level of Abstraction**:
   - TASK operates at a higher level of abstraction, focusing on the logical relationships and requirements of actions without detailing how they are executed.
   - CODE_FUNC provides a lower-level, procedural description that includes specific steps and actions taken by the robotic gripper in a simulation context.

4. **Format**:
   - TASK is structured in a formal syntax specific to PDDL, including definitions, predicates, actions, and parameters.
   - CODE_FUNC is written in natural language, summarizing the function's purpose and steps in a narrative format.

5. **Components**:
   - TASK includes definitions of types, predicates, and actions, which are essential for automated planning systems.
   - CODE_FUNC includes procedural steps, environment setup, and status messages, which are relevant for simulation execution.

6. **Execution Context**:
   - TASK is intended for use in a planning system that can interpret PDDL and generate plans based on the defined actions and predicates.
   - CODE_FUNC is intended for execution in a programming environment where the function can be called to perform the simulation task.

7. **Outcome Representation**:
   - TASK defines the effects of actions in terms of state changes in the planning domain.
   - CODE_FUNC describes the process of checking task completion and printing status messages, focusing on the operational outcome of the simulation.

8. **Interaction with Environment**:
   - TASK specifies the conditions under which actions can be taken based on the state of the environment (e.g., whether a drawer is locked or open).
   - CODE_FUNC describes the actual interaction with the environment, including moving the gripper and pulling the drawer, as part of the simulation.

9. **Focus on Planning vs. Execution**:
   - TASK emphasizes planning and the logical structure needed to derive a sequence of actions.
   - CODE_FUNC emphasizes execution and the practical steps taken to achieve the task in a simulated environment.

10. **Use of Predicates**:
    - TASK uses predicates to define the state of objects and conditions for actions.
    - CODE_FUNC does not explicitly mention predicates but implies their use through the description of actions and conditions in the simulation.

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

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

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

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

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

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

        # Define the positions for the actions
        bottom_side_pos = positions['bottom_side_pos']
        bottom_anchor_pos = positions['bottom_anchor_pos']

        # === Execute the Plan ===
        # Step 1: Rotate the gripper to the correct orientation
        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 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, 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 during move 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 during move to anchor position!")
            return

        # Step 4: Pick the bottom drawer
        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 during pick!")
            return

        # Step 5: Pull the bottom drawer
        print("[Task] Pulling 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 completed successfully! Reward:", reward)
        else:
            print("[Task] Task not completed yet (done=False).")

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

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

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

=== Instruction 3 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving a robotic gripper interacting with a drawer. 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 relevant objects, specifically the drawer and the gripper.

The task consists of several key steps: first, the gripper is rotated to a specific orientation. Next, the gripper moves to the side position of the bottom drawer, followed by moving to the anchor position of the drawer. The gripper then attempts to pick up the bottom drawer and finally pulls the drawer open. After each action, the function checks if the task has completed successfully or if it ended prematurely. Regardless of the outcome, the environment is shut down at the end of the task. The function prints status messages throughout to indicate progress and results.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK defines a domain and problem for a planning scenario, while CODE_FUNC describes a function that executes a simulation of that task.
2. **Structure**: TASK is structured in PDDL (Planning Domain Definition Language) format, whereas CODE_FUNC is written in a programming language (likely Python or similar).
3. **Components**: TASK includes definitions of types, predicates, and actions, while CODE_FUNC focuses on the procedural steps to execute the task.
4. **Execution**: TASK does not execute any actions; it merely defines them. CODE_FUNC actually runs the simulation and performs the actions defined in TASK.
5. **Environment Setup**: TASK specifies the initial state and conditions in a declarative manner, while CODE_FUNC includes procedural steps to set up and reset the environment.
6. **Feedback Mechanism**: TASK does not provide feedback or status updates; CODE_FUNC includes print statements to indicate progress and results.
7. **Completion Check**: TASK does not include any mechanism for checking task completion, while CODE_FUNC checks if the task has completed successfully or ended prematurely.
8. **Video Recording**: TASK does not mention video recording, whereas CODE_FUNC includes an optional step for video recording during the simulation.

In summary, the two are fundamentally different in purpose, structure, and functionality.

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
        task.reset()

        # (Optional) Initialize video writers for capturing your simulation
        init_video_writers(task.get_observation())

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

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

        # Define the positions for the drawer and the gripper
        bottom_anchor_pos = positions['bottom_anchor_pos']
        side_pos_bottom = positions['bottom_side_pos']

        # === Execute the Plan ===
        # Step 1: Rotate the gripper to the correct orientation (90 degrees)
        print("[Task] Rotating gripper to 90 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 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, reward, done = move(env, task, target_pos=side_pos_bottom, max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended during movement!")
            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 during movement!")
            return

        # Step 4: Pick the bottom drawer
        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 during picking!")
            return

        # Step 5: Pull the bottom drawer to open it
        print("[Task] Pulling the bottom drawer to open it.")
        obs, reward, done = pull(env, task, pull_distance=0.1, pull_axis='y', max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
        else:
            print("[Task] Task not completed yet (done=False).")

    finally:
        # 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 to run a simulation task involving a robotic gripper interacting with a drawer. It begins by setting up the environment and resetting the task to its initial state. Video recording is initialized to capture the simulation. The positions of relevant objects, specifically the middle drawer's anchor and side positions, are retrieved.

The task consists of several key steps: first, the gripper is rotated to the correct orientation; next, it moves to the side position of the middle drawer; then, it moves to the anchor position of the drawer. After reaching the anchor position, the gripper picks up the drawer and finally pulls it open by a specified distance. Throughout the process, the task checks if it has completed successfully after each step, providing feedback on the task's status. Finally, the environment is shut down to ensure proper cleanup after the task execution.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK defines a planning domain and problem for unlocking a cabinet by opening a drawer using PDDL (Planning Domain Definition Language).
   - CODE_FUNC describes a procedural function that simulates the task of interacting with a drawer using a robotic gripper.

2. **Format**: 
   - TASK is structured in a formal PDDL format, including definitions of actions, predicates, and types.
   - CODE_FUNC is written in a narrative format, outlining the steps of a simulation without formal syntax.

3. **Components**: 
   - TASK includes specific actions (rotate, move-to-side, move-to-anchor, pick, pull) with defined parameters, preconditions, and effects.
   - CODE_FUNC does not define actions in a formal way but describes the sequence of operations performed in the simulation.

4. **Execution**: 
   - TASK is designed for automated planning and execution in a logical framework, allowing for reasoning about actions and states.
   - CODE_FUNC describes a step-by-step execution of a simulation, focusing on the procedural aspect rather than logical planning.

5. **Feedback Mechanism**: 
   - TASK does not include a feedback mechanism; it is focused on defining the actions and their effects.
   - CODE_FUNC includes a feedback mechanism that checks the success of each step and provides status updates.

6. **Environment Setup**: 
   - TASK defines the initial state and conditions for the planning problem.
   - CODE_FUNC describes the setup of the simulation environment and the initialization of video recording.

7. **Finalization**: 
   - TASK does not mention any cleanup or finalization process.
   - CODE_FUNC explicitly states that the environment is shut down after task execution to ensure proper cleanup.

8. **Level of Abstraction**: 
   - TASK operates at a higher level of abstraction, focusing on the logical relationships and requirements for task completion.
   - CODE_FUNC operates at a lower level, detailing the specific procedural steps taken during the simulation.

9. **Use of Objects**: 
   - TASK defines objects in terms of their roles within the planning domain (e.g., drawer, gripper).
   - CODE_FUNC refers to objects in a more practical context, focusing on their positions and interactions during the simulation.

10. **Language**: 
    - TASK uses a formal language specific to planning and AI.
    - CODE_FUNC uses natural language to describe the simulation process.

11. **Focus on Actions**: 
    - TASK emphasizes the logical structure of actions and their interdependencies.
    - CODE_FUNC emphasizes the sequence and execution of actions in a simulation context.

12. **State Representation**: 
    - TASK represents states through predicates and logical conditions.
    - CODE_FUNC represents states through procedural checks and updates during the simulation.

13. **Interaction with Environment**: 
    - TASK defines how the gripper interacts with the drawer in a logical sense.
    - CODE_FUNC describes the physical interaction in a simulation, including movement and manipulation.

14. **Complexity**: 
    - TASK is more complex in terms of logical structure and planning requirements.
    - CODE_FUNC is more straightforward, focusing on the execution of a series of steps.

15. **Outcome**: 
    - TASK aims to define a successful plan for unlocking a cabinet.
    - CODE_FUNC aims to successfully execute a simulation of the task and provide feedback on its completion.

16. **Error Handling**: 
    - TASK does not address error handling or failure conditions.
    - CODE_FUNC implies a mechanism for checking success and potentially handling errors during execution.

17. **Temporal Aspect**: 
    - TASK does not explicitly address the timing of actions.
    - CODE_FUNC implies a temporal sequence of actions that occur in a specific order during the simulation.

18. **User Interaction**: 
    - TASK does not involve user interaction; it is a purely logical definition.
    - CODE_FUNC may involve user interaction in terms of monitoring the simulation and receiving feedback.

19. **Simulation vs. Planning**: 
    - TASK is focused on planning and reasoning about actions.
    - CODE_FUNC is focused on simulating the execution of those actions in a controlled environment.

20. **Implementation Detail**: 
    - TASK does not provide implementation details; it is a high-level description.
    - CODE_FUNC provides implementation details about how the simulation is set up and executed.

21. **Goal Specification**: 
    - TASK specifies goals in terms of logical states (e.g., drawer is open).
    - CODE_FUNC does not explicitly state goals but implies them through the sequence of actions.

22. **State Changes**: 
    - TASK defines state changes through effects of actions.
    - CODE_FUNC describes state changes as part of the procedural execution of the simulation.

23. **Reusability**: 
    - TASK can be reused in different planning scenarios with different initial states.
    - CODE_FUNC is specific to the described simulation and may not be easily reusable without modification.

24. **Scalability**: 
    - TASK can be scaled to include more complex scenarios and additional actions.
    - CODE_FUNC may require significant changes to scale to more complex scenarios.

25. **Documentation**: 
    - TASK serves as documentation for a planning domain.
    - CODE_FUNC serves as documentation for a specific simulation procedure.

26. **Focus on Logic vs. Procedure**: 
    - TASK focuses on the logical relationships and requirements for actions.
    - CODE_FUNC focuses on the procedural steps and execution flow of the simulation.

27. **Abstraction Level**: 
    - TASK operates at a higher level of abstraction, suitable for AI planning.
    - CODE_FUNC operates at a lower level, suitable for implementation in a programming context.

28. **Task Definition**: 
    - TASK defines a task in terms of logical actions and states.
    - CODE_FUNC defines a task in terms of procedural steps and execution.

29. **State Initialization**: 
    - TASK initializes states through the PDDL init section.
    - CODE_FUNC initializes states through procedural setup in the simulation.

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

31. **Logical vs. Physical Representation**: 
    - TASK represents actions and states logically.
    - CODE_FUNC represents actions and states physically in a simulation context.

32. **Dependency on External Libraries**: 
    - TASK does not depend on external libraries; it is self-contained in PDDL.
    - CODE_FUNC may depend on simulation libraries or frameworks for execution.

33. **Execution Environment**: 
    - TASK does not specify an execution environment; it is abstract.
    - CODE_FUNC specifies an execution environment for the simulation.

34. **Task Complexity**: 
    - TASK can represent complex tasks with multiple actions and states.
    - CODE_FUNC may simplify the task for simulation purposes.

35. **State Transition Representation**: 
    - TASK uses logical predicates to represent state transitions.
    - CODE_FUNC uses procedural steps to represent state transitions.

36. **Action Preconditions**: 
    - TASK defines preconditions for actions in a formal manner.
    - CODE_FUNC does not explicitly define preconditions but implies them through the sequence of actions.

37. **Action Effects**: 
    - TASK defines effects of actions in a formal manner.
    - CODE_FUNC describes effects in a narrative context without formal definitions.

38. **Task Execution Monitoring**: 
    - TASK does not include monitoring of task execution.
    - CODE_FUNC includes monitoring of task execution and feedback on success.

39. **Task Resetting**: 
    - TASK does not include a mechanism for resetting the task.
    - CODE_FUNC includes a step for resetting the task to its initial state.

40. **Simulation Focus**: 
    - TASK is not focused on simulation; it is focused on planning.
    - CODE_FUNC is entirely focused on simulating the task execution.

41. **User Feedback**: 
    - TASK does not provide user feedback mechanisms.
    - CODE_FUNC provides feedback on the status of the task execution.

42. **Task Completion Criteria**: 
    - TASK does not specify completion criteria beyond logical states.
    - CODE_FUNC implies completion criteria through procedural checks after each step.

43. **Action Sequencing**: 
    - TASK does not define the sequence of actions explicitly; it is implied through logical dependencies.
    - CODE_FUNC explicitly defines the sequence of actions to be taken during the simulation.

44. **Error Reporting**: 
    - TASK does not include error reporting mechanisms.
    - CODE_FUNC implies error reporting through feedback on task status.

45. **Task Adaptability**: 
    - TASK can be adapted for different planning scenarios.
    - CODE_FUNC may require significant changes to adapt to different scenarios.

46. **State Representation Complexity**: 
    - TASK uses a more complex representation of states through predicates.
    - CODE_FUNC uses a simpler representation of states through procedural checks.

47. **Action Definition Detail**: 
    - TASK provides detailed definitions for each action.
    - CODE_FUNC provides a high-level overview of actions without detailed definitions.

48. **Task Execution Flow**: 
    - TASK does not define an execution flow; it is a logical representation.
    - CODE_FUNC defines a clear execution flow for the simulation.

49. **Task Initialization**: 
    - TASK initializes the task through PDDL definitions.
    - CODE_FUNC initializes the task through procedural setup.

50. **Focus on Planning vs. Execution**: 
    - TASK focuses on planning and logical reasoning.
    - CODE_FUNC focuses on execution and procedural steps.

EXACT

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

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

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

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

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

        # Define the positions for the drawers
        middle_anchor_pos = positions['middle_anchor_pos']
        side_pos_middle = positions['middle_side_pos']

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

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

        # Step 3: Move to the anchor position of the middle drawer
        obs, _, done = move(env, task, target_pos=middle_anchor_pos)
        if done:
            print("[Task] Task ended after moving to anchor position!")
            return

        # Step 4: Pick the middle drawer
        obs, _, done = pick(env, task, target_pos=middle_anchor_pos)
        if done:
            print("[Task] Task ended after picking the drawer!")
            return

        # Step 5: Pull the middle drawer to open it
        obs, _, done = pull(env, task, pull_distance=0.1)  
        if done:
            print("[Task] Task completed successfully! Drawer is now open.")
        else:
            print("[Task] Task not completed yet (done=False).")

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

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

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

=== Instruction 5 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving a robotic gripper interacting with a drawer. It begins by setting up the environment and resetting the task to its initial state. Video recording is optionally initialized to capture the simulation. The function retrieves the positions of various objects, specifically the positions of the drawers.

The task consists of several key steps: first, the gripper is rotated to a ninety-degree angle. Next, the gripper moves to the side position of the middle drawer, followed by moving to the anchor position of the same drawer. The gripper then attempts to pick up the middle drawer and finally pulls it to open it. After each step, the function checks if the task is completed and prints appropriate messages. At the end of the task, the environment is shut down properly. The overall behavior is to simulate the process of opening a drawer using a robotic gripper.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK describes a specific instruction for a robotic gripper to open a drawer, while CODE_FUNC outlines a function that simulates the entire process of interacting with the drawer, including setup and completion checks.
2. **Detail Level**: TASK provides a high-level instruction without implementation details, whereas CODE_FUNC includes specific steps and actions taken during the simulation.
3. **Context**: TASK is presented in a PDDL format, which is used for planning in AI, while CODE_FUNC is a narrative description of a function's behavior in a programming context.
4. **Execution**: TASK does not specify how the actions are executed, while CODE_FUNC describes the sequence of actions and checks performed during the simulation.
5. **Initialization**: CODE_FUNC mentions initializing the environment and optionally recording video, which is not addressed in TASK.
6. **Completion Check**: CODE_FUNC includes a mechanism to check if the task is completed and print messages, which is absent in TASK.
7. **Action Sequence**: TASK lists actions in a PDDL format, while CODE_FUNC describes the actions in a narrative format, detailing the order and purpose of each action.
8. **Environment Shutdown**: CODE_FUNC mentions shutting down the environment at the end of the task, which is not mentioned in TASK.

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

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

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

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

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

        # Define the positions for the drawers
        middle_anchor_pos = positions['middle_anchor_pos']

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

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

        # Step 5: Pull the middle drawer to open it
        print("[Task] Pulling the middle drawer to open it.")
        obs, reward, done = pull(env, task, pull_distance=0.1, pull_axis='y', max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
        else:
            print("[Task] Task not completed yet (done=False).")

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

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

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

