=== Instruction 1 ===
Is Correct: False
Syntax Pass: False
Code Function: This code controls a robot to perform a two-step task involving a drawer. First, the robot picks up the bottom handle of a drawer from the floor by approaching it along the x-axis. Next, the robot pulls the drawer open using the same handle, again approaching along the x-axis and moving it by a specified distance. Any errors during these actions are caught and printed.
Similarity: {'ok': True, 'reason': "The described code picks up a handle and pulls open an unlocked, closed drawer, which matches the domain's requirements for opening a drawer."}
Differences: 1. **Scope of Action**  
   - **TASK**: The instruction is to "Open one drawer," which is semantically agnostic to *how* the drawer is opened, what objects are involved, or which drawer is chosen (as long as one is opened).
   - **CODE_FUNC**: The code specifically opens the "bottom" drawer by first picking up the "bottom handle" from the floor and then using it to open the "bottom" drawer. The drawer is chosen explicitly.

2. **Object Manipulation**  
   - **TASK**: Does not specify any requirement to pick up a handle or manipulate any object other than the drawer itself.
   - **CODE_FUNC**: Requires the robot to pick up a handle object from the floor before opening the drawer, implying the handle is a necessary intermediary.

3. **Preconditions**  
   - **TASK**: Does not mention environmental preconditions (e.g., lighting, robot location, hand state).
   - **CODE_FUNC**: Implicitly assumes the robot must approach the handle and the drawer along the x-axis, and that the handle is on the floor and must be picked up first.

4. **Drawer Selection**  
   - **TASK**: "One drawer" is generic; any drawer could be opened.
   - **CODE_FUNC**: Only the "bottom" drawer is targeted.

5. **Error Handling**  
   - **TASK**: No mention of error handling or contingencies.
   - **CODE_FUNC**: Explicitly catches and prints errors during the pick and pull actions.

6. **Level of Abstraction**  
   - **TASK**: High-level, goal-oriented instruction.
   - **CODE_FUNC**: Low-level, stepwise procedure specifying the sequence of actions and the objects involved.

7. **Assumptions about Environment**  
   - **TASK**: No assumptions about the state of the room (e.g., lighting).
   - **CODE_FUNC**: Implicitly assumes the robot can see and interact with the handle and drawer (e.g., room is bright enough, robot is at the correct location).

8. **Action Sequence**  
   - **TASK**: Only requires the end state (drawer open).
   - **CODE_FUNC**: Requires a specific sequence: approach handle, pick handle, approach drawer, pull drawer.

9. **Use of Handle**  
   - **TASK**: Does not mention a handle.
   - **CODE_FUNC**: Opening the drawer is only possible via the handle, which must be picked up first.

10. **Physical Approach Direction**  
    - **TASK**: No mention of approach direction.
    - **CODE_FUNC**: Specifies approach along the x-axis for both picking and pulling.

11. **Drawer State**  
    - **TASK**: Does not specify the initial state of the drawer (locked/unlocked, open/closed).
    - **CODE_FUNC**: Assumes the drawer is closed and unlocked, and the handle is on the floor.

12. **Multiplicity**  
    - **TASK**: "One drawer" could be any; does not specify which if multiple are available.
    - **CODE_FUNC**: Only the bottom drawer is considered.

---

**Summary:**  
The main semantic differences are in specificity (drawer and handle selection), required action sequence, environmental and object preconditions, and error handling. The TASK is a high-level, generic instruction, while the CODE_FUNC is a concrete, low-level implementation for a specific drawer and handle.

Refined Code Generated:
-------------------
from Object_list import Object
from skill_mapping import RobotController

def open_one_drawer():
    """
    Opens any one available drawer.
    """
    robot = RobotController()
    # Choose a drawer to open; here, we select the bottom drawer as an example.
    drawer = "drawer_bottom"
    handle = "handle_bottom"

    # Ensure the room is bright
    if robot.is_room_dark():
        robot.execute_push_switch(Object["light_switch"], Object["ready-pose"])

    # Move to the handle location if not already there
    if not robot.is_at_location(Object["drawer-area"]):
        robot.execute_go(Object["ready-pose"], Object["drawer-area"])

    # Pick up the handle if not already holding it
    if not robot.is_holding(Object[handle]):
        if not robot.is_hand_empty():
            robot.release_object()
        robot.execute_pick(Object[handle], Object["drawer-area"])

    # Open the drawer if it is closed and unlocked
    if robot.is_drawer_closed(drawer) and robot.is_drawer_unlocked(drawer):
        robot.execute_pull(Object[drawer + "_handle"], Object[handle], Object["drawer-area"])

def main():
    open_one_drawer()

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

=== Instruction 2 ===
Is Correct: False
Syntax Pass: False
Code Function: This code controls a robot to perform a two-step task. First, the robot moves to pick the handle of the bottom drawer. Next, the robot pulls the handle to open the bottom drawer by a specified distance. If any error occurs during these actions, it is printed out.
Similarity: {'ok': False, 'reason': "The code does not include turning on the light, which is required before picking the handle or pulling the drawer according to the domain's preconditions."}
Differences: 1. TASK specifies only the high-level goal: "Pull open a single drawer," without specifying which drawer or how to select it.
2. CODE_FUNC specifies the bottom drawer explicitly ("handle of the bottom drawer") and operates only on that drawer.
3. TASK does not specify any preconditions or error handling.
4. CODE_FUNC includes error handling (printing errors if actions fail).
5. CODE_FUNC describes the process as two steps: (a) pick the handle, (b) pull to open by a specified distance; TASK does not mention the number of steps or the need to pick the handle.
6. CODE_FUNC implies a specific sequence and granularity of actions, while TASK leaves the implementation details open.
7. CODE_FUNC assumes the robot must move to the handle before picking it; TASK does not mention movement.
8. CODE_FUNC specifies opening the drawer "by a specified distance," implying partial opening is possible; TASK does not specify how far to open the drawer.
9. CODE_FUNC is written as a code description, while TASK is a natural language instruction.

Refined Code Generated:
-------------------
"""Module to pull open a single drawer using the robot controller."""

from Object_list import Object
from skill_mapping import RobotController

def long_horizon_task2_oracle_seq():
    """Pull open a single drawer."""
    robot = RobotController()

    try:
        # Step 1: Move to the light switch and turn on the light
        robot.execute_movement(Object["light_switch"], mode=1, axis=2)
        robot.execute_push_switch(Object["light_switch"])

        # Step 2: Move to the handle of a drawer (e.g., bottom drawer)
        robot.execute_movement(Object["drawer_bottom_handle"], mode=1, axis=0)

        # Step 3: Pick the handle
        robot.execute_pick(Object["drawer_bottom_handle"])

        # Step 4: Pull to open the drawer using the handle
        robot.execute_movement(Object["drawer_bottom_handle"], mode=4, axis=0, distance=0.1)

    except Exception as error:
        print(f"Error during task execution: {error}")

def main():
    """Main function to execute the drawer opening task."""
    long_horizon_task2_oracle_seq()

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

=== Instruction 3 ===
Is Correct: False
Syntax Pass: False
Code Function: This code controls a robot to perform a two-step task involving a drawer. First, the robot moves to pick the bottom handle of the drawer. Next, the robot pulls the drawer open by moving the handle a specified distance. The code handles any errors that occur during these actions by printing error messages.
Similarity: {'ok': False, 'reason': "The code does not mention turning on the light, which is required before picking the handle or opening the drawer according to the domain's preconditions."}
Differences: 1. **Explicitness of Drawer Selection**  
   - TASK: "Slide one drawer open" is ambiguous about which drawer to open; it does not specify which drawer (bottom, middle, or top).
   - CODE_FUNC: Explicitly operates on the bottom drawer by picking the bottom handle and pulling it.

2. **Handling of Preconditions**  
   - TASK: Does not mention any preconditions (e.g., whether the room is dark, whether the drawer is locked/unlocked, or whether the robot is at the correct location).
   - CODE_FUNC: Implicitly assumes the robot can pick the handle and pull the drawer, but does not mention or check for room brightness, drawer lock state, or robot location.

3. **Error Handling**  
   - TASK: No mention of error handling or what to do if the action fails.
   - CODE_FUNC: Explicitly handles errors during picking and pulling by printing error messages.

4. **Level of Abstraction**  
   - TASK: High-level instruction ("slide one drawer open") without specifying the means (e.g., which handle to use, how to move, etc.).
   - CODE_FUNC: Low-level, step-by-step actions (pick handle, pull drawer) with concrete object references.

5. **Number of Drawers Opened**  
   - TASK: Implies opening a single drawer, but does not specify which.
   - CODE_FUNC: Opens specifically the bottom drawer.

