-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load iCub URDF models in MuJoCo #155
Comments
cc @xEnVrE |
@CarlottaSartore is doing some experience in loading a URDF of a model similar to an iCub in MuJoCo, so probably some tricks that she is learning may be useful also here. |
I did some trials with the stickbot model (https://github.com/icub-tech-iit/ergocub-gazebo-simulations/tree/master/models). To load an urdf file in mujoco, it is possible to use the
I have implemented the following lines to do it programmatically, even though they can surely be improved. from urdfpy import URDF
from urdfpy import Joint
from urdfpy import Link
def get_mujoco_urdf_file(urdf_string, joint_name_list, base_link):
robot = URDF.load(urdf_string)
for item in robot.joints:
print(item)
if item.name not in (joint_name_list):
item.joint_type = "fixed"
world_joint = Joint("floating_joint","floating", "world", base_link)
world_link = Link("world",None, None, None)
robot._links.append(world_link)
robot._joints.append(world_joint)
temp_urdf = tempfile.NamedTemporaryFile(mode = 'w+')
robot.save(temp_urdf.name)
return temp_urdf In addition, to be able to correctly see the robot, one should add the following line to the urdf (I have not implemented a function which automatically add these lines yet): Then you can load the import mujoco
urdf_mujoco_file = get_mujoco_urdf_file(urdf_string, joint_name_list, base_link))
urdf_string = urdf_mujoco_file.read()
model = mujoco.MjModel.from_xml_string(urdf_string)
mujoco.mj_saveLastXML(path_to_save,model) Then, it will be possible to visualize the robot via Other useful things to add
|
Thanks for the input @CarlottaSartore ! |
In addition to the step previously listed, one should also add the motor entry for each actuated joint, to be able to control them by filling the The motors entry is could be as follow:
Note that the order in which the motors are defined should follow the order in which the joint are defined in the XML file By defining such entries in the XML files, it is possible then to control the robot. One should pay anyhow attention to have the same ordering in filling the |
Apparently MuJoCo does not supports resolving As an example, I tried to modify the iCub3 to be visualized in MuJoCo, first I installed mujoco and icub-models as in:
Then I tried to check if MuJoCo was able to load the meshes out of the box:
And by doing, so there was an error related to the fact that
and the meshes, that are contained in:
So I copied the file, and I modified the top of the file to contain the
The robot is doing strange things, but at least the meshes are correctly loaded: |
@traversaro, last year, I wrote some throwaway snippets to automatically generate mjcf files from the original icub-models and (ergoCub)(https://github.com/icub-tech-iit/ergocub-software.git) models. The primary goal was to streamline the generation process without changing original descriptions. You can find the code repository at https://github.com/siddharthdeore/icub_mujoco.git. Mujoco's collision checking algorithm excludes consecutive links connected by non-fixed(?) joints. So, it's necessary to exclude collision pairs. This can be achieved by either directly adding exclude XML tags in the original URDF (similar to Gazebo tags) or manually adding them in the generated XML. generate.py script automatically appends the necessary exclude tag along with actuator prameters. |
Thanks @siddharthdeore . Also @CarlottaSartore did some progress of this, I guess more and less around this lines of code https://github.com/ami-iit/comodo/blob/8cbd5f5bc6f65a1385a646188abf999844244d30/src/comodo/robotModel/robotModel.py#L190-L327 . It would be cool if we could consolidate these logic somewhere, so to offer a MuJoCo Menagerie (https://github.com/google-deepmind/mujoco_menagerie) like experience for users of *Cub (iCub, ergoCub) models. It seems that most of the effort in menagerie is related to import existing models from URDF, save them in MJCF and then iterate manually on the generated MJCF. However, that would not work for us, as we continuously modify our URDFs and create new robots, so we could not manage manually MJCF models, as they would quick diverse from the URDF models we store in here and in https://github.com/icub-tech-iit/ergocub-software . |
Also ami-iit/jaxsim#83 contains related code. |
I discussed a bit with @GiulioRomualdi and @Giulero in the last days and played a bit on this in the weekend, I noted my observations in google-deepmind/mujoco#1432 (comment) . TL;DR: I think we need to have a |
This issue is interesting for simulating FT placed in the middle of the link as the one in iCub: google-deepmind/mujoco#1597 . fyi @giotherobot |
MuJoCo is a physics engine that in theory is able to load URDF files (see https://mujoco.readthedocs.io/en/latest/modeling.html).
This issue is the place where people that want to use iCub models with MuJoCo can report issues, if any.
The text was updated successfully, but these errors were encountered: