Skip to content

Commit

Permalink
Fixes misidentification of flipped parts on kit trays (#349)
Browse files Browse the repository at this point in the history
* Fix to flip issue

* Fixed issue with part rotation on kitting trays
  • Loading branch information
jfernandez37 authored May 23, 2024
1 parent a4927c5 commit fce8690
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ariac_plugins/include/ariac_plugins/ariac_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2289,15 +2289,19 @@ namespace ariac_common
*/
bool isFlipped()
{
KDL::Frame part_on_tray;
tf2::fromMsg(pose_on_tray_, part_on_tray);
KDL::Vector part_z = part_on_tray * KDL::Vector(0, 0, 1);
KDL::Rotation part_rotation = KDL::Rotation::Quaternion(
pose_on_tray_.orientation.x,
pose_on_tray_.orientation.y,
pose_on_tray_.orientation.z,
pose_on_tray_.orientation.w);

KDL::Vector part_z = KDL::Frame(part_rotation) * KDL::Vector(0, 0, 1);

// Calculate the angle between the two vectors
double angle = KDL::acos(KDL::dot(KDL::Vector(0, 0, 1), part_z) / (part_z.Norm()));

// Return that the part is flipped if angle is greater than ~10deg
if (angle > -0.2 && angle < 0.2)
if (angle > -0.20 && angle < 0.20)
{
return false;
}
Expand Down

0 comments on commit fce8690

Please sign in to comment.