6. **Object Manipulation**  
   - TASK: Does not specify how the drawer is to be opened (e.g., by pulling a handle).
   - CODE_FUNC: Specifies picking the handle and pulling it to open the drawer.

7. **Domain Constraints**  
   - TASK: Ignores domain constraints such as lighting, lock state, and robot state.
   - CODE_FUNC: Ignores some domain constraints (e.g., does not check if the room is bright or the drawer is unlocked), but assumes the robot can act.

8. **Output/Feedback**  
   - TASK: No output or feedback mechanism.
   - CODE_FUNC: Provides feedback via error messages if actions fail.

9. **Assumed Initial State**  
   - TASK: Makes no assumptions about the initial state.
   - CODE_FUNC: Assumes the handle is available to pick and the drawer can be pulled.

10. **Action Granularity**  
    - TASK: Single high-level action.
    - CODE_FUNC: Decomposes into two primitive actions (pick, pull).

11. **Robustness**  
    - TASK: No robustness to failure.
    - CODE_FUNC: Some robustness via error handling.

12. **Parameterization**  
    - TASK: No parameters specified.
    - CODE_FUNC: Operates on specific objects (bottom handle, bottom drawer).

13. **Physical Movement**  
    - TASK: Does not mention robot movement or location.
    - CODE_FUNC: Assumes robot is in position to pick and pull.

14. **Lighting Condition**  
    - TASK: Does not mention lighting.
    - CODE_FUNC: Does not check or handle lighting, but the domain requires the room to be bright for these actions.

15. **Lock State**  
    - TASK: Does not mention lock state.
    - CODE_FUNC: Does not check or handle lock state, but the domain requires the drawer to be unlocked.

---

**Summary:**  
The main semantic differences are in specificity (which drawer), level of abstraction, handling of domain constraints, error handling, and action decomposition. The TASK is high-level and ambiguous, while CODE_FUNC is concrete, specific, and includes error handling.

Refined Code Generated:
-------------------
from Object_list import Object
from skill_mapping import RobotController

def long_horizon_task2_oracle_seq():
    """Slide one drawer open: turn on the light, pick a handle, and pull to open a drawer."""
    robot = RobotController()

    try:
        # Step 1: If the room is dark, turn on the light
        robot.execute_movement(Object["light_switch"], mode=2, axis=1)
    except Exception as exc:
        print(f"Error during execute_push_switch on light_switch: {exc}")

    try:
        # Step 2: Pick the handle of a drawer (choose bottom drawer for determinism)
        robot.execute_movement(Object["drawer_bottom_handle"], mode=1, axis=0)
    except Exception as exc:
        print(f"Error during execute_pick on drawer_bottom_handle: {exc}")

    try:
        # Step 3: Pull the drawer open using the handle
        robot.execute_movement(Object["drawer_bottom_handle"], mode=4, axis=0, distance=0.1)
    except Exception as exc:
        print(f"Error during execute_pull on drawer_bottom_handle: {exc}")

def main():
    """Main entry point."""
    long_horizon_task2_oracle_seq()

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

=== Instruction 4 ===
Is Correct: False
Syntax Pass: False
Code Function: This code controls a robot to perform a two-step task involving a drawer. First, the robot moves to pick the bottom handle of the drawer. Then, it pulls the drawer open by a specified distance using the same handle. If any error occurs during these actions, it is caught and printed.
Similarity: {'ok': False, 'reason': "The code does not include turning on the light, which is required before picking up the handle or opening the drawer according to the domain's preconditions."}
Differences: 1. TASK is a high-level, open-ended instruction ("Open up one of the drawers.") that does not specify which drawer or how to open it, nor does it mention any constraints or steps.
2. CODE_FUNC describes a specific, two-step procedure: (a) the robot picks the bottom handle of the drawer, and (b) pulls the drawer open by a specified distance using that handle.
3. CODE_FUNC implicitly selects the "bottom" drawer (via "bottom handle"), whereas TASK allows for any drawer to be opened.
4. CODE_FUNC specifies the use of a particular handle ("bottom handle"), while TASK does not mention handles at all.
5. CODE_FUNC includes error handling (catching and printing errors), which is not present in TASK.
6. CODE_FUNC describes the process as a sequence of low-level actions (pick, pull), while TASK is a high-level goal.
7. CODE_FUNC does not mention any environmental preconditions (e.g., room brightness, drawer locked/unlocked state), while TASK is agnostic to such details.
8. CODE_FUNC specifies the drawer is opened "by a specified distance," implying partial opening is possible, whereas TASK could be interpreted as fully opening the drawer.
9. CODE_FUNC is robot-centric and assumes the robot is the agent, while TASK could be directed at any agent (robot, human, etc.).
10. CODE_FUNC is deterministic and procedural, while TASK is declarative and goal-oriented.

