Skip to content
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

Python viewer.launch.passive() (v 2.3.3) - Crush problem #790

Closed
cidxb opened this issue Mar 24, 2023 · 13 comments
Closed

Python viewer.launch.passive() (v 2.3.3) - Crush problem #790

cidxb opened this issue Mar 24, 2023 · 13 comments
Labels
maybe bug Further investigation needed to determine whether this is a bug

Comments

@cidxb
Copy link

cidxb commented Mar 24, 2023

Hi,
it is great that mujoco offers a passive viewer now,

but I encounter another problem with it.

When I put the viewer.launch.passive() to my testing script, loading the XML model.
it will crush with this message :
Segmentation fault(core dumped)

Since I didn't meet any other similar report, I assume is because there is some thing went wrong with my setting up?

@cidxb cidxb added the question Request for help or information label Mar 24, 2023
@cidxb cidxb changed the title Python viewer.launch.passive() (v 2.3.3) Python viewer.launch.passive() (v 2.3.3) - Crush problem Mar 24, 2023
@saran-t
Copy link
Member

saran-t commented Mar 24, 2023

We need your script, model, and system config to troubleshoot.

@cidxb
Copy link
Author

cidxb commented Mar 27, 2023

Minimal XML of the model of an open-source project MuJoCo_RL_UR5.

The mesh is available at https://github.com/PaulDanielML/MuJoCo_RL_UR5

<default>
    <site rgba="0.8 0.6 0.7 0.3" type="ellipsoid" group="3"/>
    <geom contype='1' conaffinity='1' condim='4'  margin="1e-3" solref=".01 1" solimp=".99 .99 .01" />
    <joint armature="0.01" damping=".1"/>
    <default class="UR5">
        <joint damping='65'/>
    </default>
    <default class="UR5e">
        <joint damping='45'/>
    </default>
    <default class="GRIPPER">
        <joint damping='5'/>
    </default>
</default>

<visual>
    <map fogstart="3" fogend="5" znear="0.05"/>
    <quality shadowsize="2048"/>
    <scale framelength="0.1"
           framewidth="0.005"
           contactwidth="0.1"
           contactheight="0.005"
           forcewidth="0.01"
           />
</visual>

<!--Assets-->
<asset>
    <!--Meshes-->
    <mesh name="base"           file="base.stl"     />
    <mesh name="shoulder"       file="shoulder.stl" />
    <mesh name="upperarm"       file="upperarm.stl" />
    <mesh name="forearm"        file="forearm.stl"  />
    <mesh name="wrist1"         file="wrist1.stl"   />
    <mesh name="wrist2"         file="wrist2.stl"   />
    <mesh name="wrist3"         file="wrist3.stl"   />
    <mesh name="gripperpalm"    file="palm.STL"     />
    <mesh name="link_0"         file="link_0.STL"   />
    <mesh name="link_1"         file="link_1.STL"   />
    <mesh name="link_2"         file="link_2.STL"   />
    <mesh name="link_3"         file="link_3.STL"   />

    <mesh name="robotiq_85_base_link_coarse" file="robotiq_85_base_link_coarse.STL" />
    <mesh name="inner_knuckle_coarse" file="inner_knuckle_coarse.STL" />
    <mesh name="inner_finger_coarse" file="inner_finger_coarse.STL" />
    <mesh name="outer_knuckle_coarse" file="outer_knuckle_coarse.STL" />
    <mesh name="outer_finger_coarse" file="outer_finger_coarse.STL" />

    <!--Textures-->
    <texture name="ur5_tex"     type="2d"       builtin="flat" height="32" width="32" rgb1="0.45 0.45 0.45" />
    <texture name="gripper_tex" type="2d"       builtin="flat" height="32" width="32" rgb1="0.45 0.45 0.45" rgb2="0 0 0"/>
    <texture name="bench_tex"   type="2d"       builtin="flat" height="32" width="32" rgb1="0.7 0.7 0.7" />
    <texture name="sky_tex"     type="skybox"   builtin="gradient" width="100" height="100" rgb1="1 1 1" rgb2="0.3 0.3 0.8" />
    <texture name="texgeom"     type="cube"     builtin="flat" mark="cross" width="127" height="1278" rgb1="0.8 0.6 0.4" rgb2="0.8 0.6 0.4" markrgb="1 1 1" random="0.01" />
    <texture name="floor_tex"   type="2d"        builtin="checker" rgb1=".2 .3 .4" rgb2=".1 .2 .3" width="100" height="100" />
    <texture name="wood"        type="cube"     file="wood2.png"/>
    <texture name="metal"        type="cube"     file="metal2.png"/>
    <!--Materials-->
    <material name="ur5_mat"        texture="ur5_tex"   shininess="0.9" specular="0.75" reflectance="0.3"/>
    <material name="gripper_mat"    texture="gripper_tex"   shininess="0.9" specular="0.75" reflectance="0.4"/>
    <material name='floor_mat'      texture="floor_tex"  shininess="0.8" texrepeat="10 10" specular="0.7"  reflectance="0.5" />
    <material name='geom'           texture="texgeom"   texuniform="true" />
    <material name="bench_mat"      texture="metal"   shininess="0.1" specular="0.5" reflectance="0.2"/>
    <material name="tablecube"      texture="wood" rgba=".8 .8 .8 1"/>
</asset>

