=== Instruction 1 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task where an agent picks up rubbish and places it in a bin. It begins by setting up the environment and resetting the task to its initial state. The simulation can optionally record video of the task. It retrieves the positions of the rubbish and the bin, then executes a plan to pick up the rubbish, checking if the task is completed after this step. If the task is not completed, it proceeds to place the rubbish in the bin, again checking for task completion. Finally, the environment is shut down properly, and the task's execution is logged throughout the process.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK defines a specific instruction for a robot to follow, while CODE_FUNC describes a function that implements a simulation of that instruction.
2. **Structure**: TASK is presented in a formal PDDL format, defining a domain and problem, whereas CODE_FUNC is a narrative description of a procedural function.
3. **Detail Level**: TASK includes specific predicates, actions, and preconditions, while CODE_FUNC provides a high-level overview of the simulation process without detailing the underlying logic or structure.
4. **Execution**: TASK does not specify how the instruction is executed, while CODE_FUNC explicitly mentions the steps taken to execute the task, including checking for task completion and logging.
5. **Environment Setup**: TASK includes the initial state of the environment in a structured format, while CODE_FUNC describes the environment setup in a more general narrative form.
6. **Outcome Handling**: TASK does not address what happens after the instruction is executed, while CODE_FUNC includes checks for task completion and proper shutdown of the environment.
7. **Flexibility**: TASK is a static definition of a task, while CODE_FUNC implies a dynamic execution that can adapt based on the state of the simulation (e.g., checking if the task is completed).

