Humanoid Simulation

Discussion in 'Simulation' started by Gautam, Jul 12, 2017.

  1. Hi,
    I am trying to simulate a humanoid model and I want the model to move its hands or performing walking but I am unable to figure it out, the model kind of drops down, I am using 1.5version so could you please help me, here is the python code

    Code:
    from mujoco_py import load_model_from_path, MjSim, MjViewer
    import os
    
    model = load_model_from_path("../xmls/humanoid.xml")
    sim = MjSim(model)
    
    
    viewer = MjViewer(sim)
    
    
    sim_state = sim.get_state()
    
    while True:
        sim.set_state(sim_state)
    
        for i in range(1000):
            if i < 150:
                sim.data.ctrl[:] = 0.0
            else:
                sim.data.ctrl[:] = -1.0
            sim.step()
            viewer.render()
    
        if os.getenv('TESTING') is not None:
            break
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    You are trying to write 20 lines of Python code that solves a problem which the research community has been trying to solve for half a century. It is unlikely to work :)

    The control signals have to set to some values that make the system behave in the way you want. But what are these values? That is the general problem of control. There is no easy answer.
     
    Himadri Mishra likes this.
  3. Ha ha ok, no what I meant was I am trying to simulate and need some help in regards to calling functions, so the thing is I tried implementing an architecture with chaotic RNN and reinforcement learning in Opensim (opensim.stanford.edu) arm26 model, I want to do the same with Mujoco. The idea here is I don't want to use any exclusive kinematics or dynamics, I want the neural network to figure it out by itself, I did this with Opensim Arm model but somehow I was told that the mathematical accuracy of the model is not good and people told me to try with Mujoco so any advice would be very much helpful. Regarding that comment for half a century I guess we are getting close in answering it, Churchland and Shenoy work is interesting in this area and yours also. Any advice would be very beneficial meaning should I call functions in C++ or python for example a calling function to move the arm etc, I want to plugin the control signals from the neural network to the model
     
  4. Emo Todorov

    Emo Todorov Administrator Staff Member

    Oh, your question was not as deep as I feared :)

    When using MuJoCo in a C or C++ program, you can install various callbacks. mjcb_control in particular is called just before MuJoCo needs the control signals to advance the simulation state. So you would simply evaluate your RNN or whatever in the control callback, and copy the outputs into mjData.ctrl.

    I am not sure how callbacks would work in Python though. Maybe ask on the OpenAI forum (they developed the Python wrapper for MuJoCo and their users are using it for RL) or someone at Sergey Levine and Pieter Abbeel's group at Berkeley. Alternatively, you can set ctrl explicitly before calling step(), as in your code above. I don't see anything wrong with this approach.
     
  5. Ok seems to be a long project, I will try with the OpenAI folks but do you think these type of approaches (simulations) can help solve the understanding of motor control behaviour in our brain ?
     
    Last edited: Jul 13, 2017
  6. Emo Todorov

    Emo Todorov Administrator Staff Member

    They can help you understand the brain on the system level in an abstract sense. Given a model of the biomechanical system and cost function, you can ask, what is the optimal movement and how does it compare to observed movements. If there is mismatch, you are either using the wrong cost, or your optimizer is not converging to the real minimum, or you over-simplified the biomechanical model, or the brain is doing something mechanistic that is not well described with optimality principles. Regardless, understanding the brain is predominantly an experimental field at least for now, so whatever you do, make sure you stay close to data and talk to people who do experiments (or even better, so experiments yourself).
     
  7. Ok thank you :)