Joint angle information from Rigid Body Data

NatNet, VRPN, TrackD, and Plugins
Post Reply
Student09
Posts: 4
Joined: Sun Feb 08, 2009 4:09 am

Joint angle information from Rigid Body Data

Post by Student09 »

Hello

I am using Optitrack system to track the motion of user's arm real time. I want to get joint angle information (in contrast to marker position info). I have calibrated my point cloud data to form a set of rigid bodies using Arena Software.

I am having difficulties in using Sampleclient.cpp to write my streaming data to a file.
I get the following error message:
Unable to connect to server. Host not present. Exiting.
The procedure i follow is:
Arena>Load .pt2 data
Arena>Stream Data
Execute Sampleclient.cpp

If i try running the Sampleclient3d file, it runs fine and outputs the openGL model.
1. What am i doing wrong in writing to a file.
2. Can i manipulate marker data from sampleclient3d.cpp to get joint angle information real-time. Please point me in the specific direction.

Thanks
Student09
Posts: 4
Joined: Sun Feb 08, 2009 4:09 am

Re: Joint angle information from Rigid Body Data

Post by Student09 »

Having delved more in the second part of the question, my query now is :

How to get joint angle description from Quaternion data of rigid body.
I have six markers on the arm, three on the upper arm and three on the wrist. I form two rigid bodies and stream the rigid body data to an OpenGL model. Thus i have quaternion info as well as x, y and z cartesian info of the rigid body.
Will an axis angle conversion from quaternion work?

I have a demo in less than a month and would greatly appreciate any help

Regards
morgan
NaturalPoint Employee
NaturalPoint Employee
Posts: 199
Joined: Tue Jun 24, 2008 2:01 pm
Location: Corvallis, OR, USA
Contact:

Re: Joint angle information from Rigid Body Data

Post by morgan »

Hey Student,

Regarding the "host not present" eror, this indicates the client was unable to connect to Arena. If the OpenGL sample is working, check your code against (server IP, client IP) it to make sure you are connecting to Arena.

Regarding real-time joint angle data, yes - the OpenGL sample is receiving and displaying real-time data in the callback function. this data conatins joint angle and joint position information. you should be able to use any stndard routine to convert from quaternion to eulers or axis-angle.

Let us know if you are unable to get the conversions working correctly and perhaps we can provide you with some sample routines.

Hope this helps.

Morgan
morgan
NaturalPoint Employee
NaturalPoint Employee
Posts: 199
Joined: Tue Jun 24, 2008 2:01 pm
Location: Corvallis, OR, USA
Contact:

Re: Joint angle information from Rigid Body Data

Post by morgan »

Here's a forum topic that discusses the quaternions a little more, along with some conversion code from Quats to Eulers.

http://forum.naturalpoint.com/forum/ubb ... mber=32176
Student09
Posts: 4
Joined: Sun Feb 08, 2009 4:09 am

Re: Joint angle information from Rigid Body Data

Post by Student09 »

Hello

Thanks for your reply.

Can you point me to the line of code in the sampleclient3D file where i can obtain joint angle and joint angle information.
I am using the Arena software and wish to obtain joint angle info for two rigid bodies (the arm and the wrist/forearm).

Regards
morgan
NaturalPoint Employee
NaturalPoint Employee
Posts: 199
Joined: Tue Jun 24, 2008 2:01 pm
Location: Corvallis, OR, USA
Contact:

Re: Joint angle information from Rigid Body Data

Post by morgan »

Here's the important code from SampleClient3D:

1. Tell NatNet to deliver data to your callback function:

Code: Select all

  natnetClient.SetDataCallback( DataHandler );
2. Receive data (position and orientation) in your callback function:

Code: Select all

// DataHandler receives data from the server
void __cdecl DataHandler(sFrameOfMocapData* data, void* pUserData)
{
	NatNetClient* pClient = (NatNetClient*) pUserData;

	printf("Received frame %d\n", data->iFrame);
	if(fp)
		_WriteFrame(fp,data);
	int i=0;

	// Other Markers
	printf("Other Markers [Count=%d]\n", data->nOtherMarkers);
	for(i=0; i < data->nOtherMarkers; i++)
	{
		printf("Other Marker %d : %3.2f\t%3.2f\t%3.2f\n",
			i,
			data->OtherMarkers[i][0],
			data->OtherMarkers[i][1],
			data->OtherMarkers[i][2]);
	}

	// Rigid Bodies
	printf("Rigid Bodies [Count=%d]\n", data->nRigidBodies);
	for(i=0; i < data->nRigidBodies; i++)
	{
		printf("Rigid Body [ID=%d]\n", data->RigidBodies[i].ID);
		printf("\tx\ty\tz\tqx\tqy\tqz\tqw\n");
		printf("\t%3.2f\t%3.2f\t%3.2f\t%3.2f\t%3.2f\t%3.2f\t%3.2f\n",
			data->RigidBodies[i].x,
			data->RigidBodies[i].y,
			data->RigidBodies[i].z,
			data->RigidBodies[i].qx,
			data->RigidBodies[i].qy,
			data->RigidBodies[i].qz,
			data->RigidBodies[i].qw);

		printf("\tRigid body markers [Count=%d]\n", data->RigidBodies[i].nMarkers);
		printf("\tx\ty\tz\n");
		for(int iMarker=0; iMarker < data->RigidBodies[i].nMarkers; iMarker++)
		{
			printf("\t%3.2f\t%3.2f\t%3.2f\n",
				data->RigidBodies[i].Markers[iMarker][0],
				data->RigidBodies[i].Markers[iMarker][1],
				data->RigidBodies[i].Markers[iMarker][2]);
		}
	}


}
Joint angle information is delivered as a quaternion, in:

data->RigidBodies.qx,
data->RigidBodies.qy,
data->RigidBodies.qz,
data->RigidBodies.qw);

Hope this helps,

Morgan
Student09
Posts: 4
Joined: Sun Feb 08, 2009 4:09 am

Re: Joint angle information from Rigid Body Data

Post by Student09 »

Thanks Morgan,

Please correct me if i am wrong in saying this:
We can obtain euler angles for each rigid body w.r.t the global frame. Joint angles are the angles between two sets of rigid bodies (say the elbow flexion angle between the forearm and upper arm). Thus, to obtain the Joint angles we simply subtract the euler angles (which are w.r.t global frame) of one rigid body from the euler angles of the second rigid body.

I followed your advice and checked my sampleclient code against the SampleClient3d settings. The server and client ip address are both set to 127.0.0.1 in the sampleclient3d
When i edit my sampleClient.cpp code to include:
char szMyIPAddress[128] = "127.0.0.1";
char szServerIPAddress[128] = "127.0.0.1";

I still get stuck in the following line of code.
if(!ServerDescription.HostPresent)
{
printf("Unable to connect to server. Host not present. Exiting.");
return 1;
}
My OpenGL code runs but i cannot get the "sampleclient.cpp" to write the data to a file.
On the console i get the error:
[Client]:Received command from 158.132.75.26, Command=5623
Unable to connect to server. Host not present.

Please share your insights into what i maybe doing wrong.

Regards

Student
Post Reply