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

Add example about using joint control components #2728

Open
wants to merge 1 commit into
base: gz-sim9
Choose a base branch
from

Conversation

scpeters
Copy link
Member

🎉 New feature

Demonstrate issues with joint control

Summary

I was struggling to use both JointVelocityCmd and JointVelocityReset components when controlling joints until I noticed the following comment in src/systems/physics/Physics.cc:

        // Only set joint velocity if joint force is not set.
        // If both the cmd and reset components are found, cmd is ignored.

To demonstrate this interaction I created two example plugins:

  • ResetJointVelocityNearPosition: this plugin sets the JointVelocityReset
    component to a fixed value when the measured joint position is near a trigger
    position. This can create a bouncing behavior of a pendulum if the trigger
    position is the bottom stable equilibrium.
  • PulseJointVelocityCommand: this plugin applies pulses of joint velocity
    commands as a square wave with a specified time period between pulses.

The example world includes three pendulum models:

  • On the far left, the pendulum has only the ResetJointVelocityNearPosition
    with a trigger position at the downward stable eqilibrium point. This exhibits
    a bouncing behavior.
  • On the far right, the pendulum has only the PulseJointVelocityCommand.
    It starts out stationary, then alternates between moving at constant velocity
    and swinging passively.
  • In the center, the pendulum has both plugins enabled and experiences pulses
    of constant velocity alternating with passive swinging and bouncing at the
    bottom.

Screen capture with dartsim:

example_joint_control_commands_dartsim.mov

Screen capture with dartsim without setting JointForceCmd

If you comment out PulseJointVelocityCommand.cc:67 which sets the JointForceCmd component to 0 during the inactive portion of the pulse, the velocity controller remains active with a velocity command of 0.

example_joint_control_commands_dartsim_without_force_cmd.mov

Bullet

There is an issue with bullet-featherstone; I will file that separately.

Test it

Follow the instructions in the example README to compile and run the examples

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.

@@ -0,0 +1,82 @@
/*
* Copyright (C) 2024 Open Source Robotics Foundation
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Copyright (C) 2024 Open Source Robotics Foundation
* Copyright (C) 2025 Open Source Robotics Foundation

## Build

~~~
cd examples/plugin/reset_plugin
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cd examples/plugin/reset_plugin
cd examples/plugin/joint_control_components

<!-- This example uses the ResetJointVelocityNearPosition to reset the joint
velocity to a positive value when it is near the stable equilibrium
position. The joint appears to bounce upward near the bottom of its
swing.
Copy link
Contributor

Choose a reason for hiding this comment

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

also mention PulseJointVelocityCommand?

@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)

project(BouncePlugins)
Copy link
Contributor

Choose a reason for hiding this comment

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

JointControlPlugins?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏛️ ionic Gazebo Ionic
Projects
Status: Inbox
Development

Successfully merging this pull request may close these issues.

2 participants