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

The task consists of several key steps: first, the gripper rotates to a specified angle; then it moves to the side position of a bottom drawer, followed by moving to the anchor position of the drawer. Next, the gripper picks up the bottom drawer and pulls it out. After that, the gripper picks up rubbish and finally places it into the bin. Each step checks if the task is completed and prints relevant messages. The environment is ensured to shut down properly at 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 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) with defined types, predicates, and actions, whereas CODE_FUNC is written in a narrative format describing the steps of a simulation.
3. **Purpose**: TASK is designed for automated planning and execution in a robotic context, while CODE_FUNC describes the execution of a simulation task, including setup and teardown processes.
4. **Detail Level**: TASK includes detailed definitions of actions, preconditions, and effects, while CODE_FUNC provides a high-level overview of the steps without specific details on preconditions or effects.
5. **Execution Context**: TASK is intended for a planning system to derive a sequence of actions, while CODE_FUNC is meant for direct execution in a simulation environment.
6. **State Representation**: TASK explicitly defines the initial state and conditions for actions, while CODE_FUNC assumes an initial state and focuses on the procedural steps to achieve the task.
7. **Action Specification**: TASK specifies actions in terms of parameters and logical conditions, while CODE_FUNC describes actions in a sequential manner without formal parameterization.
8. **Feedback Mechanism**: TASK does not include feedback or logging mechanisms, while CODE_FUNC mentions printing relevant messages during execution.
9. **Environment Management**: TASK does not address environment setup or teardown, while CODE_FUNC explicitly mentions ensuring proper shutdown of the environment after task completion.

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
        rubbish_pos = positions['rubbish']
        bin_pos = positions['bin']
        bottom_anchor_pos = positions['bottom_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 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_anchor_pos, max_steps=100, threshold=0.01, timeout=10.0)
        if done:
            print("[Task] Task ended after moving to side position!")
            return

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

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

        # Step 5: Pull 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 ended after pulling the drawer!")
            return

        # Step 6: Pick the rubbish
        print("[Task] Picking the rubbish.")
        obs, reward, done = pick(env, task, target_pos=rubbish_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 rubbish!")
            return

        # Step 7: Place the rubbish in the bin
        print("[Task] Placing the rubbish in the bin.")
        obs, reward, done = place(env, task, target_pos=bin_pos, approach_distance=0.15, max_steps=100, threshold=0.01, approach_axis='z', timeout=10.0)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
        else:
            print("[Task] Task not completed yet (done=False).")

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

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

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

The task consists of several key steps: first, the gripper is rotated to a specified orientation. Then, the gripper moves to the side position of the bottom drawer, followed by moving to the anchor position of the drawer. The gripper then picks up the bottom drawer and pulls it open. Next, it picks up rubbish from a table and finally places the rubbish into a bin. 

Throughout the process, the function checks if each step is completed successfully and prints messages indicating the status of the task. After all steps are attempted, the environment is shut down properly. The function concludes by indicating the end of the task.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK describes a high-level instruction for a robotic action, while CODE_FUNC outlines a specific implementation of that instruction in a programming context.
2. **Detail Level**: TASK provides a general sequence of actions without implementation specifics, whereas CODE_FUNC includes detailed steps and checks for executing the task.
3. **Environment Setup**: TASK does not mention any setup or initialization, while CODE_FUNC explicitly states that it sets up the environment and resets the task state.
4. **Object Interaction**: TASK mentions pulling a drawer and dropping rubbish, while CODE_FUNC specifies the exact sequence of movements and actions taken by the gripper, including rotation and position changes.
5. **Feedback Mechanism**: TASK does not include any feedback or status reporting, while CODE_FUNC includes checks for successful completion of each step and prints status messages.
6. **Simulation Context**: TASK is a conceptual instruction, while CODE_FUNC is framed within a simulation context, including optional video recording.
7. **Finalization**: TASK does not mention how the task concludes, whereas CODE_FUNC includes a shutdown process for the environment after task completion.

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 positions for the drawers and rubbish
        bottom_anchor_pos = positions['bottom_anchor_pos']
        bottom_side_pos = positions['bottom_side_pos']
        rubbish_pos = positions['rubbish']
        bin_pos = positions['bin']

        # === Execute the Plan ===
        # Step 1: Rotate the gripper to the correct orientation (not specified, assuming zero_deg)
        obs, reward, 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 bottom drawer
        obs, reward, done = move(env, task, bottom_side_pos)
        if done:
            print("[Task] Task ended after moving to side position!")
            return

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

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

        # Step 5: Pull the bottom drawer open
        obs, reward, done = pull(env, task, 'gripper', 'bottom')
        if done:
            print("[Task] Task ended after pulling the drawer!")
            return

        # Step 6: Pick the rubbish from the table
        obs, reward, done = pick(env, task, rubbish_pos, 'gripper')
        if done:
            print("[Task] Task ended after picking the rubbish!")
            return

        # Step 7: Place the rubbish into the bin
        obs, reward, done = place(env, task, rubbish_pos, bin_pos)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
        else:
            print("[Task] Task not completed yet (done=False).")

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

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

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

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

The task consists of several key steps: first, the gripper is rotated to the correct orientation; then, it moves to the side position of a bottom drawer, followed by moving to the anchor position of the drawer. Next, the gripper picks up the bottom drawer and pulls it open. After that, it picks up rubbish from the environment and finally places the rubbish into a bin. 

Throughout the process, the function checks if each step is completed successfully, printing messages to indicate the status of the task. At the end of the task, the environment is properly shut down. The function is executed when the script is run as the main program.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Nature of Content**: 
   - TASK is a detailed instruction set for a specific action involving a robotic gripper, while CODE_FUNC describes a function that implements a simulation of that task.

2. **Level of Abstraction**: 
   - TASK provides a high-level description of what needs to be done (selecting a drawer, picking up rubbish), whereas CODE_FUNC includes specific implementation details and procedural steps for executing the task.

3. **Context**: 
   - TASK is presented in a PDDL (Planning Domain Definition Language) format, which is used for defining planning problems, while CODE_FUNC is written in a programming context, likely in Python or a similar language, focusing on simulation execution.

4. **Components**: 
   - TASK includes domain definitions, types, predicates, and actions, which are essential for planning in AI. CODE_FUNC focuses on the procedural execution of these actions in a simulation environment.

5. **Execution vs. Planning**: 
   - TASK is about planning the actions that need to be taken, while CODE_FUNC is about executing those plans in a simulated environment.

6. **Output and Feedback**: 
   - TASK does not specify any output or feedback mechanism, while CODE_FUNC includes status messages to indicate the success of each step in the task.

7. **Initialization**: 
   - TASK initializes the environment through PDDL constructs, while CODE_FUNC describes the initialization of the simulation environment and the resetting of the task state programmatically.

8. **Error Handling**: 
   - TASK does not address error handling or success conditions, whereas CODE_FUNC includes checks for successful completion of each step.

9. **Recording**: 
   - CODE_FUNC mentions optional video recording of the simulation, which is not present in TASK.

10. **Execution Trigger**: 
    - CODE_FUNC specifies that it runs when the script is executed as the main program, while TASK does not include any execution context.

11. **Object Interaction**: 
    - TASK describes interactions in terms of predicates and actions, while CODE_FUNC describes these interactions in terms of function calls and procedural steps.

12. **Focus on Simulation**: 
    - CODE_FUNC emphasizes the simulation aspect of the task, while TASK is focused on the planning and action definitions without any simulation context.

13. **Step-by-Step Process**: 
    - CODE_FUNC outlines a sequential process for completing the task, while TASK provides a more abstract representation of actions without detailing the order of execution.

14. **Language and Syntax**: 
    - TASK uses PDDL syntax, which is specific to planning domains, while CODE_FUNC uses programming language syntax, which is meant for execution in a computational environment.

15. **Task Completion**: 
    - TASK does not define what constitutes the completion of the task, while CODE_FUNC implies completion through the successful execution of all steps and the shutdown of the environment.

16. **Object Types and Definitions**: 
    - TASK defines object types and their relationships in a planning context, while CODE_FUNC assumes these definitions are already established and focuses on their manipulation during execution.

17. **Gripper Actions**: 
    - TASK includes specific actions related to the gripper's interaction with objects, while CODE_FUNC describes these actions in a more narrative form, detailing the sequence of operations.

18. **Use of Predicates**: 
    - TASK utilizes predicates to define conditions and states, while CODE_FUNC does not explicitly mention predicates but rather describes the state of the environment and actions in a procedural manner.

19. **Focus on Physical Actions**: 
    - TASK emphasizes the logical structure of actions and their preconditions/effects, while CODE_FUNC emphasizes the physical execution of these actions in a simulated environment.

20. **Finalization**: 
    - TASK does not include a finalization step, while CODE_FUNC explicitly mentions shutting down the environment after task completion.

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

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

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

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

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

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

        # Define object positions
        bottom_anchor_pos = positions['bottom_anchor_pos']
        bottom_side_pos = positions['bottom_side_pos']
        rubbish_pos = positions['rubbish']
        bin_pos = positions['bin']

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

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

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

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

        # Step 5: Pull the bottom drawer open
        obs, reward, done = pull(env, task, 'gripper', 'bottom')
        if done:
            print("[Task] Task ended after pulling the drawer!")
            return

        # Step 6: Pick up the rubbish
        obs, reward, done = pick(env, task, rubbish_pos, 'gripper')
        if done:
            print("[Task] Task ended after picking up the rubbish!")
            return

        # Step 7: Place the rubbish in the bin
        obs, reward, done = place(env, task, bin_pos)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
        else:
            print("[Task] Task not completed yet (done=False).")

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

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

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

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

The task consists of several key steps: first, the gripper rotates to a specific orientation. Next, it moves to the side position of a bottom drawer, followed by moving to the anchor position of the drawer. The gripper then picks up the drawer and pulls it open. After that, it picks up rubbish from a designated position and finally places the rubbish into a bin.

Throughout the process, the function checks if each step is completed successfully and prints messages indicating the status of the task. At the end, it ensures that the environment is properly shut down. The function is executed when the script is run as the main program.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - **TASK**: Describes a specific sequence of actions to be performed by a robot to unlock a cabinet and dispose of trash.
   - **CODE_FUNC**: Describes a function that simulates the task execution, including setup, execution, and shutdown.

2. **Structure**: 
   - **TASK**: Presented in a formal PDDL (Planning Domain Definition Language) format, defining actions, predicates, and the problem domain.
   - **CODE_FUNC**: Described in a narrative format, outlining the steps of a function without formal structure.

3. **Detail Level**: 
   - **TASK**: Provides detailed preconditions and effects for each action in a structured manner.
   - **CODE_FUNC**: Offers a high-level overview of the task steps without detailing preconditions or effects.

4. **Execution Context**: 
   - **TASK**: Represents a theoretical model for planning and reasoning about actions in a robotic context.
   - **CODE_FUNC**: Represents an actual implementation that runs a simulation of the task.

5. **Output**: 
   - **TASK**: Does not produce output; it defines actions and their relationships.
   - **CODE_FUNC**: Includes print statements to indicate the status of each step during execution.

6. **Initialization**: 
   - **TASK**: Initialization is defined within the PDDL problem setup.
   - **CODE_FUNC**: Initialization includes setting up the environment and optionally starting video recording.

7. **Action Representation**: 
   - **TASK**: Actions are defined with specific parameters, preconditions, and effects.
   - **CODE_FUNC**: Actions are described in a sequential narrative without formal definitions.

8. **Error Handling**: 
   - **TASK**: Does not include error handling or success checks.
   - **CODE_FUNC**: Mentions checking if each step is completed successfully.

9. **Environment Management**: 
   - **TASK**: Focuses solely on the actions related to the task.
   - **CODE_FUNC**: Includes steps for shutting down the environment after task completion.

10. **Execution Trigger**: 
    - **TASK**: Does not specify how or when the actions are triggered.
    - **CODE_FUNC**: Specifies that the function is executed when the script is run as the main program.

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

Refined Code Generated:
-------------------
import numpy as np
from 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']
        rubbish_pos = positions['rubbish']
        bin_pos = positions['bin']

        # === Execute the Plan ===
        # Step 1: Rotate the gripper to the correct orientation (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 after rotating!")
            return

        # Step 2: Move to the 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
        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
        obs, reward, done = pick_drawer(env, task, gripper='gripper', 
                                         d='bottom', p=bottom_anchor_pos)
        if done:
            print("[Task] Task ended after picking the drawer!")
            return

        # Step 5: Pull the bottom drawer to open it
        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 rubbish
        obs, reward, done = pick(env, task, target_pos=rubbish_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 rubbish!")
            return

        # Step 7: Place the rubbish in the bin
        obs, reward, done = place(env, task, target_pos=bin_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 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. It optionally initializes video recording for the simulation. The function retrieves the positions of various objects in the environment, including a drawer and rubbish.

The task consists of several key steps: rotating the gripper to a specific angle, moving to the side and anchor positions of a bottom drawer, picking up the drawer, pulling it open, picking up rubbish from a table, and finally placing the rubbish into a bin. After each step, the function checks if the task is completed and prints a message accordingly. If the task is completed successfully, it reports the reward received.

Regardless of the outcome, the function ensures that the environment is properly shut down at the end of the execution. The overall behavior is to simulate a sequence of actions performed by a robotic system to manipulate objects in a controlled environment.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - **TASK**: Describes a specific instruction for a robotic system to perform a sequence of actions involving drawers and rubbish.
   - **CODE_FUNC**: Describes a function that implements a simulation of the task, including setup, execution, and cleanup.

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

3. **Context**:
   - **TASK**: Focuses on the actions to be taken in a physical or simulated environment.
   - **CODE_FUNC**: Focuses on the programming aspect, detailing how the task is executed within a code structure.

4. **Components**:
   - **TASK**: Involves actions like sliding open a drawer and chucking away rubbish.
   - **CODE_FUNC**: Involves programming constructs such as function definitions, object initialization, and state management.

5. **Outcome Reporting**:
   - **TASK**: Does not specify how to report outcomes or success.
   - **CODE_FUNC**: Includes mechanisms for checking task completion and reporting rewards.

6. **Environment Management**:
   - **TASK**: Assumes an environment where actions take place but does not manage it.
   - **CODE_FUNC**: Explicitly manages the environment setup and teardown.

7. **Action Sequence**:
   - **TASK**: Lists actions in a straightforward manner.
   - **CODE_FUNC**: Describes a sequence of actions with checks and balances, ensuring each step is executed correctly.

8. **Error Handling**:
   - **TASK**: Does not address error handling or contingencies.
   - **CODE_FUNC**: Implies checks for task completion and may include error handling through the simulation process.

9. **Simulation Aspect**:
   - **TASK**: Does not mention simulation; it is more about the physical actions.
   - **CODE_FUNC**: Clearly states that it runs a simulation, indicating a controlled environment for testing.

10. **Initialization**:
    - **TASK**: Does not mention any initialization steps.
    - **CODE_FUNC**: Includes initialization of the environment and objects before executing the task.

11. **Recording**:
    - **TASK**: Does not mention any recording or monitoring of the task.
    - **CODE_FUNC**: Mentions optional video recording for the simulation.

12. **Completion Criteria**:
    - **TASK**: Does not define what constitutes task completion.
    - **CODE_FUNC**: Includes checks to determine if the task is completed successfully.

13. **Feedback Mechanism**:
    - **TASK**: Lacks a feedback mechanism for the actions taken.
    - **CODE_FUNC**: Provides feedback through printed messages regarding task status and rewards.

14. **Robotic System Interaction**:
    - **TASK**: Focuses on the actions of the robot without detailing interactions.
    - **CODE_FUNC**: Details how the robotic system interacts with the environment programmatically.

15. **Action Granularity**:
    - **TASK**: Describes actions at a high level.
    - **CODE_FUNC**: Breaks down actions into specific programming steps and checks.

In summary, the semantic differences between TASK and CODE_FUNC are significant, as TASK provides a high-level instruction set while CODE_FUNC details the implementation and execution of those instructions in a simulated environment.

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
        bottom_anchor_pos = positions['bottom_anchor_pos']
        bottom_side_pos = positions['bottom_side_pos']
        rubbish_pos = positions['rubbish']
        bin_pos = positions['bin']

        # === Execute the Plan ===
        # Step 1: Rotate the gripper to the desired angle (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 after rotating!")
            return

        # Step 2: Move to the 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
        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
        obs, reward, done = pick_drawer(env, task, gripper='gripper', d='bottom', p=bottom_anchor_pos)
        if done:
            print("[Task] Task ended after picking the drawer!")
            return

        # Step 5: Pull the bottom drawer open
        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 rubbish from the table
        obs, reward, done = pick(env, task, target_pos=rubbish_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 rubbish!")
            return

        # Step 7: Place the rubbish in the bin
        obs, reward, done = place(env, task, target_pos=bin_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()
-------------------

