=== Instruction 1 ===
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, including two items and a bin. 

The task consists of two main steps: first, it picks up an item from a table, and if successful, it then places that item into a designated 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 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 (put rubbish in bin), while CODE_FUNC outlines the implementation details of a simulation that executes a similar task.
2. **Level of Abstraction**: TASK is an abstract directive without implementation details, whereas CODE_FUNC provides a concrete implementation of the task with specific steps and checks.
3. **Structure**: TASK is structured in PDDL format, defining a domain and problem, while CODE_FUNC is written in a programming language (likely Python) and describes a function.
4. **Execution Context**: TASK is meant to be interpreted by a planner or a robot operating system, while CODE_FUNC is intended to be executed as a script or program.
5. **Details of Actions**: TASK specifies actions in terms of preconditions and effects in a formal way, while CODE_FUNC describes the actions in a procedural manner, including success checks and message outputs.
6. **Environment Setup**: TASK includes a definition of the initial state and objects in a PDDL format, while CODE_FUNC describes the setup and reset of the environment in a programming context.
7. **Output**: TASK does not specify any output or feedback mechanism, while CODE_FUNC includes print statements to provide feedback on the task's progress and completion.
8. **Error Handling**: TASK does not address error handling, while CODE_FUNC implies checks for successful execution of actions and may include handling for failures.

In summary, the two serve different purposes and are structured differently, with TASK being a formal specification and CODE_FUNC being an implementation of that specification.

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 in the bin
        print("[Task] Placing item1 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 to run a simulation task involving picking and placing items. 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 two items and a bin. 

The task consists of four main steps: first, it picks the first item from a table and places it into a bin; second, it picks the second item from the table and places it into the same bin. After each action, it checks if the task is completed. If the task ends after any step, it prints a message and exits. 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 defines a domain and problem for a robot disposal scenario, while CODE_FUNC describes a function that simulates the execution of the task defined in TASK.
2. **Structure**: TASK is structured in PDDL (Planning Domain Definition Language) format, whereas CODE_FUNC is written in a programming language (likely Python or similar).
3. **Components**: TASK includes definitions of types, predicates, and actions, while CODE_FUNC focuses on the procedural steps to execute the actions defined in TASK.
4. **Execution**: TASK does not execute any actions; it merely defines them. CODE_FUNC actually performs the actions of picking and placing items.
5. **Environment Setup**: TASK specifies the initial state of the environment in a declarative manner, while CODE_FUNC involves procedural setup and resetting of the environment.
6. **Feedback Mechanism**: TASK does not provide feedback or completion messages; CODE_FUNC includes checks for task completion and prints messages accordingly.
7. **Simulation Control**: CODE_FUNC includes optional video recording and shutdown procedures, which are not present in TASK.
8. **Action Sequence**: TASK defines actions in a general sense, while CODE_FUNC specifies a sequence of actions to be performed in a specific order.

Refined Code Generated:
-------------------
import numpy as np

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 object positions
        item1_pos = positions['item1']
        item2_pos = positions['item2']
        bin_pos = positions['bin']

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

        # Step 3: Pick item2 from the table
        print("[Task] Picking item2 from the table.")
        obs, reward, done = task.pick(
            target_pos=item2_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 item2!")
            return

        # Step 4: Place item2 into the bin
        print("[Task] Placing item2 into the bin.")
        obs, reward, done = task.place(
            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)
            return

    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 picking and placing an item. 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, including two items and a bin. 

The task consists of two main steps: first, it picks up an item from a specified position on the table, and if successful, it then places that item into a designated 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 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. **Nature of Content**: TASK is a formal representation of a planning problem in PDDL, while CODE_FUNC describes a procedural function for simulating a task in a programming context.
2. **Format**: TASK is structured in a declarative format (PDDL), whereas CODE_FUNC is written in an imperative programming style.
3. **Purpose**: TASK defines the rules and conditions for a robot to perform actions, while CODE_FUNC outlines the implementation of those actions in a simulation.
4. **Level of Abstraction**: TASK operates at a higher level of abstraction, focusing on the logical relationships and requirements, while CODE_FUNC deals with specific implementation details and execution flow.
5. **Components**: TASK includes predicates, actions, and their effects, while CODE_FUNC includes function definitions, environment setup, and procedural steps.
6. **Execution**: TASK does not execute actions but defines how they should be executed, whereas CODE_FUNC actually runs the simulation and performs the actions.
7. **State Management**: TASK specifies the initial state and effects of actions in a logical manner, while CODE_FUNC manages state through procedural code and checks for task completion.
8. **Output**: TASK does not produce output directly; it is a model for planning. CODE_FUNC includes print statements to provide feedback during execution.
9. **Flexibility**: TASK can be reused for different scenarios by changing the problem definition, while CODE_FUNC is typically more rigid and specific to the defined simulation task.

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 at:", item1_pos)
        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 in the bin
        print("[Task] Placing item1 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 4 ===
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, including two items and a bin. 

The first step of the task involves picking up "item2" from a table, and if successful, it proceeds to the next step of placing "item2" into the bin. After each action, it checks if the task is completed and prints relevant messages. 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 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 structured in PDDL (Planning Domain Definition Language) format, focusing on actions, predicates, and problem definitions. CODE_FUNC is a narrative description of a function's behavior in a programming context.
3. **Level of Abstraction**: TASK operates at a higher level of abstraction, specifying what needs to be done (throwing away trash), whereas CODE_FUNC details the procedural steps taken to achieve that goal (picking and placing objects).
4. **Execution Context**: TASK is a theoretical model for planning and does not execute actions, while CODE_FUNC implies actual execution of code in a programming environment.
5. **Details of Actions**: TASK specifies the actions (pick and place) in terms of preconditions and effects, while CODE_FUNC describes the sequence of actions taken during the simulation without formal preconditions and effects.
6. **Outcome Focus**: TASK focuses on the desired outcome (throwing away trash), while CODE_FUNC emphasizes the process and checks for task completion during execution.
7. **Environment Setup**: TASK includes a domain and problem definition, while CODE_FUNC mentions setting up the environment and resetting the task state, which is not present in TASK.
8. **Object Interaction**: TASK mentions generic objects (trash), while CODE_FUNC specifies particular objects (item2, bin) involved in the simulation.
9. **Feedback Mechanism**: CODE_FUNC includes feedback mechanisms (printing messages) to indicate progress, which is not present in TASK.

Overall, the two serve different purposes and contexts within the realm of robotics and simulation.

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
        item2_pos = positions['item2']
        bin_pos = positions['bin']

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

        # Step 2: Place item2 in the bin
        print("[Task] Placing item2 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 5 ===
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. Video recording is optionally initialized to capture the simulation. The positions of various objects are retrieved, including two items and a tomato, as well as a bin for placing them.

The task consists of a series of steps where the program picks each object from a table and places it into the bin. Specifically, it first picks "item1," places it in the bin, then picks "item2," places it in the bin, and finally picks "tomato1" and places it in the bin. After each action, the program checks if the task is completed and prints appropriate messages. 

Regardless of the outcome, the environment is ensured to be shut down at the end of the task. The function is executed when the script is run directly.
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 that simulates the execution of that task programmatically.
2. **Structure**: TASK is structured in a formal PDDL format, including definitions of actions, predicates, and problem setup. CODE_FUNC is a narrative description of a procedural function that implements the task.
3. **Execution**: TASK does not specify how the actions are executed; it only defines the rules and conditions. CODE_FUNC explicitly describes the sequence of actions taken during the simulation.
4. **Environment Setup**: TASK includes the initial state of the environment in the PDDL format, while CODE_FUNC describes the setup in a more general programming context.
5. **Output**: TASK does not mention any output or feedback mechanism, whereas CODE_FUNC includes checks for task completion and prints messages based on the outcome.
6. **Flexibility**: TASK is a static definition that can be used in various planners, while CODE_FUNC is a specific implementation that may not be easily adaptable without modifying the code.
7. **Recording**: CODE_FUNC mentions optional video recording of the simulation, which is not addressed in TASK.
8. **Shutdown Procedure**: CODE_FUNC includes a shutdown procedure to ensure the environment is closed after the task, which is not part of TASK.

Refined Code Generated:
-------------------
import numpy as np

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 object positions
        item1_pos = positions['item1']
        item2_pos = positions['item2']
        tomato1_pos = positions['tomato1']
        bin_pos = positions['bin']

        # === Execute Task Plan ===
        # Step 1: Pick item1 from the table
        print("[Task] Picking item1 from the table.")
        obs, reward, done = task.pick(target_pos=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 = task.place(target_pos=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 = task.pick(target_pos=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 = task.place(target_pos=bin_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after placing item2!")
            return

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

        # Step 6: Place tomato1 in the bin
        print("[Task] Placing tomato1 in the bin.")
        obs, reward, done = task.place(target_pos=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 =====")

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

