Skip to content

closed_loop.py: should saved frame metadata use planning-time current_info or post-step info #71

Description

@DanqiZhao21

Question about frame serialization semantics in closed_loop.py

I am trying to understand the intended meaning of each saved frame in data.pkl.

In the original implementation of closed_loop.py, the code does:

acc, steer_rate = traj2control(plan_traj, info)
obs, reward, terminated, truncated, info = env.step(action)

imu_plan_traj = plan_traj[:, [1, 0]]
imu_plan_traj[:, 1] *= -1
global_traj = traj_transform_to_global(imu_plan_traj, info['ego_box'])

save_data['frames'].append({
    'time_stamp': info['timestamp'],
    'ego_box': info['ego_box'],
    'obj_boxes': info['obj_boxes'],
    'planned_traj': {
        'traj': global_traj,
        'timestep': 0.5
    },
    'collision': info['collision'],
    'rc': info['rc']
})

My understanding

This means the saved frame uses post-step info for everything:

  • time_stamp
  • ego_box
  • obj_boxes
  • planned_traj
  • collision
  • rc

But the plan_traj itself was generated from the observation/info before env.step().

So semantically, this looks like:

  1. generate plan_t from obs_t
  2. convert plan_t to control
  3. execute one step to get info_{t+dt}
  4. save the frame using info_{t+dt} and also transform the original plan using info['ego_box']

What confuses me

This seems to make the saved trajectory no longer correspond exactly to the state from which it was generated.

In other words, the recorded frame is not a pure planning-time snapshot, but rather something like:

  • plan generated at time t
  • saved together with state/outcome at time t+dt

I want to confirm whether this is intentional.

Specific questions

  1. Is this the intended semantics of a frame in data.pkl?

    • a post-step frame that stores the previous plan aligned to the new ego state?
  2. Was it intentional to transform plan_traj using info['ego_box'] after env.step(), instead of the ego pose at planning time?

  3. Is collision / rc supposed to be interpreted as:

    • labels for the saved frame after execution, or
    • labels for the state when the plan was generated?
  4. If this is intentional, what is the reasoning behind this choice?

    • for example, is the goal to evaluate the plan after one control interval has been consumed?

Why I am asking

I noticed that using post-step info for the saved frame can change evaluation behavior noticeably, and I want to make sure I follow the original intended protocol rather than reinterpreting it incorrectly.

if plan_traj is not None:
    current_info = info  # info before env.step()

    acc, steer_rate = traj2control(plan_traj, info, wheelbase=wheelbase)

    action = {'acc': acc, 'steer_rate': steer_rate}
    obs, reward, terminated, truncated, info = env.step(action)  # info after env.step()

imu_plan_traj = plan_traj[:, [1, 0]]
imu_plan_traj[:, 1] *= -1

global_traj = traj_transform_to_global(imu_plan_traj, current_info['ego_box'])

save_data['frames'].append({
    'time_stamp': current_info['timestamp'],
    'ego_box': current_info['ego_box'],
    'obj_boxes': current_info['obj_boxes'],
    'planned_traj': {
        'traj': global_traj,
        'timestep': 0.5
    },
    'collision': info['collision'],
    'rc': info['rc']
})
’’’
if this change is right?
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions