MeMory-of-MOtion / docker-loco3d

Discussions relative to the docker for the generation of motion data using Loco3D pipeline.
1 stars 1 forks source link

How to read the dataset #4

Closed wxmerkt closed 5 years ago

wxmerkt commented 5 years ago

Hi, I am trying to load the dataset in Python for some analysis. The big question is how to - what are the dependencies and how do I get them into an analysable format. When I open each experiment, I see: image

The most important here is the serialized contact sequence: How can I transform this into a Python object? Do you have example scripts to load and visualise?

pFernbach commented 5 years ago

Hello, please see my comment https://github.com/MeMory-of-MOtion/docker-loco3d/issues/5#issuecomment-478099570 and the new readme file.

teguhSL commented 5 years ago

The most important here is the serialized contact sequence: How can I transform this into a Python object? Do you have example scripts to load and visualise?

To access the serialized contact sequence you need to install the multicontact-api:

You need to contact Rohan to ask for the permission.

Once you do that you can use the following codes to extract the contact sequences and the time duration (the file also contains the contact force trajectory, COM, angular momentum etc which can be access at each phase):


##################Extract Contact Sequence from File#######################
import numpy as np
from pinocchio.libpinocchio_pywrap import SE3

FILENAME = 'data/sample_data_teguh/10'
FACTOR_TIME = 1.
ROBOT = loadTalosLegs()

from locomote import ContactSequenceHumanoid
cs = ContactSequenceHumanoid(0)
cs.loadFromXML(FILENAME + '/contact_sequence_trajectory.xml', 'contact_sequence')
raw_phases = cs.contact_phases

rfs = []
lfs = []
phase_durations = []
num_phases = len(raw_phases)
for i,cur_phase in enumerate(raw_phases):
    rfs.append(cur_phase.RF_patch)
    lfs.append(cur_phase.LF_patch)
    phase_durations.append(cur_phase.time_trajectory[-1] - cur_phase.time_trajectory[0])
    print('Phase {}'.format(i))
    print('Right foot contact is {} at {}'.format(cur_phase.RF_patch.active, cur_phase.RF_patch.placement))
    print('Left foot contact is {} at {}'.format(cur_phase.LF_patch.active, cur_phase.LF_patch.placement))

#Convert durations to number of timesteps for each phase
timesteps = np.array(phase_durations)/0.005
timesteps = timesteps.astype(int)
print timesteps

I will try to add an example script to load the configuration file to rviz.