Kinect Angles Calculation Script: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
No edit summary
Line 21: Line 21:


== Extracting Data from Kinect Input ==  
== Extracting Data from Kinect Input ==  
The data needed is calculated from an array of <code>Joint</code> objects from the closest skeleton tracked by the Kinect sensor by the function <code>GetArmAngles</code>. It returns an 14 sized array of <code>double</code>'s representing the 14 angles calculated, 7 per arm. Below and excerpt of this function is given in which the angles for the left arm are calculated. For an explanation, see the [http://cstwiki.wtb.tue.nl/index.php?title=PRE2015_4_Groep1#Extracting_data_from_the_Kinect_sensor mathematical explanation] mentioned before. Note that the vectors are given more human-readable names like 'a'. Vectors pointing from one joint to the other are often given a name using a standard format. For example, the vector <code>sh2elL</code> is the vector pointing from the left <code>sh</code>oulder <code>to</code> the left <code>el</code>bow. The <code>L</code> is used to indicate that this vector belongs to the calculation of angles for the <code>L</code>eft arm.
The data needed is calculated from an array of <code>Joint</code> objects from the closest skeleton tracked by the Kinect sensor by the function <code>GetArmAngles</code>. It returns an 14 sized array of <code>double</code>'s representing the 14 angles calculated, 7 per arm. Below and excerpt of this function is given in which the angles for the left arm are calculated. For an explanation, see the [http://cstwiki.wtb.tue.nl/index.php?title=PRE2015_4_Groep1#Extracting_data_from_the_Kinect_sensor mathematical explanation] mentioned before. Note that the vectors are given more human-readable names than the short ' '''a''' '. Vectors pointing from one joint to the other are often given a name using a standard format. For example, the vector <code>sh2elL</code> is the vector pointing from the left <code>sh</code>oulder <code>to</code> the left <code>el</code>bow. The <code>L</code> is used to indicate that this vector belongs to the calculation of angles for the <code>L</code>eft arm.

Revision as of 18:29, 20 June 2016

This is a brief explanation of code used to convert Kinect input from the Joints structure into the degrees of freedom of the AMIGO's arms.

This code is part of a project to create a robot technique that allows users to hug someone when separated by a disctance like a phone call.

For a mathmatical explanation of how the degrees of freedom are determined, check this section of the project.

Vectors and Vector Manipulation

As c++ does not provide a standard library for 3 dimensional vectors and vector manipulations, we made our own Vector3 class that gives the user access to its coördinates and contains a function that returns the length of the vector. This code is not contained here but can be read in the full code that can be downloaded from this wiki page.

Several manipulations on 3 dimensional vectors can be found in the same class that also converts the Kinect input into useable data. These are:

  • subtractV, a function that returns a Vector3 that is a difference vector pointing from one CameraSpacePoint to another CameraSpacePoint.
  • angleV, a function that returns the angle between two vectors, calculated using the vector dot product.
  • dotV, a function that returns the dot product between two vectors.
  • crossV, a function that returns the cross product between two vectors.
  • projectPlaneV, a function that returns the projection of a vector onto a plane given by that plane's normal vector.
  • projectVectorV, a function that projects a vector onto another vector.
  • normalizedV, a function that returns a vector with the same direction of the input vector, but with length one.
  • converseV, a function that returns the converse of the input vector, the vector multiplied by -1.

Extracting Data from Kinect Input

The data needed is calculated from an array of Joint objects from the closest skeleton tracked by the Kinect sensor by the function GetArmAngles. It returns an 14 sized array of double's representing the 14 angles calculated, 7 per arm. Below and excerpt of this function is given in which the angles for the left arm are calculated. For an explanation, see the mathematical explanation mentioned before. Note that the vectors are given more human-readable names than the short ' a '. Vectors pointing from one joint to the other are often given a name using a standard format. For example, the vector sh2elL is the vector pointing from the left shoulder to the left elbow. The L is used to indicate that this vector belongs to the calculation of angles for the Left arm.