You are browsing as a guest. Sign up (or log in) to start making projects!

1h 13m 58s logged

Devlog3_RoboSnoop_10/06/26
FINALLY aligned the second slider with the first and completed the code for the calculation of the angle for the index finger (unfortunately we have been lied to, A-level mathematics is not completely useless):


#Find vector AB
  const BA = {
    x: A.x - B.x,
    y: A.y - B.y
  };
#Find vector  CB
  const BC = {
    x: C.x - B.x,
    y: C.y - B.y
  };
#Calculate the dot product
  const dotProduct =
    BA.x * BC.x +
    BA.y * BC.y;
#mod AB = (x^2 + y^2)^0.5
  const magnitudeBA =
    Math.sqrt(BA.x * BA.x + BA.y * BA.y);

  const magnitudeBC =
    Math.sqrt(BC.x * BC.x + BC.y * BC.y);
#dot product = modAB * mod BC cos theta (manipulate to calculate theta)
  const angle = Math.acos(
    dotProduct /
    (magnitudeBA * magnitudeBC)
  );

  return angle * 180 / Math.PI;
}

hands.onResults((results) => {

  if (!results.multiHandLandmarks.length) return;

  const hand = results.multiHandLandmarks[0];
#5, 6, 7 represent the different joints in the finger
  const indexAngle =
    getAngle(hand[5], hand[6], hand[8]);

  setAngleValue(indexAngle);

The next steps would be adding 3 more sliders for each of the fingers (and aligning them so that they aren’t floating everywhere), and hopefully accounting for another degree of freedom about the knuckle joint (right now there’s only one degree I calculated for so only one value of theta, but there’s 3 degrees of freedom about the index finger (not accounting for adduction and abduction) and I have to figure out how to work around that or incorporate it into RoboSnoop and ultimately Project Handy

  • Snoopsawg
0
1

Comments 0

No comments yet. Be the first!