<!--Contacts-->
<contact>
    <exclude body1="box_link" body2="base_link"/>
    <exclude body1="base_link" body2="shoulder_link"/>
    <exclude body1="shoulder_link" body2="upper_arm_link"/>
    <exclude body1="upper_arm_link" body2="forearm_link"/>
    <exclude body1="forearm_link" body2="wrist_1_link"/>
    <exclude body1="wrist_1_link" body2="wrist_2_link"/>
    <exclude body1="wrist_2_link" body2="wrist_3_link"/>
    <exclude body1="ee_link" body2="wrist_3_link"/>
</contact>


<!--MODEL DESCRIPTION-->
<worldbody>
    <!--Lighting parameters-->
    <light name="light3" mode="targetbody" target="box_link" directional="true" pos="1 -1 3" />
    <!-- <light name="light3" mode="targetbody" target="box_link" directional="true" pos="1 1 3" /> -->
    <!--Camera parameters-->
    <camera name="main1" mode="fixed" target="ee_link" pos="2 2 2.7" axisangle="2 2 -2 1"/>
    <camera name="top_down" mode="fixed" target="ee_link" pos="0 -0.6 2.0" axisangle="2 2 2 0"/>
    <camera name="side" mode="fixed" target="ee_link" pos="0.8 -0.6 1.0" quat="0.5 0.5 0.5 0.5"/>
    <!--Floor Property-->
    <geom name='floor' material="floor_mat" pos='0 0 0' size='2.5 2.5 0.1'  type='plane' />
    <body name="pick_box" pos="0 -0.6 0.0" euler="0 0 1.57">
        <geom size=".2 .28 .03" pos ="0 0 0.88" type="box" material="bench_mat"/>
        <!-- <geom size=".2 .28 .03" pos ="0 0 0.86" type="box" material="bench_mat" friction="2 0.005 0.0001"/> -->
        <geom size=".03 .27 .44" pos ="0.23 0.0 0.44" type="box" material="bench_mat"/>
        <geom size=".03 .27 .44" pos ="-0.23 0.0 0.44" type="box" material="bench_mat"/>
        <geom size=".26 .03 .44" pos ="0.0 0.3 0.44" type="box" material="bench_mat"/>
        <geom size=".26 .03 .44" pos ="0.0 -0.3 0.44" type="box" material="bench_mat"/>
        <inertial pos="0 0 0" mass="1000" diaginertia="0 0 0" />
    </body>


    <body name="drop_box" pos="0.6 0.1 0.0">
        <geom size=".2 .3 .03" pos ="0 0 0.615" type="box" material="bench_mat"/>
        <geom size=".03 .3 .4" pos ="0.23 0.0 0.4" type="box" material="bench_mat"/>
        <geom size=".03 .3 .4" pos ="-0.23 0.0 0.4" type="box" material="bench_mat"/>
        <geom size=".26 .03 .4" pos ="0.0 0.33 0.4" type="box" material="bench_mat"/>
        <geom size=".26 .03 .4" pos ="0.0 -0.33 0.4" type="box" material="bench_mat"/>
        <inertial pos="0 0 0" mass="1000" diaginertia="0 0 0" />
    </body>


    <!--Robot UR5-->
    <body name="box_link" pos="0 0 0.435">
        <!--<geom size=".3 .2 .435" type="box" material="bench_mat"/>-->
        <geom size=".29 .19 .03" pos ="0 0 0.4" type="box" material="bench_mat"/>
        <geom size=".29 .19 .03" pos ="0 0 -0.2" type="box" material="bench_mat"/>
        <geom size=".04 .04 .435" pos =".26 .16 0" type="box" material="bench_mat"/>
        <geom size=".04 .04 .435" pos ="-.26 .16 0" type="box" material="bench_mat"/>
        <geom size=".04 .04 .435" pos =".26 -.16 0" type="box" material="bench_mat"/>
        <geom size=".04 .04 .435" pos ="-.26 -.16 0" type="box" material="bench_mat"/>
        <inertial pos="0 0 0" mass="1000" diaginertia="0 0 0" />
        <body name="base_link" pos="0 0 0.435">
            <inertial pos="0 0 0" quat="0.5 0.5 -0.5 0.5" mass="4" diaginertia="0.0072 0.00443333 0.00443333" />
            <geom type="mesh"  mesh="base" material="ur5_mat"/>
            <body name="shoulder_link" pos="0 0 0.089159">
                <inertial pos="0 0 0" mass="3.7" diaginertia="0.0102675 0.0102675 0.00666" />
                <joint name="shoulder_pan_joint" class="UR5" pos="0 0 0" axis="0 0 1" limited="true" range="-3.14159 3.14159" />
                <geom type="mesh"  mesh="shoulder" material="ur5_mat"/>
                <body name="upper_arm_link" pos="0 0.13585 0" quat="0.707107 0 0.707107 0">
                    <inertial pos="0 0 0.28" mass="8.393" diaginertia="0.226891 0.226891 0.0151074" />
                    <joint name="shoulder_lift_joint" class="UR5" pos="0 0 0" axis="0 1 0" limited="true" range="-3.14159 0" /> <!--Range= -3.14159 3.14159-->
                    <geom type="mesh"  mesh="upperarm" material="ur5_mat"/>
                    <body name="forearm_link" pos="0 -0.1197 0.425">
                        <inertial pos="0 0 0.25" mass="2.275" diaginertia="0.0494433 0.0494433 0.004095" />
                        <joint name="elbow_joint" class="UR5" pos="0 0 0" axis="0 1 0" limited="true" range="-3.14159 3.14159" />
                        <geom type="mesh"  mesh="forearm" material="ur5_mat"/>
                        <body name="wrist_1_link" pos="0 0 0.39225" quat="0.707107 0 0.707107 0">
                            <inertial pos="0 0 0" quat="0.5 0.5 -0.5 0.5" mass="1.219" diaginertia="0.21942 0.111173 0.111173" />
                            <joint name="wrist_1_joint" class="UR5e" pos="0 0 0" axis="0 1 0" limited="true" range="-3.14159 3.14159" />
                            <geom type="mesh"  mesh="wrist1" material="ur5_mat"/>
                            <body name="wrist_2_link" pos="0 0.093 0">
                                <inertial pos="0 0 0" quat="0.5 0.5 -0.5 0.5" mass="1.219" diaginertia="0.21942 0.111173 0.111173" />
                                <joint name="wrist_2_joint" class="UR5e" pos="0 0 0" axis="0 0 1" limited="true" range="-3.14159 3.14159" />
                                <geom type="mesh"  mesh="wrist2" material="ur5_mat"/>
                                <body name="wrist_3_link" pos="0 0 0.09465">
                                    <inertial pos="0 0 0" quat="0.5 0.5 -0.5 0.5" mass="0.1879" diaginertia="0.033822 0.0171365 0.0171365" />
                                    <joint name="wrist_3_joint" class="UR5e" pos="0 0 0" axis="0 1 0" limited="true" range="-3.14159 3.14159" />
                                    <geom type="mesh"  mesh="wrist3" material="ur5_mat"/>
                                    <body name="ee_link" pos="0 0.0823 0" quat="0.707107 0 0 0.707107">
                                        <inertial pos="-0.01 0 0" mass="0.001" diaginertia="1.66667e-08 1.66667e-08 1.66667e-08" />
                                        <geom size="0.005 0.005 0.005" pos="-0.01 0 0" type="box" />
                                    <!--GRIPPER-->
                                         <!-- <joint name="ee_to_base" pos="0 0 0" axis="1 0 0" limited="true" range="0 0" /> -->
                                        <body name="robotiq_85_base_link" pos="0 0 0" quat="0.5 0.5 0.5 0.5 ">
                                        <inertial pos="0.00021987 -2.3546e-10 0.030163"  quat="0.707058 0.00723369 0.00723345 0.707081" mass="0.30915" diaginertia="0.00030737 0.000289758 0.000199102" />
                                        <geom type="mesh" rgba="0.1 0.1 0.1 1" friction="0.8 0.8 0.8" mesh="robotiq_85_base_link_coarse" />
                                  
                                        <body name="left_inner_knuckle" pos="0.0127 0 0.0693075">
                                            <inertial pos="0.0170975 -3.93809e-10 0.0224918"   quat="0.947655 0 -0.319297 0" mass="0.0110931" diaginertia="5.59353e-06 3.96549e-06 1.88108e-06" />
                                            <geom type="mesh" rgba="0.1 0.1 0.1 1" friction="0.8 0.8 0.8" mesh="inner_knuckle_coarse" />
                                             <joint name="base_to_lik" class="GRIPPER" pos="0 0 0" axis="0 1 0" limited="true" range="-1 1" />

                                            <body name="left_inner_finger" pos="0.0345853 0 0.045497" >
                                                <inertial pos="0.00602756 0 0.00669926"  quat="0.699065 0.106339 0.106339 0.699065" mass="0.00724255" diaginertia="1.70064e-06 1.58577e-06 3.69621e-07" />
                                                <geom type="mesh" rgba="0.1 0.1 0.1 1" friction="0.8 0.8 0.8" mesh="inner_finger_coarse" />
                                            </body>
                                        </body>

                                        <body name="right_inner_knuckle" pos="-0.0127 0 0.0693075" quat="0 0 0 1">
                                            <inertial pos="0.0168606 3.93808e-10 0.02267"  quat="0.949317 0 -0.314322 0" mass="0.0110931" diaginertia="5.59353e-06 3.96549e-06 1.88108e-06" />
                                            <geom type="mesh" rgba="0.1 0.1 0.1 1" friction="0.8 0.8 0.8" mesh="inner_knuckle_coarse" />
                                            <joint name="base_to_rik" class="GRIPPER" pos="0 0 0" axis="0 1 0" limited="true" range="-1 1" />

                                            <body name="right_inner_finger" pos="0.034106 0 0.0458574">
                                                <inertial pos="0.00602756 0 0.00669926"  quat="0.699065 0.106339 0.106339 0.699065" mass="0.00724255" diaginertia="1.70064e-06 1.58577e-06 3.69621e-07" />
                                                <geom type="mesh" rgba="0.1 0.1 0.1 1" friction="0.8 0.8 0.8" mesh="inner_finger_coarse" />
                                            </body>
                                        </body>
                                </body>
                            </body>
                        </body>
                    </body>
                </body>
            </body>
        </body>
    </body>
