Skip to content

Lag in last_event.frame update after setObjectPoses()? #1295

@anjaliwgoogta

Description

@anjaliwgoogta

I have noticed that after an action is taken with setObjectPoses, the object metadata updates immediately and accordingly but the image, as queried through controller.last_event.frame and visualized with plot_frames() in the Ai2-THOR Colab, does not update until after another setObjectPoses action has been taken, like calling a dummy setObjectPoses (not changing any objects' position and rotation).

Am I mistaken about this? Is this a bug that the team is aware of?

Thank you! I include example code and images below.

`def rotate_translate(object_id, translation_vector_xz, degrees_to_rotate):
moveable_pickupable_objects = [obj for obj in controller.last_event.metadata["objects"] if obj["pickupable"] or obj["moveable"]]
object_metadata = controller.last_event.metadata["objects"][object_id]
object_name = object_metadata.get("name")
current_position = object_metadata.get("position")
current_rotation = object_metadata.get("rotation")

if not all([object_name, current_position, current_rotation]):
print(f"Error: Incomplete metadata for object. "
"Requires 'name', 'position', and 'rotation'. Current metadata: {object_metadata}")
else:
new_position = {
"x": current_position["x"] + translation_vector_xz["x"],
"y": current_position["y"],
"z": current_position["z"] + translation_vector_xz["z"]
}

  new_y_rotation = (current_rotation["y"] + degrees_to_rotate) % 360

  new_rotation = {
      "x": current_rotation["x"],
      "y": new_y_rotation,
      "z": current_rotation["z"]
  }

  object_pose_to_set = {
      "objectName": object_name,
      "position": new_position,
      "rotation": new_rotation
  }

  print(f"Attempting to translate '{object_name}' from "
        f"({current_position['x']:.2f}, {current_position['y']:.2f}, {current_position['z']:.2f}) to "
        f"({new_position['x']:.2f}, {new_position['y']:.2f}, {new_position['z']:.2f}).")

  print(f"Attempting to rotate '{object_name}' from "
    f"({current_rotation['x']:.2f}, {current_rotation['y']:.2f}, {current_rotation['z']:.2f}) to "
    f"({new_rotation['x']:.2f}, {new_rotation['y']:.2f}, {new_rotation['z']:.2f}).")

  # these objects will be removed from the scene unless otherwise specified 
  object_poses = [object_pose_to_set]
  for obj in moveable_pickupable_objects:
    if obj["name"] != object_name:
      object_poses.append(
          {"objectName": obj["name"],
          "position": obj["position"],
          "rotation": obj["rotation"]}
      )

  print(object_poses)

  controller.step(
      action='SetObjectPoses',
      objectPoses=object_poses
  )

  if controller.last_event.metadata["lastActionSuccess"]:
      print(f"Translation action for '{object_name}' was SUCCESSFUL.")
  else:
      print(f"Translation action for '{object_name}' FAILED!")
      print(f"Error Message: {controller.last_event.metadata['errorMessage']}")`

original image:
Image

`object_id = 4 # the box to the left of the TV stand
translation_vector_xz = {"x": 0, "z": -0.5}
degrees_to_rotate = 0

rotate_translate(object_id, translation_vector_xz, degrees_to_rotate)
print(controller.last_event.metadata["objects"][4]['position'], controller.last_event.metadata["objects"][4]['rotation'])
plot_frames(controller.last_event.frame)`

Image

Note the difference in the plotted frame before and after calling the additional setobjectposes below.

`# add dummy action so that image frame updates
rotate_translate(object_id, {"x": 0, "z": 0}, 0)

plot_frames(controller.last_event.frame)`

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions