Skip to content

Sigma inverse edits#430

Merged
dellaert merged 20 commits into
masterfrom
sigma_inverse_edits
Jul 2, 2026
Merged

Sigma inverse edits#430
dellaert merged 20 commits into
masterfrom
sigma_inverse_edits

Conversation

@kshaji3

@kshaji3 kshaji3 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Notes:

  • This PR basically adds the ability to set custom joint prior sigmas, with the goal of being able to favor certain joint movements over others in inverse kinematics
  • Tested across C++ and Python

@kshaji3 kshaji3 requested a review from dellaert June 30, 2026 16:57
Comment thread gtdynamics/kinematics/KinematicsParameters.h Outdated
Comment thread gtdynamics/kinematics/KinematicsSlice.cpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for overriding the joint-angle prior noise model on a per-joint basis (by joint name) in kinematics inverse-kinematics solves, enabling users to “favor” certain joints by tightening/loosening their prior sigmas. It also adds C++ and Python regression tests demonstrating that looser gantry priors allow the gantry joints to absorb more motion in a redundant IK setup.

Changes:

  • Add KinematicsParameters::joint_prior_overrides plus setJointPriorSigma(joint_name, sigma) to override the default prior_q_cost_model for specific joints.
  • Update Kinematics::jointAngleObjectives<Slice> to use the per-joint override noise model when present.
  • Add Bar-Lab gantry sigma behavior tests in both C++ and Python.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/tests/test_forward_inv_kinematics.py Adds a Python test validating looser gantry priors increase gantry joint motion (but currently uses randomized initialization).
gtdynamics/kinematics/tests/testKinematicsSlice.cpp Adds a C++ test validating looser gantry priors increase gantry joint motion (but currently uses randomized initialization).
gtdynamics/kinematics/KinematicsSlice.cpp Uses per-joint prior override noise models when building joint-angle prior factors.
gtdynamics/kinematics/KinematicsParameters.h Introduces per-joint prior overrides and a helper setter.
gtdynamics.i Exposes setJointPriorSigma to the wrapper interface.

Comment on lines +172 to +182
slice0 = gtd.Slice(k)

# Total gantry travel from the zero prior mean for a given gantry sigma.
def gantry_travel(gantry_sigma):
params = gtd.KinematicsParameters()
for name in gantry_joints:
params.setJointPriorSigma(name, gantry_sigma)
result = gtd.Kinematics(params).inverse(
slice0, robot, pose_goals, gtsam.Values(), True)
return sum(abs(gtd.JointAngle(result, robot.joint(n).id(), k))
for n in gantry_joints)
Comment on lines +445 to +453
// Solve IK with the given gantry prior sigma; pose goal is a hard constraint.
auto solve = [&](double gantry_sigma) {
KinematicsParameters params;
params.method = OptimizationParameters::Method::AUGMENTED_LAGRANGIAN;
for (const auto& name : gantry_joints)
params.setJointPriorSigma(name, gantry_sigma);
return Kinematics(params).inverse(kSlice, robot, pose_goals, gtsam::Values(),
/*pose_goals_as_constraints=*/true);
};
Comment thread gtdynamics.i Outdated
double bv_cost_model_sigma = 1e-4,
double v_cost_model_sigma = 1e-4,
double cv_cost_model_sigma = 1e-2);
void setJointPriorSigma(string joint_name, double sigma);
@dellaert

dellaert commented Jul 1, 2026

Copy link
Copy Markdown
Member

Several co-pilot comments are valid, Please resolve them as you fix them, or deem them irrelevant - be honest though :-).

Except for very simple types like float, int etc. always use constant references (const &) in c++.

@dellaert

dellaert commented Jul 1, 2026

Copy link
Copy Markdown
Member

Also, CI fails :-/

Comment thread examples/example_constraint_manifold/main_arm_kinematic_planning.cpp Outdated
@dellaert dellaert merged commit fa1c990 into master Jul 2, 2026
6 checks passed
@dellaert dellaert deleted the sigma_inverse_edits branch July 2, 2026 07:44
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.

3 participants