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

[SW-2049] ability to stream joint gains through hardware interface #588

Merged
merged 2 commits into from
Feb 25, 2025

Conversation

khughes-bdai
Copy link
Collaborator

@khughes-bdai khughes-bdai commented Feb 20, 2025

Change Overview

Adds k_q_p and k_qd_p to the command interface of Spot's hardware interface.These get set to an initial value via the initial_value field from the URDF, so existing logic here in the hardware interface to parse this input has been removed in favor of this new method. Existing controllers will not need to change anything, as they simply don't claim the interface.

The following PR in the stack will set up a controller to allow users to easily change this at runtime.

This PR also depends on the changes from bdaiinstitute/spot_description#3 to expose these new command interfaces in the URDF.

Testing Done

The default behavior from the user interface does not change with this PR.

  • Tested wiggle arm example successfully on robot with default gains
  • Tested wiggle arm example with different initial gains, verified that robot behavior adjusts accordingly
    \

Copy link
Collaborator Author

khughes-bdai commented Feb 20, 2025

@coveralls
Copy link

coveralls commented Feb 20, 2025

Pull Request Test Coverage Report for Build 13526106956

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.4%) to 52.917%

Totals Coverage Status
Change from base Build 13499858671: 0.4%
Covered Lines: 1968
Relevant Lines: 3719

💛 - Coveralls

Copy link
Collaborator

@mhidalgo-bdai mhidalgo-bdai left a comment

Choose a reason for hiding this comment

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

Looks about right. Need a controller to test.

Katie Hughes added 2 commits February 25, 2025 11:45
Signed-off-by: Katie Hughes <khughes-bdai@theaiinstitute.com>
Signed-off-by: Katie Hughes <khughes-bdai@theaiinstitute.com>
@khughes-bdai khughes-bdai force-pushed the khughes/SW-2049-stream-joint-gains branch from f2b6813 to 749ed00 Compare February 25, 2025 16:45
Copy link
Collaborator Author

merging this in now as i verified that the user interface stays the same, will keep working on the follow up controller separately

Copy link
Collaborator Author

khughes-bdai commented Feb 25, 2025

Merge activity

  • Feb 25, 12:48 PM EST: A user started a stack merge that includes this pull request via Graphite.
  • Feb 25, 12:48 PM EST: A user merged this pull request with Graphite.

@khughes-bdai khughes-bdai merged commit 37de15b into main Feb 25, 2025
5 checks passed
@khughes-bdai khughes-bdai deleted the khughes/SW-2049-stream-joint-gains branch February 25, 2025 17:48
Comment on lines +267 to +275
for (size_t i = 0; i < njoints_; i++) {
// copy over current position, velocity, and load from state to current command
hw_commands_[command_interfaces_per_joint_ * i] = hw_states_[state_interfaces_per_joint_ * i];
hw_commands_[command_interfaces_per_joint_ * i + 1] = hw_states_[state_interfaces_per_joint_ * i + 1];
hw_commands_[command_interfaces_per_joint_ * i + 2] = hw_states_[state_interfaces_per_joint_ * i + 2];
// Fill in k_q_p and k_qd_p gains from the initial_value field from the URDF
const auto& joint = info_.joints.at(i);
hw_commands_[command_interfaces_per_joint_ * i + 3] = std::stof(joint.command_interfaces.at(3).initial_value);
hw_commands_[command_interfaces_per_joint_ * i + 4] = std::stof(joint.command_interfaces.at(4).initial_value);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we could replace the hard-coded offsets with pos_offset = 0, vel_offset = 1, load_offset = 2, ... to make it easier to parse and don't assume or rely on remembering a known order in the code.

Comment on lines +293 to +295
joint_commands_.load.at(i) = hw_commands_[command_interfaces_per_joint_ * i + 2];
joint_commands_.k_q_p.at(i) = hw_commands_[command_interfaces_per_joint_ * i + 3];
joint_commands_.k_qd_p.at(i) = hw_commands_[command_interfaces_per_joint_ * i + 4];
Copy link
Contributor

@robodreamer robodreamer Feb 28, 2025

Choose a reason for hiding this comment

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

With the constants defined for the offsets, all these lines will not rely on a specific ordering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants