From 505cb156000513d97a2c571ec429a86cce51deb7 Mon Sep 17 00:00:00 2001 From: erwincoumans Date: Sun, 27 Jan 2019 12:11:40 -0800 Subject: [PATCH] proto2csv --- .../envs/minitaur_proto_dump_example.py | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/examples/pybullet/gym/pybullet_envs/minitaur/envs/minitaur_proto_dump_example.py b/examples/pybullet/gym/pybullet_envs/minitaur/envs/minitaur_proto_dump_example.py index b3a4017a7..ca0534ad5 100644 --- a/examples/pybullet/gym/pybullet_envs/minitaur/envs/minitaur_proto_dump_example.py +++ b/examples/pybullet/gym/pybullet_envs/minitaur/envs/minitaur_proto_dump_example.py @@ -1,4 +1,6 @@ import argparse +import numpy + from pybullet_envs.minitaur.envs import minitaur_logging parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) @@ -6,4 +8,20 @@ parser.add_argument('--log_file', help='path to protobuf file', default='') args = parser.parse_args() logging = minitaur_logging.MinitaurLogging() episode = logging.restore_episode(args.log_file) -print("episode=",episode) \ No newline at end of file +#print(dir (episode)) +#print("episode=",episode) +fields = episode.ListFields() + +recs = [] + +for rec in fields[0][1]: + #print(rec.time) + for motorState in rec.motor_states: + #print("motorState.angle=",motorState.angle) + #print("motorState.velocity=",motorState.velocity) + #print("motorState.action=",motorState.action) + #print("motorState.torque=",motorState.torque) + recs.append([motorState.angle,motorState.velocity,motorState.action,motorState.torque]) + +a = numpy.array(recs) +numpy.savetxt("motorq_qdot_action_torque.csv", a, delimiter=",") \ No newline at end of file