Closed rafaveguim closed 2 years ago
Hey,
hmm I woudn't have expected f
to be 3-dimensional in this example. There seems to be some unwanted broadcasting along the processing pipeline. Could you check what x_cart
and x_pole
is in https://github.com/cheind/pytorch-blender/blob/develop/examples/control/cartpole.py?`
I don't have blender 3.x around currently
So, I've installed latest Blender 3.0, gym 0.21 and pytorch 10.1. I however can't reproduce what you are seeing. The control example runs fine. Are you on latest develop
of blendtorch?
Yes, my branch is up to date with develop
.
I printed xcart
and xpole
in cartpole.py:
xcart: 0.0 xpole: [0. 0. 1.2]
Do these seem sane?
I'm on Mac, with python 3.9.7
xpole
is incorrect, it should be just the x-coordinate of the pole. I have no idea how that happens and I cannot reproduce it. The data you see is read from Blender when you reset/step the env. In both methods just the x coordinate of the world_matrix is returned.
I've tested the code on Ubuntu as well and it works as expected. Would you mind creating a fresh virtual environment to install pytorch-blender?
@rafaveguim any updates on this?
Is this correct in _env_reset
?
p = np.array([0.0, 0, 1.2])
Ah, you're on the right track here!
I believe the code should be
def _env_reset(self):
self.motor.motor_lin_target_velocity = 0.
self.cart.location = np.array([0.0, 0, 1.2])
self.polerot.rotation_euler[1] = np.random.uniform(-0.6, 0.6)
return self._env_post_step()
def _env_post_step(self):
c = self.cart.matrix_world.translation[0]
p = self.pole.matrix_world.translation[0]
a = self.pole.matrix_world.to_euler('XYZ')[1]
return dict(
obs=(c, p, a),
reward=0.,
done=bool(
abs(a) > 0.6
or abs(c) > 4.0
)
)
in examples/control/cartpole_gym/envs/cartpole.blend.py
. Could you try this? Not sure, why it works on other platforms though.
Problem solved!
nice, will move the updated code to develop. thanks for your help!
I just installed the project with the latest versions of pytorch (1.10.1), gym (0.21.0), and Blender (3.0.0).
I'm getting the following error when trying to run the cartpole example:
It seems that the value of
f
being passed todef _apply_motor_force(self, f):
is a numpy.ndarray of 3 values.Is there an easy way to fix this or it's a deeper issue due to changes in the dependencies?