</body>
            <body name="base" pos="0 0 0" quat="1.7949e-09 0 0 -1">
                <inertial pos="0 0 0" quat="1.7949e-09 0 0 -1" mass="0" diaginertia="0 0 0" />
            </body>
    </body>
    <body name="box_1" pos=".0 -.6 0.95">
        <joint armature="0" axis="1 0 0" damping="0" limited="true" name="box_1_x" pos="0 0 0" range="-5. 5." stiffness="0" type="slide"/>
        <joint armature="0" axis="0 1 0" damping="0" limited="true" name="box_1_y" pos="0 0 0" range="-5. 5." stiffness="0" type="slide"/>
        <joint armature="0" axis="0 0 1" damping="0" limited="true" name="box_1_z" pos="0 0 0" range="-2. 2." stiffness="0" type="slide"/>
        <joint armature="0" damping="0" name="box_1_rot" pos="0 0 0" stiffness="0" type="ball"/>
        <geom name="box_1" pos="0 0 0" material="tablecube" size="0.02 0.02 0.02" type="box"/>
    </body>

    <body name="box_2" pos=".0 -.6 1.1">
        <joint armature="0" axis="1 0 0" damping="0" limited="true" name="box_2_x" pos="0 0 0" range="-5. 5." stiffness="0" type="slide" />
        <joint armature="0" axis="0 1 0" damping="0" limited="true" name="box_2_y" pos="0 0 0" range="-5. 5." stiffness="0" type="slide" />
        <joint armature="0" axis="0 0 1" damping="0" limited="true" name="box_2_z" pos="0 0 0" range="-2. 2." stiffness="0" type="slide" />
        <joint armature="0" damping="0" name="box_2_rot" pos="0 0 0" stiffness="0" type="ball"/>
        <geom name="box_2" pos="0 0 0" rgba="0.0 0.5 0.8 1" size="0.015 0.015 0.015" type="box"/>
    </body>

    <body name="box_3" pos=".0 -.6 1.2">
        <joint armature="0" axis="1 0 0" damping="0" limited="true" name="box_3_x" pos="0 0 0" range="-5. 5." stiffness="0" type="slide"/>
        <joint armature="0" axis="0 1 0" damping="0" limited="true" name="box_3_y" pos="0 0 0" range="-5. 5." stiffness="0" type="slide"/>
        <joint armature="0" axis="0 0 1" damping="0" limited="true" name="box_3_z" pos="0 0 0" range="-2. 2." stiffness="0" type="slide"/>
        <joint armature="0" damping="0" name="box_3_rot" pos="0 0 0" stiffness="0" type="ball"/>
        <geom name="box_3" pos="0 0 0" rgba="0.8 0.8 0.1 1" size="0.025 0.025 0.025" type="box"/>
    </body>

    <body name="ball_1" pos=".0 -.6 1.3">
        <joint armature="0" axis="1 0 0" damping="0" limited="true" name="ball_1_x" pos="0 0 0" range="-5. 5." stiffness="0" type="slide"/>
        <joint armature="0" axis="0 1 0" damping="0" limited="true" name="ball_1_y" pos="0 0 0" range="-5. 5." stiffness="0" type="slide"/>
        <joint armature="0" axis="0 0 1" damping="0" limited="true" name="ball_1_z" pos="0 0 0" range="-2. 2." stiffness="0" type="slide"/>
        <joint armature="0" damping="0.001" name="ball_1_rot" pos="0 0 0" stiffness="0" type="ball"/>
        <geom name="ball_1" pos="0 0 0" rgba="0.9 0.2 0.2 1" size=".03" type="sphere"/>
    </body>

    <body name="ball_2" pos=".0 -.6 1.4">
        <joint armature="0" axis="1 0 0" damping="0" limited="true" name="ball_2_x" pos="0 0 0" range="-5. 5." stiffness="0" type="slide"/>
        <joint armature="0" axis="0 1 0" damping="0" limited="true" name="ball_2_y" pos="0 0 0" range="-5. 5." stiffness="0" type="slide"/>
        <joint armature="0" axis="0 0 1" damping="0" limited="true" name="ball_2_z" pos="0 0 0" range="-2. 2." stiffness="0" type="slide"/>
        <joint armature="0" damping="0.001" name="ball_2_rot" pos="0 0 0" stiffness="0" type="ball"/>
        <geom name="ball_2" pos="0 0 0" material="geom" size=".025" type="sphere"/>
    </body>

    <body name="ball_3" pos=".0 -.6 1.5">
        <joint armature="0" axis="1 0 0" damping="0" limited="true" name="ball_3_x" pos="0 0 0" range="-5. 5." stiffness="0" type="slide"/>
        <joint armature="0" axis="0 1 0" damping="0" limited="true" name="ball_3_y" pos="0 0 0" range="-5. 5." stiffness="0" type="slide"/>
        <joint armature="0" axis="0 0 1" damping="0" limited="true" name="ball_3_z" pos="0 0 0" range="-2. 2." stiffness="0" type="slide"/>
        <joint armature="0" damping="0.001" name="ball_3_rot" pos="0 0 0" stiffness="0" type="ball"/>
        <geom name="ball_3" pos="0 0 0" rgba="0.2 0.2 0.5 1" size=".02" type="sphere"/>
    </body>
