=== Instruction 1 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task where items are picked from a table and placed into a bin. 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 positions of three items and a bin are retrieved. 

The task consists of a series of steps where each item is picked from the table and placed into the bin. After each action, the code checks if the task has ended or completed successfully, providing feedback on the task's progress and any rewards earned. Finally, the environment is shut down to ensure proper cleanup after the task is completed.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK defines a domain and problem for a robot to perform a specific action (putting rubbish in a bin) using PDDL, while CODE_FUNC describes a function that simulates the execution of that task programmatically.
2. **Structure**: TASK is structured in PDDL format with definitions of actions, predicates, and initial conditions, whereas CODE_FUNC is written in a programming language (likely Python or similar) and outlines a procedural approach to executing the task.
3. **Execution**: TASK specifies the conditions and effects of actions in a formal way, while CODE_FUNC describes a sequence of operations to be performed in a simulation environment.
4. **Feedback Mechanism**: TASK does not include any feedback mechanism for task completion, while CODE_FUNC explicitly mentions checking for task completion and providing feedback on progress and rewards.
5. **Environment Setup**: TASK defines the environment and its properties through PDDL constructs, while CODE_FUNC describes the procedural setup and resetting of the environment in a simulation context.
6. **Action Representation**: In TASK, actions are defined with preconditions and effects, while CODE_FUNC describes actions in terms of function calls and procedural steps without formal preconditions and effects.
7. **Recording**: CODE_FUNC mentions the optional initialization of video recording to capture the simulation, which is not present in TASK.
8. **Cleanup**: CODE_FUNC includes a step for shutting down the environment after task completion, which is not addressed in TASK.

Overall, the two serve different purposes and are structured differently, reflecting their respective roles in defining a task and simulating its execution.

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

from env import setup_environment, shutdown_environment
from skill_code import pick, place
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
        item1_pos = positions['item1']
        item2_pos = positions['item2']
        item3_pos = positions['item3']
        bin_pos = positions['bin']
        
        # === Task Plan Execution ===
        # Step 1: Pick item1 from the table
        print("[Task] Picking item1 from the table.")
        obs, reward, done = pick(env, task, item1_pos)
        if done:
            print("[Task] Task ended after picking item1!")
            return
        
        # Step 2: Place item1 in the bin
        print("[Task] Placing item1 in the bin.")
        obs, reward, done = place(env, task, bin_pos)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
            return
        
        # Step 3: Pick item2 from the table
        print("[Task] Picking item2 from the table.")
        obs, reward, done = pick(env, task, item2_pos)
        if done:
            print("[Task] Task ended after picking item2!")
            return
        
        # Step 4: Place item2 in the bin
        print("[Task] Placing item2 in the bin.")
        obs, reward, done = place(env, task, bin_pos)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
            return
        
        # Step 5: Pick item3 from the table
        print("[Task] Picking item3 from the table.")
        obs, reward, done = pick(env, task, item3_pos)
        if done:
            print("[Task] Task ended after picking item3!")
            return
        
        # Step 6: Place item3 in the bin
        print("[Task] Placing item3 in the bin.")
        obs, reward, done = place(env, task, bin_pos)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
            return

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

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

=== Instruction 2 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving picking and placing objects. It begins by setting up the environment and resetting the task to its initial state. It optionally initializes video recording for the simulation. The function retrieves the positions of specific objects and then executes a sequence of actions: first, it picks an item from a designated position, and if successful, it places that item into a bin. Throughout the process, it checks if the task is completed and prints relevant 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. **Purpose**: TASK defines a domain and problem for a robot disposal scenario using PDDL, while CODE_FUNC describes a function for simulating the task execution in a programming context.
2. **Structure**: TASK is structured in a formal PDDL format with actions, predicates, and problem definitions, whereas CODE_FUNC is written in a programming language format describing a function.
3. **Execution**: TASK outlines the preconditions and effects of actions in a logical framework, while CODE_FUNC describes the procedural steps taken to execute the task in a simulation.
4. **Environment Setup**: TASK specifies the initial state and objects in a declarative manner, while CODE_FUNC describes the setup and initialization of the environment in an imperative manner.
5. **Action Details**: TASK includes specific actions (pick, place, close_gripper, press) with detailed preconditions and effects, while CODE_FUNC summarizes the actions without detailing their conditions or effects.
6. **Output**: TASK does not specify output messages or feedback, while CODE_FUNC mentions printing relevant messages during execution.
7. **Completion Check**: TASK does not include a mechanism for checking task completion, whereas CODE_FUNC explicitly states that it checks if the task is completed.
8. **Shutdown Procedure**: TASK does not mention any shutdown or cleanup procedures, while CODE_FUNC ensures the environment is properly shut down after task execution.

