Giter VIP home page Giter VIP logo

Comments (6)

saran-t avatar saran-t commented on May 17, 2024 7

You can actually already do this without needing to touch MuJoCo's source code at all. If your goal is to provide your own actuation model (e.g. by training a neural network to model real motors from logged data), the best way to proceed is by using actuator callbacks. More specifically:

  • Define a C function of type [mjfAct](gainprm = "0") that outputs the torque for a given actuator ID.
  • Assign your function to MuJoCo's global function pointer to mjcb_act_bias
  • In your model, create a <general> actuator with gainprm = "0" and biastype = 'user'.

See here for more detail on how actuator bias, gain, and activation translate to torque.

We still commit to fully open sourcing MuJoCo next year as originally announced. There are a number of technical action items on our side that we need to complete before we can open source. In the meantime, we will continue to release new binaries under permissive license terms that tackle some of the issues that we've posted on GitHub.

I'll go ahead and change the title of this issue to reflect the technical question in your OP. If there are other specific issues that you feel require source access, please continue to reach out to us via new GitHub issues or discussions. Often, MuJoCo's existing API already offer the feature you need, and we can point you in the right direction. If that's not the case, we can work with you to see what we can do to help.

from mujoco.

cadop avatar cadop commented on May 17, 2024

@MotorCityCobra I think this is it https://github.com/openai/mujoco-py
and https://github.com/deepmind/dm_control

from mujoco.

MotorCityCobra avatar MotorCityCobra commented on May 17, 2024

Interesting. I knew about MuJoCo-py, but not the other.
Still, I want the source files in C++ for MuJoCo. These both look like theyโ€™re in Python. .

from mujoco.

MotorCityCobra avatar MotorCityCobra commented on May 17, 2024
  • outputs the torque for a given actuator ID.

Thank you for the reply. Very enlightening.
I haven't had a chance to get too far with the steps you laid out, and I thank you for the spoon feeding. I need it. But I might be picturing something a bit more elaborate.

I'll try to ask the pinitol question before going into excruciating detail...
Can the user controlled bias be reset to a new value at every singe time frame? Or is it timestep? That's what I need.
Does something need to be compiled after a bias value is reset?

In the docs for some of the functions you posted I'm seeing "bias for specified actuator", but I can't set a single bias for specific actuators individually for my model. The current state of every sensor and input to every motor has to set the bias at every timestep in the simulation. I want inputs from all data about the robot inputted to my trained model inside the simulation. I want this trained model to set the bias.
Can these biases be changed at every timestep? Maybe then I can work with them. But I think I might need more than bias. I want the trained model to do all the actuator predictions and the simulator to handle gravity and collisions.
I'll say it other ways just to be clear. When training on the physical robot the neural net will have an input of every sensor on the robot. Accelerometers, gyros, and encoders. Other inputs to the neural net will be the torque, or torque called for into every actuator. Final inputs will be voltage, or something to factor battery power. Other data will be inputted, but let's leave those worms canned.

The bias for every actuator will depend on the state of every sensor and the action of every motor and this will vary at every time step. What's the word? Dynamic, wholistic?
In my vision no simulator estimates the next state of a limb without inputting all current actions and positions. The actuators will have specific biases but they will always be in flux because I want the simulator sending all actions and states into my trained model in order to get the output for the prediction of where that force put the limbs.

I repeated myself many times, but redundancy goes hand in hand with being precise.

The model architecture:
Inputs will be the current position and current demands made for force from actuators.
Outputs will be the positions of every limb.

from mujoco.

MotorCityCobra avatar MotorCityCobra commented on May 17, 2024

@saran-t

Here's what I have so far.

Modified from the humanoid.xml sample model.

<actuator>
    <motor name="abdomen_y"       gear="200" joint="abdomen_y" />
    <general gaintype="user" gear="100" biastype="user" joint="abdomen_z" name="abdomen_z"/>
    <motor name="abdomen_x"       gear="200" joint="abdomen_x" />  

Create a my callback function

mjtNum my_callback(const mjModel *m, const mjData *d, int ssid)
{
    return 10000;
}

Inside the main function after the window is rendered.

    if (m)
    {
        int ssid = m->name_actuatoradr[1];

        mjcb_act_bias = my_callback;

        m->actuator_biasprm[1] = 2000;

I've tried changing a few things, but the model doesn't seem to be affected.

from mujoco.

kevinzakka avatar kevinzakka commented on May 17, 2024

Closing with the introducing of plugins.

from mujoco.

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.