</worldbody>
<!--    <fixed name="middle23_cpl" range="0 1">
        <joint joint="gripperfinger_middle_joint_2"  coef="1"/>
        <joint joint="gripperfinger_middle_joint_3"  coef="-3.5"/>
    </fixed>

    <fixed name="finger2_12_cpl" range="0 1">
        <joint joint="gripperfinger_2_joint_1"  coef="1"/>
        <joint joint="gripperfinger_2_joint_2"  coef="-1.5"/>
    </fixed>
    <fixed name="finger2_23_cpl" range="0 1">
        <joint joint="gripperfinger_2_joint_2"  coef="1"/>
        <joint joint="gripperfinger_2_joint_3"  coef="-3.5"/>
    </fixed>

    <fixed name="finger1_12_cpl" range="0 1">
        <joint joint="gripperfinger_1_joint_1"  coef="1"/>
        <joint joint="gripperfinger_1_joint_2"  coef="-1.5"/>
    </fixed>
    <fixed name="finger1_23_cpl" range="0 1">
        <joint joint="gripperfinger_1_joint_2"  coef="1"/>
        <joint joint="gripperfinger_1_joint_3"  coef="-3.5"/>
    </fixed>
</tendon> -->

<equality>
    <!-- <tendon name="middle12_cpl"    tendon1="middle12_cpl"/> -->
    <!-- <tendon name="middle23_cpl"    tendon1="middle23_cpl"/> -->

    <!-- <tendon name="finger2_12_cpl"  tendon1="finger2_12_cpl"/> -->
    <!-- <tendon name="finger2_23_cpl"  tendon1="finger2_23_cpl"/> -->

    <!-- <tendon name="finger1_12_cpl"  tendon1="finger1_12_cpl"/> -->
    <!-- <tendon name="finger1_23_cpl"  tendon1="finger1_23_cpl"/> -->

    <joint name="fingers" joint1="base_to_rik" joint2="base_to_lik" polycoef="0 1 0 0 0"/>
