google-deepmind / mujoco

Multi-Joint dynamics with Contact. A general purpose physics simulator.
https://mujoco.org
Apache License 2.0
7.84k stars 783 forks source link

[<Actuator>] Custom Control Range Mapping for Actuators in MJCF XML #1697

Open ozgurgulsuna opened 3 months ago

ozgurgulsuna commented 3 months ago

Summary I am suggesting a feature to map the inherited joint control range to a custom range for the position controller within the tag in the XML configuration file. This feature would be particularly useful for scenarios where the joints are procedurally generated, and each joint starts in a random position within its respective movement range.

As an example, this joint is initiated with random position hence the range is between -1.5 and -0.2 <joint name="Linear-0-1" type="slide" axis="0.396823 0.917895 0.000000" range="-1.154032 -0.204032"/>

The new feature could be implemented by adding a new attribute to the tag that specify the desired control range. For example: <position name="Member-0-1" joint="Linear-0-1" kp="18000" kv="10000" inheritrange="1" customrange="0 1" />

Problem Description In many simulations, especially those involving procedurally generated robots, joints initialize at random positions within their respective movement ranges. These ranges vary for each joint, with some joints having negative minimum range aswell. As a result, each actuator ends up with a unique control range. Currently, there is no built-in functionality to standardize or map these control ranges to a consistent scale. This leads to a high number of actuators, each requiring manual adjustment to set their control ranges appropriately in python or c++.

Benefits

Thank you for your attention and for your continuous efforts in improving MuJoCo.

Here is a procedurally generated truss robot model from my research.

image

yuvaltassa commented 3 months ago

This is certainly possible. I think I prefer rescalerange to customrange, wdyt?

There is also the question of the semantics of kp, should they be wrt the natural units or the rescaled units?

yuvaltassa commented 3 months ago

BTW here is a dm_control function that is basically doing what you want, correct?

ozgurgulsuna commented 2 months ago

BTW here is a dm_control function that is basically doing what you want, correct?

I believe that the 'scaled_actuators' function is implemented with similar motivations, although I am not extensively familiar with the package. It seems like the intention is there.

It looks like their approach involves scaling not only the gain (kp) parameter, but bias parameters too, which seems more intuitive and precise perhaps.

I will look into this function further to see if it yields the desired results for inherent implementation.