Git Product home page Git Product logo

Comments (9)

cheind avatar cheind commented on June 3, 2024

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

from pytorch-blender.

cheind avatar cheind commented on June 3, 2024

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?

from pytorch-blender.

rafaveguim avatar rafaveguim commented on June 3, 2024

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

from pytorch-blender.

cheind avatar cheind commented on June 3, 2024

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?

from pytorch-blender.

cheind avatar cheind commented on June 3, 2024

@rafaveguim any updates on this?

from pytorch-blender.

rafaveguim avatar rafaveguim commented on June 3, 2024

Is this correct in _env_reset?

p = np.array([0.0, 0, 1.2])

from pytorch-blender.

cheind avatar cheind commented on June 3, 2024

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.

from pytorch-blender.

rafaveguim avatar rafaveguim commented on June 3, 2024

Problem solved!

from pytorch-blender.

cheind avatar cheind commented on June 3, 2024

nice, will move the updated code to develop. thanks for your help!

from pytorch-blender.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.