</equality>


<!--ACTUATORS-->
<actuator>
    <!--UR5-->
    <position name='shoulder_pan' ctrllimited="true" ctrlrange="-3.14159 3.14159" joint='shoulder_pan_joint' kp="500"/>
    <position name='shoulder_lift' ctrllimited="true" ctrlrange="-3.14159 3.14159" joint='shoulder_lift_joint' kp="500"/>
    <position name='forearm' ctrllimited="true" ctrlrange="-3.14159 3.14159" joint='elbow_joint' kp="500"/>
    <position name='wrist_1' ctrllimited="true" ctrlrange="-3.14159 3.14159" joint='wrist_1_joint' kp="100"/>
    <position name='wrist_2' ctrllimited="true" ctrlrange="-3.14159 3.14159" joint='wrist_2_joint' kp="100"/>
    <position name='wrist_3' ctrllimited="true" ctrlrange="-3.14159 3.14159" joint='wrist_3_joint' kp="100"/>

    <!-- <motor name='shoulder_pan_T' ctrllimited="true" ctrlrange="-2 2" joint='shoulder_pan_joint' gear="101"/> range -150 150 -->
    <!-- <motor name='shoulder_lift_T' ctrllimited="true" ctrlrange="-2 2" joint='shoulder_lift_joint' gear="101"/> -->
    <!-- <motor name='forearm_T' ctrllimited="true" ctrlrange="-2 2" joint='elbow_joint' gear="101" /> -->
    <!-- <motor name='wrist_1_T' ctrllimited="true" ctrlrange="-1 1" joint='wrist_1_joint' gear="101"/>  range -28 28 -->
    <!-- <motor name='wrist_2_T' ctrllimited="true" ctrlrange="-1 1" joint='wrist_2_joint' gear="101"/> -->
    <!-- <motor name='wrist_3_T' ctrllimited="true" ctrlrange="-1 1" joint='wrist_3_joint' gear="101"/> -->




    <motor name='gripper_motor' ctrllimited="true" ctrlrange="-1 1" joint='base_to_lik' gear="101"/>

    <!--<velocity name='shoulder_pan_v' class="UR5" joint='shoulder_pan_joint' kv="10"/>-->
    <!--<velocity name='shoulder_lift_v' class="UR5" joint='shoulder_lift_joint' />-->
    <!--<velocity name='forearm_v' class="UR5" joint='elbow_joint' />-->
    <!--<velocity name='wrist_1_v' class="UR5" joint='wrist_1_joint' />-->
    <!--<velocity name='wrist_2_v' class="UR5" joint='wrist_2_joint'/>-->
    <!--<velocity name='wrist_3_v' class="UR5" joint='wrist_3_joint'/>-->

    <!--Gripper-->
    <!--<position name='finger_1' ctrllimited="true" kp="20" joint='gripperfinger_1_joint_1' ctrlrange='0 1.2217'/>-->
    <!--<position name='finger_2' ctrllimited="true" kp="20" joint='gripperfinger_2_joint_1' ctrlrange='0 1.2217'/>-->
    <!--<position name='middle_finger'  ctrllimited="true" kp="20" joint='gripperfinger_middle_joint_1' ctrlrange='0 1.2217'/>-->
    <!--<position name='finger_scissor' ctrllimited="true" kp="20" joint='gripperpalm_finger_1_joint' ctrlrange="-0.2967 0.2967"/>-->

    <!-- <motor name='finger_1_T' ctrllimited="true" joint='gripperfinger_1_joint_1' ctrlrange='-0.5 .8' gear="20"/> -->
    <!-- <motor name='finger_2_T' ctrllimited="true" joint='gripperfinger_2_joint_1' ctrlrange='-0.5 .8' gear="20"/> -->
    <!-- <motor name='middle_finger_T'  ctrllimited="true" joint='gripperfinger_middle_joint_1' ctrlrange='-0.5 .8' gear="20"/> -->
    <!-- <motor name='finger_scissor_T' ctrllimited="true" joint='gripperpalm_finger_1_joint' ctrlrange="-0.8 0.8" gear="15"/>    -->

 <!--    
    <motor name='finger_1_T' ctrllimited="true" joint='gripperfinger_1_joint_1' ctrlrange='-0.1 .8' gear="20"/>
    <motor name='finger_2_T' ctrllimited="true" joint='gripperfinger_2_joint_1' ctrlrange='-0.1 .8' gear="20"/>
    <motor name='middle_finger_T'  ctrllimited="true" joint='gripperfinger_middle_joint_1' ctrlrange='-0.1 .8' gear="20"/>
    <motor name='finger_scissor_T' ctrllimited="true" joint='gripperpalm_finger_1_joint' ctrlrange="-0.8 0.8" gear="15"/> -->
