Change fixed body position at runtime

Discussion in 'Simulation' started by Adam Allevato, Oct 17, 2017.

  1. First, thanks for making a cool simulator and maintaining the community!

    I'm trying to programmatically vary parameters of my model at runtime, in code - specifically, I have a body that is attached to the world with a linear joint. I'd like the motion to be strictly linear, but the angle of the motion needs to vary from run to run. How would I go about setting the euler rotation of the body in code?

    I've tried modifying the position via xquat, but my understanding is that xquat is only used for output. I would use qpos, but qpos only gives me the joint angle, correct? I also tried adding a hinge joint, but I don't want the system to spin around that joint during the simulation.

    I'm using OpenAI's python wrapper, so it's possible that the functionality I need exists, it's just not exposed. The relevant part of the code looks like this:
    Code:
        <worldbody>
            <body pos="0 0 0.1" name="manipulator">
                <geom type="box" pos="0 -0.15 0" size="0.03 0.03 0.01" mass="1" name="manipulator_wrist"/>
                <joint axis="0 1 0" name="eef_slide" pos="0 0 0" range="-2 1" type="slide"/>
            </body>
        </worldbody>
    
    Thanks!
     
  2. I think I've figured this out! I modified the (python) value mjModel.body_quat.
     
  3. Emo Todorov

    Emo Todorov Administrator Staff Member

    Modifying body_quat rotates both the body and the joint axis (and every other model element that is a child of the body). If you want to rotate just the joint axis, you need to change mjModel.jnt_axis.
     
    kenneth shea and Kyokushin like this.