osim-rl
osim-rl copied to clipboard
Improve interface for coordinate variables in the observation dictionary
Instead of iterating over the joints to get the generalized coordinate, velocities and accelerations for the observations, I would prefer to iterate over the coordinates in the compute_state_desc
. You can update the code as follows if you agree:
## Coordinates
res['coordinate_pos'] = {}
res['coordinate_vel'] = {}
res['coordinate_acc'] = {}
for i in range(self.coordinateSet.getSize()):
coordinate = self.coordinateSet.get(i)
name = coordinate.getName()
res['coordinate_pos'][name] = coordinate.getValue(self.state)
res['coordinate_vel'][name] = coordinate.getSpeedValue(self.state)
res['coordinate_acc'][name] = coordinate.getAccelerationValue(self.state)
This is cleaner, because a joint might have more than one coordinates and also we know the name of the coordinate instead of the joint. For example, if you do an imitation learning you might want to compare coordinates directly.