</actuator>

Script

gripper_xml='/home/jeffery/Workspace/MuJoCo_RL_UR5-master/UR5+gripper/UR5gripper_2_finger.xml'

from mujoco import viewer

import mujoco as mj
model=mj.MjModel.from_xml_path(gripper_xml)
data = mj.MjData(model)
m = model
d = data
viewer.launch_passive(m,d)
for  i in range (10000):
    mujoco.mj_forward(m,d)

Error message :
Segmentation fault (core dumped)

System config:
OS: Ubuntu 22.04.2 LTS
OS Type:64-bit
Graphic: GeForce RTX 3060 Mobile/MaxQ 6G
Memory: 15.7GB (16)
Processor: 12th Intel@Core i7-12700H x 20
Pyhton env:3.10.8

MUJOCO_GL=GLFW (Since you might know that EGL isn't working for me.)

@saran-t
Copy link
Member

saran-t commented Apr 10, 2023

I think I've identified the responsible race condition. Fix incoming.

@Geryyy
Copy link

Geryyy commented Apr 29, 2023

I encounter the same issue with mujoco 2.3.5.
It crashes with a segmentation fault.

min working example:

gripper_xml='/home/geryyy/repos/mujoco/model/tendon_arm/arm26.xml'

from mujoco import viewer

import mujoco as mj
model=mj.MjModel.from_xml_path(gripper_xml)
data = mj.MjData(model)
m = model
d = data
viewer.launch_passive(m,d)
for  i in range (10000):
    mj.mj_forward(m,d)

@saran-t
Copy link
Member

saran-t commented Apr 29, 2023

@Geryyy I'll need a stack trace of your crash to troubleshoot the issue.

@Geryyy
Copy link

Geryyy commented Apr 29, 2023

stack trace:

(gdb) bt
#0  0x00007fffbdffb640 in ?? ()
#1  0x00007fffcd08bfce in ?? ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/mujoco/_simulate.cpython-310-x86_64-linux-gnu.so
#2  0x00007fffcd08ba22 in ?? ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/mujoco/_simulate.cpython-310-x86_64-linux-gnu.so
#3  0x00007fffcd08a7ae in ?? ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/mujoco/_simulate.cpython-310-x86_64-linux-gnu.so
#4  0x00007fffcd08a61a in ?? ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/mujoco/_simulate.cpython-310-x86_64-linux-gnu.so
#5  0x00007ffff60a5de6 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#6  0x00007ffff60a64e0 in _Unwind_ForcedUnwind () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#7  0x00007ffff7c9d4c6 in __GI___pthread_unwind (buf=<optimized out>) at ./nptl/unwind.c:130
#8  0x00007ffff7c95d3a in __do_cancel () at ../sysdeps/nptl/pthreadP.h:280
#9  __GI___pthread_exit (value=0x0) at ./nptl/pthread_exit.c:36
#10 0x00005555556641bd in PyThread_exit_thread ()
#11 0x00005555555c7e8b in ?? ()
#12 0x00005555556a190c in _PyEval_EvalFrameDefault ()
#13 0x00005555556b11ec in _PyFunction_Vectorcall ()
#14 0x00007ffff6ab3d51 in ?? () from /usr/lib/python3.10/lib-dynload/_ctypes.cpython-310-x86_64-linux-gnu.so
#15 0x00007ffff7e317ec in ?? () from /lib/x86_64-linux-gnu/libffi.so.8
#16 0x00007ffff7e32050 in ?? () from /lib/x86_64-linux-gnu/libffi.so.8
#17 0x00007ffff675b52b in _glfwInputError () from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/glfw/wayland/libglfw.so
#18 0x00007ffff675a58f in glfwMakeContextCurrent ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/glfw/wayland/libglfw.so
#19 0x00007fffcd0e6bfa in ?? ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/mujoco/_simulate.cpython-310-x86_64-linux-gnu.so
#20 0x00007fffcd0e2e24 in ?? ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/mujoco/_simulate.cpython-310-x86_64-linux-gnu.so
#21 0x00007fffcd0e2ce6 in ?? ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/mujoco/_simulate.cpython-310-x86_64-linux-gnu.so
#22 0x00007ffff68da12d in ?? ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/mujoco/_callbacks.cpython-310-x86_64-linux-gnu.so
#23 0x00005555556d1227 in ?? ()
#24 0x00005555556a7090 in ?? ()
#25 0x00005555556b1223 in _PyFunction_Vectorcall ()
#26 0x00005555556bf8e2 in PyObject_Call ()
#27 0x000055555569baf0 in _PyEval_EvalFrameDefault ()
#28 0x00005555556b11ec in _PyFunction_Vectorcall ()
#29 0x00005555556998cb in _PyEval_EvalFrameDefault ()
#30 0x00005555556b11ec in _PyFunction_Vectorcall ()
#31 0x00005555556998cb in _PyEval_EvalFrameDefault ()
#32 0x00005555556bee91 in ?? ()
#33 0x00005555557eae5b in ?? ()
#34 0x00005555557e0f58 in ?? ()
#35 0x00007ffff7c94b43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#36 0x00007ffff7d26a00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

@saran-t
Copy link
Member

saran-t commented Apr 29, 2023

That's really strange, it looks like you've installed a MuJoCo callback that somehow calls into simulate.

Can you share your Python code?

@saran-t saran-t added maybe bug Further investigation needed to determine whether this is a bug and removed question Request for help or information labels Apr 29, 2023
@Geryyy
Copy link

Geryyy commented Apr 29, 2023

The code is the minimal example from above.

gripper_xml='/home/geryyy/repos/mujoco/model/tendon_arm/arm26.xml'

from mujoco import viewer

import mujoco as mj
model=mj.MjModel.from_xml_path(gripper_xml)
data = mj.MjData(model)
m = model
d = data
viewer.launch_passive(m,d)
for  i in range (10000):
    mj.mj_forward(m,d)

@saran-t saran-t reopened this Apr 29, 2023
@saran-t
Copy link
Member

saran-t commented Apr 29, 2023

Please update your code to follow the example in our documentation. The API was changed in 2.3.5, specifically, you now need to hold a reference to the handle returned by viewer.launch_passive, and you also need to call sync on the handle for the updated physics to be reflected in the viewer.

@Geryyy
Copy link

Geryyy commented Apr 29, 2023

Thanks for the update! Unfortunately, it crashes with a seg fault again.
the code:

gripper_xml='/home/geryyy/repos/mujoco/model/tendon_arm/arm26.xml'

from mujoco import viewer
import time

import mujoco 
model=mujoco.MjModel.from_xml_path(gripper_xml)
data = mujoco.MjData(model)
m = model
d = data
with mujoco.viewer.launch_passive(m, d) as viewer:
  # Close the viewer automatically after 30 wall-seconds.
  start = time.time()
  while viewer.is_running() and time.time() - start < 30:
    step_start = time.time()

    # mj_step can be replaced with code that also evaluates
    # a policy and applies a control signal before stepping the physics.
    mujoco.mj_step(m, d)

    # Example modification of a viewer option: toggle contact points every two seconds.
    with viewer.lock():
      viewer.opt.flags[mujoco.mjtVisFlag.mjVIS_CONTACTPOINT] = int(d.time % 2)

    # Pick up changes to the physics state, apply perturbations, update options from GUI.
    viewer.sync()

    # Rudimentary time keeping, will drift relative to wall clock.
    time_until_next_step = m.opt.timestep - (time.time() - step_start)
    if time_until_next_step > 0:
      time.sleep(time_until_next_step)

backtrace:

hread 25 "python" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffbdffb640 (LWP 6621)]
0x00007ffff7e41627 in ?? () from /lib/x86_64-linux-gnu/libwayland-client.so.0
(gdb) bt
#0  0x00007ffff7e41627 in ?? () from /lib/x86_64-linux-gnu/libwayland-client.so.0
#1  0x00007ffff7e41705 in ?? () from /lib/x86_64-linux-gnu/libwayland-client.so.0
#2  0x00007ffff7e45902 in wl_proxy_marshal () from /lib/x86_64-linux-gnu/libwayland-client.so.0
#3  0x00007ffff6766312 in wl_buffer_destroy ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/glfw/wayland/libglfw.so
#4  0x00007ffff676b138 in _glfwPlatformDestroyWindow ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/glfw/wayland/libglfw.so
#5  0x00007ffff6761be0 in glfwDestroyWindow ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/glfw/wayland/libglfw.so
#6  0x00007fffcd0e6c0b in ?? ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/mujoco/_simulate.cpython-310-x86_64-linux-gnu.so
#7  0x00007fffcd0e2e24 in ?? ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/mujoco/_simulate.cpython-310-x86_64-linux-gnu.so
#8  0x00007fffcd0e2ce6 in ?? ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/mujoco/_simulate.cpython-310-x86_64-linux-gnu.so
#9  0x00007ffff68da12d in ?? ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/mujoco/_callbacks.cpython-310-x86_64-linux-gnu.so
#10 0x00005555556d1227 in ?? ()
#11 0x00005555556a7090 in ?? ()
#12 0x00005555556b1223 in _PyFunction_Vectorcall ()
#13 0x00005555556bf8e2 in PyObject_Call ()
#14 0x000055555569baf0 in _PyEval_EvalFrameDefault ()
#15 0x00005555556b11ec in _PyFunction_Vectorcall ()
#16 0x00005555556998cb in _PyEval_EvalFrameDefault ()
#17 0x00005555556b11ec in _PyFunction_Vectorcall ()
#18 0x00005555556998cb in _PyEval_EvalFrameDefault ()
#19 0x00005555556bee91 in ?? ()
#20 0x00005555557eae5b in ?? ()

