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

Problem using xpos to obtain the location of the xml file loaded model #1677

Open
MingchaoQi opened this issue May 18, 2024 · 0 comments
Open
Labels
question Request for help or information

Comments

@MingchaoQi
Copy link

Hi,

I'm a student and I'm trying to use MuJoCo for homework.

I'm looking for some help with obtaining joint position coordinates.

I wrote an xml file to represent the drawer.

        <geom material="MatRedWood" pos="-0.11 0 0.065" size="0.008 0.112 0.064" group="1" type="box" mass=".05"/>
        <geom material="MatRedWood" pos="0.11 0 0.065" size="0.008 0.112 0.064" group="1" type="box" mass=".05"/>
        <geom material="MatRedWood" pos="0 0.092 0.062" size="0.102 0.008 0.064" group="1" type="box" mass=".05"/>
        <geom material="MatRedWood" pos="0 -0.008 0.004" size="0.102 0.102 0.014" group="1" type="box" mass=".05"/>
        <geom material="MatRedWood" pos="0 0.01 0.121" size="0.102 0.102 0.008" group="1" type="box" mass=".05"/>
        <geom material="MatRedWood" pos="-0.102 -0.1 0.065" size="0.012 0.012 0.064" group="1" type="box" mass=".05"/>
        <geom material="MatRedWood" pos="0.102 -0.1 0.065" size="0.012 0.012 0.064" group="1" type="box" mass=".05"/>
        <site name="base_center" pos="0.0 0.0 0.001" size="0.02" rgba="0 0 1 0" />

        <body name="drawer_link" pos="0 -0.01 0.076">
          <inertial pos="0 0 0.35" quat="0.5 0.5 0.5 0.5" mass="14.0" diaginertia="0.923301 0.764585 0.168533" />
          <joint type="slide" range="-0.1 0" limited="true" axis="0 1 0" name="goal_slidey" pos="0 0 0" damping="100.0" frictionloss="1"/>
            <geom material="MatRedWood" pos="0 -0.095 0.007" size="0.088 0.010 0.046" group="1" type="box" mass=".04"/>
            <geom material="MatRedWood" pos="0 0.065 0.008" size="0.095 0.008 0.028" group="1" type="box" mass=".04"/>
            <geom material="MatRedWood" pos="-0.072 0 0.00" size="0.008 0.084 0.028" group="1" type="box" mass=".04"/>
            <geom material="MatRedWood" pos="0.072 0 0.00" size="0.008 0.084 0.028" group="1" type="box" mass=".04"/>
            <geom material="MatRedWood" pos="0 0 -0.04" size="0.08 0.09 0.008" group="1" type="box" mass=".04"/>
            <geom material="MatCeramic" euler="1.571 0 0" pos="-0.05 -0.13 0.04" size="0.009 0.03" group="1" type="capsule" mass=".06"/>
            <geom material="MatCeramic" euler="0 1.57 0" pos="0 -0.16 0.04" size="0.009 0.05" group="1" type="capsule" mass=".06"/>
            <geom material="MatCeramic" euler="1.57 0 0" pos="0.05 -0.13 0.04" size="0.009 0.03" group="1" type="capsule" mass=".06"/>
            <site name="slide_handle" pos="0 -0.16 0.04" size="0.02" rgba="0 0 1 0" />

        </body>
      </body>
    </body>
    <site name="bottom_site" pos="0 0 -0.3" rgba="0 0 0 0" size="0.005"/>
    <site name="top_site" pos="0 0 0.3" rgba="0 0 0 0" size="0.005"/>
    <site name="horizontal_radius_site" pos="0.3 0 0" rgba="0 0 0 0" size="0.1"/>
  </body>
</worldbody>

Here I want to get the position coordinates of the joint, but the coordinates obtained are always [0, 0, 0]. Here is my code:
self.object_joint_ids["cabinet_joint"] = self.sim.model.joint_name2id(self.cabinet_object.cabint_joint)
(or self.cabinet_qpos_addrs = self.sim.model.get_joint_qpos_addr(self.cabinet_object.joints[0]))
cabinet_joint_pos = self.sim.data.xpos[self.cabinet_qpos_addrs]
Can you answer this for me? Thanks you!

@MingchaoQi MingchaoQi added the question Request for help or information label May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Request for help or information
Projects
None yet
Development

No branches or pull requests

1 participant