Refined Code Generated:
-------------------
import numpy as np
from env import setup_environment, shutdown_environment
from skill_code import pick, place
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
        item1_pos = positions['item1']
        bin_pos = positions['bin']

        # === Task Plan Execution ===
        # Step 1: Pick item1 from the table
        print("[Task] Picking item1 from the table.")
        obs, reward, done = pick(
            env,
            task,
            target_pos=item1_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 item1!")
            return

        # Step 2: Place item1 into the bin
        print("[Task] Placing item1 into 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 3 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving object manipulation. It begins by setting up the environment and resetting the task to its initial state. It optionally initializes video recording for the simulation. The function retrieves the positions of specific objects and then executes a sequence of actions: first, it picks up an item from a designated position, and then it places that item into a bin. After each action, it checks if the task is completed and prints relevant messages. Finally, it ensures that the environment is properly shut down before concluding the task.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK describes a specific instruction for a robot to perform (picking up rubbish and placing it in a trash can), while CODE_FUNC outlines a function for simulating a task involving object manipulation.
2. **Detail Level**: TASK provides a detailed PDDL representation of actions, preconditions, and effects, whereas CODE_FUNC gives a high-level overview of the simulation process without specific implementation details.
3. **Context**: TASK is situated within a planning domain (robot-disposal) with defined predicates and actions, while CODE_FUNC is focused on the execution of a simulation task without explicit domain definitions.
4. **Action Specification**: TASK specifies actions (pick, place) with preconditions and effects, while CODE_FUNC describes a sequence of actions in a more abstract manner without detailing the conditions under which they occur.
5. **Environment Setup**: TASK includes the initial state of the environment and the conditions for actions, while CODE_FUNC mentions setting up the environment but does not specify the initial conditions in detail.
6. **Output**: TASK does not mention any output or feedback mechanism, while CODE_FUNC explicitly states that it prints relevant messages after actions.
7. **Completion Check**: TASK does not include a mechanism for checking task completion, whereas CODE_FUNC mentions checking if the task is completed after each action.
8. **Shutdown Procedure**: TASK does not address the shutdown of the environment, while CODE_FUNC includes a step to ensure proper shutdown 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 pick, place
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
        item1_pos = positions['item1']
        bin_pos = positions['bin']

        # === Execute Task Plan ===
        # Step 1: Pick up item1
        print("[Task] Picking up item1 at:", item1_pos)
        obs, reward, done = pick(env, task, target_pos=item1_pos)
        if done:
            print("[Task] Task ended after picking item1!")
            return

        # Step 2: Place item1 in the bin
        print("[Task] Placing item1 in the bin at:", bin_pos)
        obs, reward, done = place(env, task, target_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 4 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task where an agent interacts with objects in an environment. It begins by setting up the environment and resetting the task to its initial state. The function initializes video recording capabilities to capture the simulation. It retrieves the positions of three items and a bin.

The task consists of a series of steps where the agent picks each item from a table and places it into the bin. After each pick and place action, the function checks if the task has ended or completed successfully, providing feedback on the task's progress. Finally, the environment is shut down properly after the task execution. The function is executed when the script is run as the main program.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK describes a specific instruction for a robot to follow (throwing away trash), while CODE_FUNC outlines a function for simulating a task involving interactions with objects.

2. **Level of Detail**: 
   - TASK provides a high-level directive without implementation details, whereas CODE_FUNC includes procedural steps and implementation specifics for executing the task.

3. **Context**: 
   - TASK is focused on a single action (throwing away trash), while CODE_FUNC encompasses a broader context of setting up an environment, executing multiple actions, and managing task states.

4. **Execution**: 
   - TASK does not specify how the action should be executed, while CODE_FUNC details the sequence of actions (pick and place) and checks for task completion.

5. **Environment Interaction**: 
   - TASK implies interaction with objects but does not detail the environment setup, whereas CODE_FUNC explicitly describes initializing the environment and managing object states.

6. **Feedback Mechanism**: 
   - TASK does not mention feedback or progress tracking, while CODE_FUNC includes mechanisms for checking task completion and providing feedback.

7. **Simulation Aspect**: 
   - TASK is a directive for a real-world action, while CODE_FUNC is designed for a simulated environment, indicating a difference in application context.

8. **Initialization**: 
   - TASK assumes a starting condition without detailing it, while CODE_FUNC includes initialization steps for the environment and objects.

9. **Termination**: 
   - TASK does not address how to determine when the action is complete, while CODE_FUNC includes steps for shutting down the environment after task execution.

10. **Object Handling**: 
    - TASK focuses on the action of discarding trash, while CODE_FUNC involves multiple objects and actions (picking and placing), indicating a more complex interaction.

Refined Code Generated:
-------------------
import numpy as np
from env import setup_environment, shutdown_environment
from skill_code import pick, place
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
        item1_pos = positions['item1']
        item2_pos = positions['item2']
        item3_pos = positions['item3']
        bin_pos = positions['bin']

        # === Task Plan Execution ===
        # Step 1: Pick item1 from the table
        print("[Task] Picking item1 from the table.")
        obs, reward, done = pick(env, task, item1_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item1!")
            return

        # Step 2: Place item1 into the bin
        print("[Task] Placing item1 into the bin.")
        obs, reward, done = place(env, task, bin_pos, approach_distance=0.15)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
            return

        # Step 3: Pick item2 from the table
        print("[Task] Picking item2 from the table.")
        obs, reward, done = pick(env, task, item2_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item2!")
            return

        # Step 4: Place item2 into the bin
        print("[Task] Placing item2 into the bin.")
        obs, reward, done = place(env, task, bin_pos, approach_distance=0.15)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
            return

        # Step 5: Pick item3 from the table
        print("[Task] Picking item3 from the table.")
        obs, reward, done = pick(env, task, item3_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item3!")
            return

        # Step 6: Place item3 into the bin
        print("[Task] Placing item3 into the bin.")
        obs, reward, done = place(env, task, bin_pos, approach_distance=0.15)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
            return

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

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

=== Instruction 5 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task where an agent interacts with objects in an environment. It begins by setting up the environment and resetting the task to its initial state. The function initializes video recording capabilities to capture the simulation. It retrieves the positions of three items and a bin. 

The agent then sequentially picks each item from the table and places it into the bin, with checks after each action to determine if the task has ended. If the task is completed after picking or placing an item, it prints a message and exits. Finally, the environment is shut down properly after the task execution. The function is executed when the script is run directly.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK describes a specific instruction for a robot to dispose of rubbish on a table.
   - CODE_FUNC outlines a function that simulates the execution of a task involving interaction with objects in an environment.

2. **Structure**: 
   - TASK is structured in PDDL (Planning Domain Definition Language) format, defining actions, predicates, and the problem setup.
   - CODE_FUNC is written in a programming language (likely Python), describing a procedural function for simulation.

3. **Action Definition**: 
   - TASK defines specific actions (pick, place, close_gripper, press) with preconditions and effects.
   - CODE_FUNC describes a high-level overview of actions without detailing their implementation or conditions.

4. **Environment Setup**: 
   - TASK includes a detailed domain and problem definition, specifying types, predicates, and initial conditions.
   - CODE_FUNC mentions setting up the environment but does not provide the specifics of the environment configuration.

5. **Execution Flow**: 
   - TASK does not specify how the actions are executed or in what order; it focuses on the logical structure of the task.
   - CODE_FUNC describes a sequential execution of actions (picking and placing items) and includes checks for task completion.

6. **Output Handling**: 
   - TASK does not mention any output or feedback mechanism.
   - CODE_FUNC includes a mechanism to print messages upon task completion.

7. **Simulation Aspect**: 
   - TASK is a theoretical description of a task in a planning domain.
   - CODE_FUNC explicitly states that it runs a simulation, indicating a practical implementation.

8. **Termination**: 
   - TASK does not define how the task ends or what conditions lead to termination.
   - CODE_FUNC specifies that the function exits after the task is completed.

9. **Recording Capability**: 
   - TASK does not mention any form of recording or monitoring.
   - CODE_FUNC includes video recording capabilities to capture the simulation.

10. **Direct Execution**: 
    - TASK is a definition that would be used in a planning system.
    - CODE_FUNC specifies that it is executed when the script is run directly, indicating a runnable 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 pick, place
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
        item1_pos = positions['item1']
        item2_pos = positions['item2']
        item3_pos = positions['item3']
        bin_pos = positions['bin']

        # === Execute the Plan ===
        # Step 1: Pick item1 from the table
        print("[Task] Picking item1 from the table.")
        obs, reward, done = pick(env, task, item1_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item1!")
            return

        # Step 2: Place item1 in the bin
        print("[Task] Placing item1 in the bin.")
        obs, reward, done = place(env, task, bin_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after placing item1!")
            return

        # Step 3: Pick item2 from the table
        print("[Task] Picking item2 from the table.")
        obs, reward, done = pick(env, task, item2_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item2!")
            return

        # Step 4: Place item2 in the bin
        print("[Task] Placing item2 in the bin.")
        obs, reward, done = place(env, task, bin_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after placing item2!")
            return

        # Step 5: Pick item3 from the table
        print("[Task] Picking item3 from the table.")
        obs, reward, done = pick(env, task, item3_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item3!")
            return

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

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

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