@saran-t
Copy link
Member

saran-t commented Apr 29, 2023

Looks like the crash occurs in glfwDestroyWindow. Does the viewer work before you try to close it?

Also, those ?? in the stack trace unfortunately aren't super informative. Would you be able to figure out which Python line is causing the crash?

@Geryyy
Copy link

Geryyy commented May 3, 2023

Based on the back trace (see below) the issue is caused when the glfw window is destroyed on closing of the application.
In the minimal example from above

while viewer.is_running() and time.time() - start < 30:

the program is exited after 30 seconds which causes the segmentation fault.
If the glfw window is closed with the 'x' button the application closes nicely.

To get the back trace with debug symbols I built the python bindings (and mujoco) from source (commit 42a16f6)

back trace:

#0  0x0000000000000000 in ?? ()
#1  0x00007ffff5211b00 in glfwMakeContextCurrent ()
   from /home/geryyy/catkin_ws/src/arc/venv/lib/python3.10/site-packages/glfw/x11/libglfw.so
#2  0x00007fffb81b3507 in mujoco::GlfwAdapter::~GlfwAdapter (this=0x7fff8ca25b50, 
    __in_chrg=<optimized out>) at /tmp/pip-req-build-2umg3kz2/mujoco/simulate/glfw_adapter.cc:113
