Record object information from Issac Sim

I am trying to record the object information (such as position, speed) from the Issac Sim into a csv file. I have used the following python script to obtain the information of the carter robot successfully. However, I cannot obtain information from the simulated people. Any idea?

from omni.isaac.dynamic_control import _dynamic_control
import csv
import time


with open('/home/lab01/Downloads/sample.csv', 'a') as f:
	writer = csv.writer(f)

	print("position:", object_pose.p)
	print("rotation:", object_pose.r)


I have managed to get the information of the person with the following code.
Facing another challege here.

I am trying to do something like this:

  1. Start the simulation

  2. Check the postiion of the person and write to a csv file (not added yet).

  3. Stop the simulation

Yet the program seems to run the for loop first, than start the simulation.Maybe some kind of multi thread problem?

import omni
from pxr import UsdGeom, Gf

usd_context = omni.usd.get_context()
stage = usd_context.get_stage()

#### For testing purposes we create and select a prim
#### This section can be removed if you already have a prim selected
path = "/World/Characters/male_adult_worker_03/ManRoot/male_adult_construction_02/male_adult_construction_02//RL_BoneRoot"
cube_prim = stage.GetPrimAtPath(path)
# change the cube pose
xform = UsdGeom.Xformable(cube_prim)
omni.usd.get_context().get_selection().set_prim_path_selected(path, True, True, True, False)

# Get list of selected primitives
selected_prims = usd_context.get_selection().get_selected_prim_paths()
# Get the current timecode
timeline = omni.timeline.get_timeline_interface()
timecode = timeline.get_current_time() * timeline.get_time_codes_per_seconds()

for i in range(5000):
    # Loop through all prims and print their transforms
    for s in selected_prims:
        curr_prim = stage.GetPrimAtPath(s)
        print("Selected", s)
        pose = omni.usd.utils.get_world_transform_matrix(curr_prim, timecode)
        print("Matrix Form:", pose)
        print("Translation: ", pose.ExtractTranslation())
        q = pose.ExtractRotation().GetQuaternion()
            "Rotation: ", q.GetReal(), ",", q.GetImaginary()[0], ",", q.GetImaginary()[1], ",", q.GetImaginary()[2]


Hi @yang.guang - Someone from our team will review and get back to you.

1 Like

Many thanks!