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

calcJacobianTransformErrorDiff sign change #1020

Closed
marrts opened this issue Jul 12, 2024 · 4 comments
Closed

calcJacobianTransformErrorDiff sign change #1020

marrts opened this issue Jul 12, 2024 · 4 comments

Comments

@marrts
Copy link
Contributor

marrts commented Jul 12, 2024

I'm not entirely sure if this is a bug or expected behavior since I'm not super well versed in Jacobians, but I think this is a bug that isn't captured correctly.

In running trajopt I am getting a failure that looks like this: (also noticed opposite has a typo, but it made the error easy to track down lol)

calcJacobianTransformErrorDiff, angle axes are pointing in oposite directions!

This error is located here. Copied below for convenience.

Eigen::VectorXd calcJacobianTransformErrorDiff(const Eigen::Isometry3d& target,
                                               const Eigen::Isometry3d& source,
                                               const Eigen::Isometry3d& source_perturbed)
{
  Eigen::Isometry3d pose_err = target.inverse() * source;
  std::pair<Eigen::Vector3d, double> pose_rotation_err = calcRotationalErrorDecomposed(pose_err.rotation());
  Eigen::VectorXd err = concat(pose_err.translation(), pose_rotation_err.first * pose_rotation_err.second);

  Eigen::Isometry3d perturbed_pose_err = target.inverse() * source_perturbed;
  std::pair<Eigen::Vector3d, double> perturbed_pose_rotation_err =
      calcRotationalErrorDecomposed(perturbed_pose_err.rotation());

  // They should always pointing in the same direction
#ifndef NDEBUG
  if (std::abs(pose_rotation_err.second) > 0.01 && perturbed_pose_rotation_err.first.dot(pose_rotation_err.first) < 0)
    throw std::runtime_error("calcJacobianTransformErrorDiff, angle axes are pointing in oposite directions!");
#endif

Attaching a debugger I see my errors evaluate as:

// value = {axis, angle}
pose_rotation_error           = {[ 3.1016e-5,  1.896e-5, -0.9999999],  2.09439}
perturbed_pose_rotation_error = {[-3.5380e-5, -1.794e-5,  0.9999999], -2.09439}

These angles seem to be almost identical, just a singularity because of how the angle is represented.

Here are a couple of screenshots of the robot and the TCP at the approximate joint values where this calculation was being performed:
image
image

I know there was an effort to fix Jacobian related issues in #988 and I'm wondering if this scenario might have just been overlooked.

@marrts
Copy link
Contributor Author

marrts commented Jul 12, 2024

2.09439 radians

It's worth mentioning that this is an angle of 120 degrees, which will have some unique, weird properties

@Levi-Armstrong
Copy link
Contributor

So this is a bug. The angle axis is pointing in opposite directions. Can you post the transform for the three inputs to create a unit test to track down the issue?

@Levi-Armstrong
Copy link
Contributor

So I see I added the debug check but noticed there is an issue as the source and target converge but I didn't think it would cause issues with convergence but obviously I was wrong since you are seeing failures. I will post how to address this so you can test.

@marrts
Copy link
Contributor Author

marrts commented Jul 22, 2024

This seems to fix my issue, thanks!

@marrts marrts closed this as completed Jul 22, 2024
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

No branches or pull requests

2 participants