Refined Code Generated:
-------------------
"""Module to open up one of the drawers using the robot controller."""

from Object_list import Object
from skill_mapping import RobotController

def long_horizon_task2_oracle_seq():
    """Sequence to open up one of the drawers (drawer_bottom) as an example."""
    robot = RobotController()

    try:
        # Step 1: Turn on the light if the room is dark (execute_push_switch)
        robot.execute_movement(Object["light_switch"], mode=2)

        # Step 2: Pick the handle of the drawer (execute_pick)
        robot.execute_movement(Object["drawer_bottom_handle"], mode=1, axis=0)

        # Step 3: Pull the drawer using the handle (execute_pull)
        robot.execute_movement(Object["drawer_bottom_handle"], mode=4, distance=0.1)

    except Exception as error:
        print(f"Error during task execution: {error}")

def main():
    """Main function to execute the drawer opening task."""
    long_horizon_task2_oracle_seq()

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

=== Instruction 5 ===
Is Correct: False
Syntax Pass: False
Code Function: This code defines a sequence for a robot to interact with a drawer. First, the robot moves to pick the bottom handle of the drawer. Then, the robot pulls the handle to open the drawer by a specified distance. If any error occurs during these actions, it is caught and printed. The sequence is executed when the script is run directly.
Similarity: {'ok': False, 'reason': "The code does not include turning on the light, which is required before picking up the handle or opening the drawer according to the domain's preconditions."}
Differences: 1. TASK specifies the semantic goal as "uncover a drawer by opening it," which implies the end state is the drawer being open (drawer-open ?d).
2. CODE_FUNC describes a sequence where the robot picks the bottom handle and pulls it to open the drawer, but it does not explicitly mention the requirement for the room to be bright (i.e., turning on the light if the room is dark), which is a necessary precondition in the PDDL domain for opening the drawer.
3. TASK is agnostic to the initial state of the environment (e.g., whether the room is dark or bright, or the robot's location), while CODE_FUNC assumes the robot can immediately proceed to pick and pull the handle without addressing these possible preconditions.
4. CODE_FUNC includes error handling (catching and printing errors), which is not part of the TASK's semantic description.
5. TASK is an abstract instruction, while CODE_FUNC is a concrete implementation sequence with specific steps and error management.
6. CODE_FUNC specifies the use of the "bottom handle" and "bottom drawer," whereas TASK does not specify which drawer or handle to open.
7. TASK does not specify the need to pick up a handle object, but CODE_FUNC includes this as a necessary step before pulling.
8. CODE_FUNC assumes the robot is already at the correct location or can move there, but does not explicitly mention moving to the required location, while TASK does not specify location at all.
9. TASK does not specify what to do after opening the drawer, while CODE_FUNC ends after the drawer is opened (or an error is caught).
10. CODE_FUNC is executable code, while TASK is a high-level instruction.

In summary, the main semantic differences are in environmental preconditions (light, location), specificity (which drawer/handle), error handling, and abstraction level.

Refined Code Generated:
-------------------
"""Module to uncover a drawer by opening it, following PDDL domain preconditions."""

from Object_list import Object
from skill_mapping import RobotController

def long_horizon_task2_oracle_seq():
    """Sequence to uncover (open) a drawer, ensuring all preconditions are met."""
    robot = RobotController()

    # Step 1: If the room is dark, turn on the light
    if robot.is_room_dark():
        robot.execute_push_switch(Object["light_switch"], Object["ready-pose"])

    # Step 2: Move to the ready-pose location if not already there
    if not robot.is_at_location(Object["ready-pose"]):
        robot.execute_go(robot.get_current_location(), Object["ready-pose"])

    # Step 3: Pick the handle_bottom at ready-pose (execute_pick)
    robot.execute_movement(Object["drawer_bottom_handle"], mode=1, axis=0)

    # Step 4: Pull to open the drawer_bottom using handle_bottom at ready-pose (execute_pull)
    robot.execute_movement(Object["drawer_bottom_handle"], mode=4, distance=0.1)

def main():
    """Main entry point to execute the drawer uncovering task."""
    long_horizon_task2_oracle_seq()

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

