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

Prototype system for initializing model state #2359

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

scpeters
Copy link
Member

@scpeters scpeters commented Apr 4, 2024

🎉 New feature

Closes #2318

Summary

This adds a system called SetModelState that accepts an xml configuration containing <model_state> tags intending to serve as a prototype for new syntax for the <state> tag in SDFormat 1.12. Currently, only <joint_state> tags are supported; support should also be added for <link_state>.

Example <model_state> syntax from examples/worlds/set_model_state.sdf

  • Using degrees
        <model_state>
          <joint_state name="j1">
            <axis_state>
              <position degrees="true">60</position>
              <velocity degrees="true">-30</velocity>
            </axis_state>
          </joint_state>
        </model_state>
  • Using radians
        <model_state>
          <joint_state name="j1">
            <axis_state>
              <position>1.047</position>
              <velocity>-0.523</velocity>
            </axis_state>
          </joint_state>
        </model_state>

Test it

gz sim -v 4 examples/worlds/set_model_state.sdf

The rotors should start at a 60 degree angle and rotate clock-wise at 30 degrees / second.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

scpeters added 4 commits April 4, 2024 00:00
This system sets initial joint position and velocity
states using an xml syntax that is a prototype for
the SDFormat 1.12 state specification.

Signed-off-by: Steve Peters <[email protected]>
Signed-off-by: Steve Peters <[email protected]>
@github-actions github-actions bot added the 🏛️ ionic Gazebo Ionic label Apr 4, 2024
@scpeters
Copy link
Member Author

For specifying link velocity, there has been a request to change the link_state specification for velocity to not use the pose type (see gazebosim/sdformat#1366). As mentioned in that issue, an alternative is to specify velocity as two vector3 types since there is no vector6 type in SDFormat and this avoids confusion about the order of the data.

<model_state>
  <link_state name="link1">
    <linear_velocity>{vx} {vy} {vz}</linear_velocity>
    <angular_velocity>{wx} {wy} {wz}</angular_velocity>
  </link_state>
</model_state>

@traversaro
Copy link
Contributor

Can this be used to set the model state of a model in which no gz-sim-set-model-state-system, for example to permit to have a generic model for a robot, that is include in a .world and in which world-specific positions are specified?

@scpeters
Copy link
Member Author

Can this be used to set the model state of a model in which no gz-sim-set-model-state-system, for example to permit to have a generic model for a robot, that is include in a .world and in which world-specific positions are specified?

Yes, I would like to push these syntax changes upstream to the the <state> specification in SDFormat 1.12. I'm treating this pull request and system as a prototype for those syntax changes.

@scpeters
Copy link
Member Author

One difference between this prototype and what we could achieve by updating the //world/state specification is that this plugin allows specifying the initial state of a model from within the //model element, whereas the //world/state element must be defined at the world level. I think it is convenient to set model state from within the model, so I would also propose adding a //model/state tag as well, which would add complexity and require defining an order or precedence, but I think it would be a valuable addition.

Adjust geometry slightly and set density to retain
the same mass values and approximately the same inertia
matrix.

Signed-off-by: Steve Peters <[email protected]>
@scpeters
Copy link
Member Author

I've updated the world file to use SDFormat 1.11 and auto-inertials in 7cab1bb

@azeey azeey added the beta Targeting beta release of upcoming collection label Jul 29, 2024
@azeey azeey removed the beta Targeting beta release of upcoming collection label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏛️ ionic Gazebo Ionic
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

4 participants