gz-sim icon indicating copy to clipboard operation
gz-sim copied to clipboard

Prototype system for initializing model state

Open scpeters opened this issue 3 months ago • 5 comments

🎉 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 avatar Apr 04 '24 22:04 scpeters