CHAI3DCHAI3D

normal Porting from version 2.0 to 3.1.1

More
04 Mar 2016 12:44 #1

Hi,

I'm working on porting my chai3d application made in 2.0.0 to 3.1.1. I see bunch of modification on already existing classes. Great if someone can help me to come over some basic issues.
1. How can we access each component of vector in chai3d 3.1.1?. For ex. in 2.0.0 we can simply call

cVector3d pos; double val = pos1.x
2. What exactly need to be done in order to display a string?. I did something like this in 2.0.0
labels[deviceID]->m_string = strLabel;
but I see in 3.1.1 there is 'm_text'.

Very helpful if someone can give a suggestion on that.
Thank you!

Please Log in or Create an account to join the conversation.

More
04 Mar 2016 23:23 #2

Here is some code to access vector components using x,y and z references:

    cVector3d myVector;

    // assign values
    myVector.x(1.0);
    myVector.y(2.0);
    myVector.z(3.0);

    // retrieve values
    double x = myVector.x();
    double y = myVector.y();
    double z = myVector.z();


Another way to access a vector's components is by using indices:
    // assign values
    myVector(0) = 1.0;
    myVector(1) = 2.0;
    myVector(2) = 3.0;

    // retrieve values
    double x = myVector(0);
    double y = myVector(1);
    double z = myVector(2);


Assigning a string to a label can be performed with the following code:
    string myString = "hello world";
    myLabel->setText(myString);

Please Log in or Create an account to join the conversation.

More
06 Mar 2016 20:28 #3

Thank you very much!

Please Log in or Create an account to join the conversation.

More
07 Mar 2016 11:19 #4

Hi,

It would be very helpful if you can suggest a solution for this,

I've made a very basic haptic application using chai3d 2.0.0, now I'm porting everything into 3.1.0. But still getting some issues, not sure where I'm wrong but I suspect it's somewhere in 'updatehaptics'.

This is how I manged to do few manipulations in updatehaptics:

 hapticDevice[0]->getPosition(newPosition1);
 hapticDevice[1]->getPosition(newPosition2);
// read orientation of haptic devices 1, 2
           
 hapticDevice[0]->getRotation(newRotation1);
 hapticDevice[1]->getRotation(newRotation2);

// read linear velocity from devices 1,2
 hapticDevice[0]->getLinearVelocity(linearVelocity1);
 hapticDevice[1]->getLinearVelocity(linearVelocity2);
 linearVelocity1.x(0.0);
 linearVelocity2.x(0.0);


  // update position and orientation of cursors
cursors[0]->setLocalPos(newPosition1);
cursors[1]->setLocalPos(newPosition2);
cursors[0]->setLocalRot(newRotation1);
cursors[1]->setLocalRot(newRotation2);

startPosition1=starts[0]->getLocalPos();
startPosition2=starts[1]->getLocalPos();

targetPosition1=targets[0]->getLocalPos();
targetPosition2=targets[1]->getLocalPos();

viaPosition1 = via[0]->getLocalPos();
viaPosition2 = via[1]->getLocalPos();

 //distance from an invisible via point
			
viadist1 =  (newPosition1.y() - viaPosition1.y())*(newPosition1.y() - viaPosition1.y())+
	    (newPosition1.z() - viaPosition1.z())*(newPosition1.z() - viaPosition1.z());
	if (viadist1 < minviadist1)
	minviadist1 = viadist1;

viadist2 =  (newPosition2.y() - viaPosition2.y())*(newPosition2.y() - viaPosition2.y())+
	    (newPosition2.z() - viaPosition2.z())*(newPosition2.z() - viaPosition2.z());
	if (viadist2 < minviadist2)
	minviadist2 = viadist2;

I have implemented state transition based on cursor position, velocity etc. But after changing to 3.1.0 it's not working anymore , so I guess that might be issue manipulating position, velocity etc?

Thank you!

Please Log in or Create an account to join the conversation.

More
07 Mar 2016 12:53 #5

Please check that your haptic devices are correctly communicating with CHAI3D. The 02-multi-devices examples is a good application for that.

The next step would be to display to screen the positions that you are getting.

Please Log in or Create an account to join the conversation.

More
07 Mar 2016 14:09 #6

Thank you so much. It's working now

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum