Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Is there a possibility to set up initial joint positions before running the simulation in Unity?

Discussion in 'Robotics' started by agru, Dec 13, 2021.

  1. agru

    agru

    Joined:
    Jul 6, 2020
    Posts:
    13
    I need to find a way to set up custom joint positions before the simulation starts. Is there a way to do this?
     
  2. peifeng-unity

    peifeng-unity

    Unity Technologies

    Joined:
    Mar 30, 2020
    Posts:
    6
    Hi @agru, are you using ArticulationBody components on the joints? Before the simulation starts, the initial joint positions can be set via the Transform in the Editor. If it is a prismatic or revolute joint, you may need to carefully choose the right axis.
    1. select the joint
    2. find the ArticulationBody component and the corresponding Transform component in the Inspector
    3. change the values in the Transform component (positions or rotations)

    If you are importing the articulation body from a URDF file using the URDF-Importer, it is also possible to set the initial joint positions in the file.
     
    agru likes this.
  3. agru

    agru

    Joined:
    Jul 6, 2020
    Posts:
    13
    Thanks for your reply. But I think there is no specific tag for initial joint positions in URDF. Or am I wrong?
    And yes, I am using Articulation Bodies. But it would be better if I can change them directly in the URDF.
     
  4. peifeng-unity

    peifeng-unity

    Unity Technologies

    Joined:
    Mar 30, 2020
    Posts:
    6
    You could rotate the joint initial position by updating the "rpy" attribute in the <joint><origin> field. For example, the original joint definition in the URDF is the following

    Code (CSharp):
    1.  <joint name="joint_2" type="revolute">
    2.     <parent link="link_1"/>
    3.     <child link="link_2"/>
    4.     <origin rpy="0 0 0" xyz="0.040 0 0"/>
    5.     <axis xyz="0 1 0"/>
    6.     <limit effort="176.4" lower="-1.1344" upper="2.5307" velocity="6.7195"/>
    7.   </joint>
    and you could rotate the link by 90 degrees using the "rpy" in the origin field

    Code (CSharp):
    1.  <joint name="joint_2" type="revolute">
    2.     <parent link="link_1"/>
    3.     <child link="link_2"/>
    4.     <origin rpy="0 1.57 0" xyz="0.040 0 0"/>
    5.     <axis xyz="0 1 0"/>
    6.     <limit effort="176.4" lower="-1.1344" upper="2.5307" velocity="6.7195"/>
    7.   </joint>
    Please let us know if it makes sense to you?
     
    agru likes this.