Overall, the two serve different purposes and are structured differently, leading to these semantic differences.

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
        rubbish_pos = positions['rubbish']
        bin_pos = positions['bin']
        
        # === Execute the Plan ===
        print("[Task] Picking up 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 rubbish!")
            return

        print("[Task] Placing 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 2 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function that simulates a task in a robotic environment, specifically focused on picking up rubbish and placing it in a bin. 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 the rubbish and the bin. 

The first step involves the robot picking up the rubbish from the table, and if successful, it proceeds to the next step of placing the rubbish into the bin. After each action, it checks if the task is completed and prints the corresponding status. Finally, the environment is shut down to ensure proper cleanup 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 high-level instruction for a robot to perform (drop rubbish into the bin), while CODE_FUNC outlines a specific implementation of that task in a robotic simulation environment.
2. **Structure**: TASK is presented in a formal PDDL (Planning Domain Definition Language) format, defining actions, predicates, and the problem setup. CODE_FUNC is a narrative description of a function that executes the task.
3. **Detail Level**: TASK provides a structured representation of the robot's actions and environment, while CODE_FUNC gives a procedural overview of how the task is executed, including initialization and cleanup.
4. **Execution Context**: TASK is a theoretical model that can be used in planning algorithms, whereas CODE_FUNC describes a practical implementation that runs in a programming environment.
5. **Components**: TASK includes definitions of types, predicates, and actions, while CODE_FUNC focuses on the sequence of operations and checks performed during the task execution.
6. **Outcome Reporting**: TASK does not specify how the outcome of the task is reported, while CODE_FUNC mentions printing the status of the task after each action.
7. **Environment Management**: TASK does not address environment setup or teardown, whereas CODE_FUNC explicitly mentions shutting down the environment after task execution.

In summary, the two representations serve different purposes and contexts within the domain of robotic task 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
        rubbish_pos = positions['rubbish']
        bin_pos = positions['bin']
        
        # === Execute the Plan ===
        # Step 1: Pick the rubbish from the table
        print("[Task] Picking up 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 up the rubbish!")
            return

        # Step 2: Place the rubbish into the bin
        print("[Task] Placing the rubbish 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 =====")

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 where an agent picks up rubbish and places it in a bin. It begins by setting up the environment and resetting the task to its initial state. The simulation can optionally record video of the task. It retrieves the positions of the rubbish and the bin, then executes a plan to pick up the rubbish, checking if the task is completed after this step. If successful, it proceeds to place the rubbish in the bin, again checking for task completion. Finally, it ensures the environment is properly shut down after the task execution. The function is executed when the script is run directly.
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 describes a procedural implementation of a simulation task in a programming context.
2. **Format**: TASK is structured in a domain-specific language (PDDL), whereas CODE_FUNC is written in a programming language (likely Python or similar).
3. **Purpose**: TASK defines the rules and actions for a robot to perform a specific task, while CODE_FUNC outlines the steps to execute that task in a simulated environment.
4. **Components**: TASK includes definitions of types, predicates, and actions, while CODE_FUNC includes procedural steps, environment setup, and task execution logic.
5. **Execution**: TASK is not executable on its own; it requires a planner to interpret it, while CODE_FUNC is designed to be executed directly as a script.
6. **State Management**: TASK defines the initial state and effects of actions in a declarative manner, while CODE_FUNC manages state through procedural code and checks for task completion.
7. **Output**: TASK does not specify output beyond the effects of actions, while CODE_FUNC mentions the possibility of recording video and ensuring proper shutdown of the environment.
8. **Level of Abstraction**: TASK operates at a higher level of abstraction focused on planning, while CODE_FUNC operates at a lower level, detailing the implementation of the 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
        rubbish_pos = positions['rubbish']
        bin_pos = positions['bin']

        # === Execute the Plan ===
        print("[Task] Picking up 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 up the rubbish!")
            return

        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 =====")

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

=== Instruction 4 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function that simulates a task in a virtual environment, specifically focused on picking up rubbish and placing it in a bin. 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 relevant objects, including rubbish, a table, and a bin. 

The first step of the task involves picking up the rubbish from its designated position, and if successful, it proceeds to the next step of placing the rubbish into the bin. After each action, it checks if the task is completed. Finally, the environment is shut down properly, and the function concludes with a message indicating the end of the task.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK describes a specific instruction for a robot to follow, while CODE_FUNC outlines a function that simulates the execution of that instruction in a virtual environment.
2. **Level of Abstraction**: TASK is a high-level directive, whereas CODE_FUNC provides a detailed implementation of how to achieve that directive programmatically.
3. **Context**: TASK is presented in the context of a planning domain (PDDL), focusing on the actions and states of objects, while CODE_FUNC is situated in a programming context, detailing the procedural steps taken to simulate the task.
4. **Execution**: TASK does not specify how the actions are executed, while CODE_FUNC explicitly describes the sequence of operations and checks involved in executing the task.
5. **Environment Setup**: TASK does not mention any setup or initialization, whereas CODE_FUNC includes steps for setting up the environment and resetting the task state.
6. **Feedback Mechanism**: TASK does not include any feedback or completion checks, while CODE_FUNC incorporates checks to determine if the task is completed after each action.
7. **Recording**: TASK does not mention any form of recording or monitoring, while CODE_FUNC includes an optional step for initializing video recording during the simulation.
8. **Shutdown Procedure**: TASK does not address how to conclude the task, while CODE_FUNC specifies a shutdown procedure for 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 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
        rubbish_pos = positions['rubbish']
        bin_pos = positions['bin']

        # === Execute Plan Steps ===
        # Step 1: Pick up the rubbish
        print("[Task] Picking up the rubbish at:", rubbish_pos)
        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 up rubbish!")
            return

        # Step 2: Place the rubbish in the bin
        print("[Task] Placing the rubbish in the bin at:", bin_pos)
        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 where an agent picks up rubbish and places it in a bin. It begins by setting up the environment and resetting the task to its initial state. The simulation can optionally record video of the task execution. It retrieves the positions of the rubbish and the bin, then attempts to pick up the rubbish, checking if the task is completed after this action. If successful, it proceeds to place the rubbish in the bin, again checking for task completion. Finally, the environment is shut down properly, and the task's execution status is printed at various stages.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK defines a PDDL domain and problem for a robot disposal task, while CODE_FUNC describes a function for simulating the execution of that task.
2. **Structure**: TASK is structured in PDDL format with definitions of actions, predicates, and problem setup, whereas CODE_FUNC is a narrative description of a procedural function.
3. **Execution**: TASK does not execute any actions; it merely defines the conditions and effects of actions. CODE_FUNC describes the execution of actions in a simulation.
4. **Environment Setup**: TASK specifies the initial state of the environment in PDDL, while CODE_FUNC mentions setting up the environment and resetting the task programmatically.
5. **Action Details**: TASK includes detailed definitions of actions (pick and place) with preconditions and effects, while CODE_FUNC summarizes the actions without detailing their conditions or effects.
6. **Completion Check**: CODE_FUNC includes checks for task completion after actions, which is not present in TASK.
7. **Video Recording**: CODE_FUNC mentions the option to record video of the task execution, which is not addressed in TASK.
8. **Shutdown Procedure**: CODE_FUNC describes shutting down the environment after task execution, while TASK does not include any shutdown or cleanup procedures.
9. **Status Reporting**: CODE_FUNC mentions printing the task's execution status at various stages, which is not part of TASK.

In summary, the two have distinct purposes and structures, with CODE_FUNC providing a procedural overview of executing the task defined in TASK.

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

from env import setup_environment, shutdown_environment

from skill_code import 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
        rubbish_pos = positions['rubbish']
        bin_pos = positions['bin']

        # === Execute the Plan ===
        print("[Task] Picking up 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 rubbish!")
            return

        print("[Task] Placing 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()
-------------------