#3  0x00007fffb81b3550 in mujoco::GlfwAdapter::~GlfwAdapter (this=0x7fff8ca25b50, 
    __in_chrg=<optimized out>) at /tmp/pip-req-build-2umg3kz2/mujoco/simulate/glfw_adapter.cc:115
#4  0x00007fffb817289a in std::default_delete<mujoco::PlatformUIAdapter>::operator() (
    this=0x7fff8d3f0d98, __ptr=0x7fff8ca25b50) at /usr/include/c++/9/bits/unique_ptr.h:81
#5  0x00007fffb816abc2 in std::unique_ptr<mujoco::PlatformUIAdapter, std::default_delete<mujoco::PlatformUIAdapter> >::~unique_ptr (this=0x7fff8d3f0d98, __in_chrg=<optimized out>)
    at /usr/include/c++/9/bits/unique_ptr.h:292
#6  0x00007fffb81641a2 in mujoco::Simulate::~Simulate (this=0x7fff8d00c550, 
    __in_chrg=<optimized out>) at /tmp/pip-req-build-2umg3kz2/mujoco/simulate/simulate.h:44
#7  0x00007fffb8173498 in mujoco::python::(anonymous namespace)::SimulateWrapper::~SimulateWrapper
    (this=0x7fff8d00c550, __in_chrg=<optimized out>)
    at /tmp/pip-req-build-2umg3kz2/mujoco/simulate.cc:38
#8  0x00007fffb81734be in std::default_delete<mujoco::python::(anonymous namespace)::SimulateWrapper>::operator() (this=0x7fffb6d5c908, __ptr=0x7fff8d00c550)
    at /usr/include/c++/9/bits/unique_ptr.h:81
#9  0x00007fffb816b770 in std::unique_ptr<mujoco::python::(anonymous namespace)::SimulateWrapper, std::default_delete<mujoco::python::(anonymous namespace)::SimulateWrapper> >::~unique_ptr (
    this=0x7fffb6d5c908, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/unique_ptr.h:292
#10 0x00007fffb81730e3 in pybind11::class_<mujoco::python::(anonymous namespace)::SimulateWrapper>::dealloc (v_h=...)
    at /tmp/pip-req-build-2umg3kz2/build/temp.linux-x86_64-cpython-310/_deps/pybind11-src/include/pybind11/pybind11.h:1872
#11 0x00007ffff70e7a43 in pybind11::detail::clear_instance (self=0x7fffb6d5c8f0)
    at /tmp/pip-req-build-2umg3kz2/build/temp.linux-x86_64-cpython-310/_deps/pybind11-src/include/pybind11/detail/class.h:424
#12 0x00007ffff70e7b6b in pybind11::detail::pybind11_object_dealloc (self=0x7fffb6d5c8f0)
    at /tmp/pip-req-build-2umg3kz2/build/temp.linux-x86_64-cpython-310/_deps/pybind11-src/include/pybind11/detail/class.h:457
#13 0x0000000000546772 in ?? ()
#14 0x000000000053e3e8 in ?? ()
#15 0x0000000000629945 in _PyFunction_Vectorcall ()
#16 0x00000000006294ec in PyObject_Call ()
#17 0x00000000005ac10b in _PyEval_EvalFrameDefault ()
#18 0x0000000000629910 in _PyFunction_Vectorcall ()
#19 0x00000000005a9c15 in _PyEval_EvalFrameDefault ()
#20 0x0000000000629910 in _PyFunction_Vectorcall ()
#21 0x00000000005a9c15 in _PyEval_EvalFrameDefault ()
#22 0x00000000005a87e1 in ?? ()
#23 0x0000000000548f44 in ?? ()
#24 0x00000000006295ea in PyObject_Call ()
#25 0x000000000068e04a in ?? ()
#26 0x00000000006b6798 in ?? ()
#27 0x00007ffff7d72609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#28 0x00007ffff7eac133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

This issue is minor as the viewer can still be used in passive mode.

@curtiscjohnson
Copy link

I am having a similar minor issue as @Geryyy above. I'm using the mujoco python bindings v2.3.5 installed via pip on Ubuntu 20.04.

The passive viewer works well until the program exits by reaching 30 seconds.

Here's a minimum working example using the one of the example humanoid mjcf files:

gripper_xml = "/home/curtis/mujoco-2.3.5/model/humanoid/humanoid.xml"

from mujoco import viewer
import time

import mujoco

model = mujoco.MjModel.from_xml_path(gripper_xml)
data = mujoco.MjData(model)
m = model
d = data
with mujoco.viewer.launch_passive(m, d) as viewer:
    # Close the viewer automatically after 30 wall-seconds.
    start = time.time()
    while viewer.is_running() and time.time() - start < 10:
        step_start = time.time()

        # mj_step can be replaced with code that also evaluates
        # a policy and applies a control signal before stepping the physics.
        mujoco.mj_step(m, d)

        # Example modification of a viewer option: toggle contact points every two seconds.
        with viewer.lock():
            viewer.opt.flags[mujoco.mjtVisFlag.mjVIS_CONTACTPOINT] = int(d.time % 2)

        # Pick up changes to the physics state, apply perturbations, update options from GUI.
        viewer.sync()

        # Rudimentary time keeping, will drift relative to wall clock.
        time_until_next_step = m.opt.timestep - (time.time() - step_start)
        if time_until_next_step > 0:
            time.sleep(time_until_next_step)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maybe bug Further investigation needed to determine whether this is a bug
Projects
None yet
Development

No branches or pull requests

4 participants