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

Spec 1.12: link_state, joint_state changes #1461

Merged
merged 21 commits into from
Aug 28, 2024
Merged

Conversation

scpeters
Copy link
Member

@scpeters scpeters commented Jul 20, 2024

🎉 New feature

Closes #1366, #83

Summary

This makes several changes to the specification for the <state/> element in SDFormat 1.12. It does not include DOM objects, which will be implemented in a future pull request. Note that part of the motivation for these changes is to allow specification of initial model state in gz-sim (see prototype in gazebosim/gz-sim#2359).

Link state changes

  • Use pairs of vector3 datatypes to represent twist, spatial acceleration, and wrenches instead of a pose datatype, which distorts the angular values by interpreting them as Euler angles. This resolves link_state velocity, acceleration, and wrench data should not use pose type #1366. The new elements for velocity and acceleration have names starting with linear_ or angular_, while the replacement for wrench is force and torque:
    • //link_state/linear_velocity
    • //link_state/angular_velocity
    • //link_state/linear_acceleration
    • //link_state/angular_acceleration
    • //link_state/force
    • //link_state/torque
  • Alternative considered: add support for a vector6 type and rename velocity to twist, acceleration to spatial_acceleration. While this could allow for shorter XML files, it would require features to be added to gz-math to support math::Vector6 and has the potential for error in remembering which order to specify the angular and linear coefficients. Using a pair of vector3 types is more verbose but more clear and is already supported by gz-math and libsdformat.

Joint state changes

  1. Add velocity, acceleration, and effort to //joint_state. The addition of velocity and acceleration was requested by add joint velocity and joint acceleration to state structure #83, and effort is added to match wrench used in link states.

Link and Joint states: add boolean @degrees attribute to some angular types

  • Add a boolean @degrees attribute to the following elements:
    • //link_state/angular_velocity
    • //link_state/angular_acceleration
    • //joint_state/axis_state/position
    • //joint_state/axis_state/velocity
    • //joint_state/axis_state/acceleration
    • //joint_state/axis2_state/position
    • //joint_state/axis2_state/velocity
    • //joint_state/axis2_state/acceleration
  • When true, this attribute causes the data to be interpreted in deg instead of rad, deg/s instead of rad/s, or deg/s^2 instead of rad/s^2. The attribute is not added to joint effort and link wrench types.

Allow specification of model state within a model

  • Currently states are only specified at the world level via the //world/state element. To allow a model to specify a default initial configuration or initial velocity, the //model/model_state element is added. If a world contains both a //world/state and a model that specifies its own state, I think the world state should take precedence.
  • To allow a model state to be overridden when being <include>d, the //model/include/model_state and //world/include/model_state elements are added as well.

Test it

The INTEGRATION_nested_model test has been updated to use some of the new //link_state elements, but there are not yet any tests using the new //joint_state or //model/model_state elements.

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.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Include joint_state.sdf from model_state.sdf
and state.sdf for //world/joint states.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
This deprecates the //joint_state/angle element in
favor of a joint state specification that supports
multi-axis joints by mirroring the //joint/axis and
//joint/axis2 elements with
* //joint_state/axis_state
* //joint_state/axis2_state

Each axis state can specify position, velocity, and
acceleration, each with an optional @Degrees attribute.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Deprecate the //link_state/velocity and
//link_state/acceleration elements since the `pose`
type is not well-suited to represent vector6 data.
Add pairs of vector3 angular_* and linear_* elements
for velocity and acceleration to replace the pose-typed
elements.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@azeey azeey added the beta Targeting beta release of upcoming collection label Jul 29, 2024
@azeey azeey requested a review from jennuine August 6, 2024 21:12
Base automatically changed from scpeters/state_1_12_suffix to main August 18, 2024 21:11
also rephrase some element descriptions

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@azeey azeey added the Breaking change Breaks API, ABI or behavior. Must target unstable version. label Aug 20, 2024
Also use a larger values in an angular_velocity.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
update migration guide

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@scpeters scpeters changed the base branch from main to sdf15 August 26, 2024 18:38
@scpeters scpeters added the 🏛️ ionic Gazebo Ionic label Aug 26, 2024
@scpeters scpeters marked this pull request as ready for review August 26, 2024 21:38
@scpeters scpeters requested a review from azeey as a code owner August 26, 2024 21:38
Migration.md Outdated
### Deprecations

1. **joint_state.sdf**:
+ `//joint_state/angle` is deprecated in favor of `//axis_state/position`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make it clear that it's still within joint_state.

Suggested change
+ `//joint_state/angle` is deprecated in favor of `//axis_state/position`
+ `//joint_state/angle` is deprecated in favor of `//joint_state/axis_state/position`

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will fix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migration.md Outdated
Comment on lines 686 to 687
+ `//link_state/wrench` is deprecated in favor of `//link_state/angular_wrench`
and `//link_state/linear_wrench`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've commonly seen the term wrench refer to the 6D vector that represents torques and forces. If we split them into two 3D vectors, would it make sense to call them torque and force instead of angular_wrench and linear_wrench?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that's a good point; I was trying to keep symmetry with angular_ and liner_ prefixes, but force and torque are better. I will update this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the pull request description with force and torque as well


<attribute name="degrees" type="bool" default="false" required="0">
<description>
If true, the joint position is expressed in units of degrees [deg],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you specify that this would not apply to prismatic joints and the unit will be meters regardless of this attribute?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


<attribute name="degrees" type="bool" default="false" required="0">
<description>
If true, the joint velocity is expressed in units of degrees per
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the position, can you add a qualifier for prismatic joints?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contains the state of the first joint axis.
</description>

<element name="position" type="double" default="0" required="0">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't position be a vector?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this position element is under //joint_state/axis_state and represents the position of the first axis / degree of freedom. there is another position element under //joint_state/axis2_state for the second axis. this mirrors the specification of the //joint/axis and //joint/axis2 elements

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@scpeters scpeters merged commit c2c4f91 into sdf15 Aug 28, 2024
12 checks passed
@scpeters scpeters deleted the scpeters/state_1_12 branch August 28, 2024 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Targeting beta release of upcoming collection Breaking change Breaks API, ABI or behavior. Must target unstable version. 🏛️ ionic Gazebo Ionic
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants