Monthly Archives: April 2014

Using C++ and C# together to convert angles

A problem that I encountered during the project is that the Kondo program is written in C++ and the Kinect XNA program is written in C#.

The solution for this was to send angle data collected by the Kinect camera, and write the values to a text file for each of the joints using streamwriter in C#. Then in the Kondo program, use iostream reader to read to strings, convert them to an integer value and then apply a formula that would convert the kinect angles to the kondo angles for the correct movement.

 

The formula used found using these basic steps:

  1. Find the angles in the kondo for the joints. For example, the arm at a vertical in the kondo would be 2500 for the left side, 7500 for a horizontal position, and 10000 when the arm is by the side of the robot (down position).
  2. Find the angle values for the same position in kinect, so verticle position for the left arm is 15, horizontal position for the arm is 30, and arm down by the side is 100.

Once these values were collected we need an average angle, because the kondo arm has to move constantly and there is not a fixed position. Therefore we can apply this formula:

Position = (Sum of all Kondo angles) / (Sum of all Kinect angles) / 3 . This will give the conversion between the kondo angle ratio and the kinect angle ratio.

Therefore, (2500/15) + (7500/30) + (10000/100) = (517/3) = 170.

So the answer 170 means that each of the kondo angles from the left arm needs to be multiplied by 170 to get the conversion to the kondo angle.

 

A working video can be seen below of this implementation: