WorldViz User Forum  

Go Back   WorldViz User Forum > Plug-in development

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-23-2012, 08:07 AM
pwsnow pwsnow is offline
Member
 
Join Date: Apr 2012
Posts: 23
HapticMaster + Vizard 4.0 SDK help

Hi everyone, I’m currently assessing Vizard in order to decide if our team should purchase a license. I have downloaded the demo copy but I have to get an external (unsupported) device working with it before we decide to purchase a copy.

The device I am using for my work is the Moog FCS HapticMaster. Basically it’s a big robot arm that interacts with a virtual world like a mouse but provides haptic feedback. I created a demo app using Ogre (graphics engine) and since that was in C++ I could easily integrate the HapticMaster to get the end effector arm xyz co-ordinates and use that to control a simple model.
I understand that this device isn’t supported officially in Vizard 4.0, but I’m looking to write my own plug in. I’m having difficulty understanding some of the instructions here: http://docs.worldviz.com/vizard/VizH...ementation.htm so I thought I would ask here for some pointers. I’ll explain below how I usually interface with the HapticMaster so that it helps explain the situation better.


When creating the Ogre application to use the HapticMaster end effector xyz position. All I did was include all the HapticMaster API header files and merge parts of one of the HapticMaster examples with the Ogre app. In this case sending/receiving commands to the HapticMaster (via a String command, yeah not my choosing!) and then splitting the String into the xyz values followed by assigning it to the movement of the model. So all the code is in one .cpp file calling the .h file sending command to the HapticMaster. My main problem is getting my head round doing this with the Vizard SDK.


I know that I have to include the HapticMaster.h/lib files etc
I have the code to get the position of the arm in C++ and have saved these as a double (xyz) but might have to put them in Vizards float.
I know I have to make these values available to my .viz python code.
But I can’t find any clear decent guides on how to do this within the Vizard SDK or how I would use the resulting files in a .viz file.

Any help or pointers will be gladly received! Let me know if there is anything I can do to further explain etc

Below is a section of the Ogre code I wrote, hope it is of some use to point me in the right direction to get started! Thanks

Code:
bool TutorialApplication::processUnbufferedInput(const Ogre::FrameEvent& evt)
{
	static bool mMouseDown = true;     // If a mouse button is depressed
    static Ogre::Real mToggle = 0.0;    // The time left until next toggle
    static Ogre::Real mRotate = 0.13;   // The rotate constant
    static Ogre::Real mMove = 150;      // The movement constant set at 250


	Ogre::Vector3 transVector = Ogre::Vector3::ZERO;

	double EEPos[3] = {0.0, 0.0, 0.0};

	double pot1dir;
	double pot2dir;
	double pot3dir;
	

	//transVector.z -= mMove;
	//transVector.z += mMove;

	/*
	// Get The Current EndEffector Position From THe HapticMASTER
	if ( haSendCommand( dev, "get measpos", response ) ) {
		printf("--- ERROR: Could not query current position");
	}
	else {
		ParseFloatVec( response, CurrentPosition[PosX], CurrentPosition[PosY],
		CurrentPosition[PosZ] );
	}


	SampleNr++;
	if (SampleNr >= MaxSamples)
		SampleNr = 0;

*/
	//if statement from page 94 of the Moog HapticAPI Programming Manual to get the XYZ pos of the end effector
	if ( haSendCommand ( dev, "get measpos", response ) ) {
		printf("--- ERROR: Could not query current position");
	}
	else {
		ParseFloatVec( response, CurrentPosition[PosX], CurrentPosition[PosY], CurrentPosition[PosZ] );
		//ParseFloatVec( response, ParamSamples[0] [SampleNr], ParamSamples[1] [SampleNr], ParamSamples[2] [SampleNr] );
	}

	/*

	//if statement to get the gimbal position 1 direction
	if ( haSendCommand ( dev, "get pot1dir", response ) ) {
		printf("--- ERROR: Could not query current position");
	}
	else {
		ParseFloatVec( response, pot1dir[PosX], pot1dir[PosY], pot1dir[PosZ]);
		//ParseFloatVec( response, ParamSamples[0] [SampleNr], ParamSamples[1] [SampleNr], ParamSamples[2] [SampleNr] );
	}

	*/
	
	//EEPos[0] = ParamSamples[0][SampleNr];
	//EEPos[0] = response[0];
	//EEPos[0] = CurrentPosition[PosX];
	//EEPos[1] = ParamSamples[1] [SampleNr];
	//EEPos[1] = response[1];
	//EEPos[1] = CurrentPosition[PosY];
	//EEPos[2] = ParamSamples[2] [SampleNr];
	//EEPos[2] = response[2];
	//EEPos[2] = CurrentPosition[PosZ];
	

	//Code from Basic Tutorial 4

	//if (mKeyboard->isKeyDown(OIS::KC_I)) // Forward
	if (CurrentPosition[PosX] > 0 & (mKeyboard->isKeyDown( OIS::KC_LSHIFT ))) // Forward ADDED LSHIFT DOWN TO DEBUG - REMOVE + EXTRA ()'S
	//if (EEPos[0] > 0.0) // Forward
    {
        //transVector.z -= mMove;
		transVector.z += mMove;
    }
    //if (mKeyboard->isKeyDown(OIS::KC_K)) // Backward
	if (CurrentPosition[PosX] < 0 & (mKeyboard->isKeyDown( OIS::KC_LSHIFT ))) // Backward ADDED LSHIFT DOWN TO DEBUG - REMOVE + EXTRA ()'S
	//if (EEPos[0] < 0.0) // Backward
    {
        //transVector.z += mMove;
		transVector.z -= mMove;
    }
    //if (mKeyboard->isKeyDown(OIS::KC_J)) // Left - yaw or strafe
	if (CurrentPosition[PosY] < 0) // Left - yaw or strafe
    {
        if(mKeyboard->isKeyDown( OIS::KC_LSHIFT ))
        {
            // Yaw left
            //mSceneMgr->getSceneNode("headNode")->yaw(Ogre::Degree(mRotate * 5));
			transVector.x -= mMove; // MOVE THIS INTO ELSE ONLY USED HERE FOR DEBUG
        } else {
			//transVector.x -= mMove;
        }
    }
    //if (mKeyboard->isKeyDown(OIS::KC_L)) // Right - yaw or strafe
	if (CurrentPosition[PosY] > 0) // Right - yaw or strafe
    //if (EEPos[1] > 0.0) // Right - yaw or strafe
    {
        if(mKeyboard->isKeyDown( OIS::KC_LSHIFT ))
        {
            // Yaw right
            //mSceneMgr->getSceneNode("headNode")->yaw(Ogre::Degree(-mRotate * 5));
			transVector.x += mMove; // MOVE THIS INTO ELSE ONLY USED HERE FOR DEBUG
        } else {
            //transVector.x += mMove; // Strafe right
			//transVector.x += mMove;
        }
    }
    //if (mKeyboard->isKeyDown(OIS::KC_U)) // Up
	if (CurrentPosition[PosZ] > 0 & (mKeyboard->isKeyDown( OIS::KC_LSHIFT ))) // Up ADDED LSHIFT DOWN TO DEBUG - REMOVE + EXTRA ()'S
	//if (EEPos[2] > 0.0) // Up
    {
        //transVector.y += mMove;
		transVector.y += mMove;
    }
    //if (mKeyboard->isKeyDown(OIS::KC_O)) // Down
	if (CurrentPosition[PosZ] < 0 & (mKeyboard->isKeyDown( OIS::KC_LSHIFT ))) // Down ADDED LSHIFT DOWN TO DEBUG - REMOVE + EXTRA ()'S
	//if (EEPos[2] < 0.0) // Down
    {
        //transVector.y -= mMove;
		transVector.y -= mMove;
    }






	
	//headNode->move(CurrentPosition[PosX], CurrentPosition[PosY], CurrentPosition[PosZ]);
	 

	mSceneMgr->getSceneNode("headNode")->translate(transVector * evt.timeSinceLastFrame, Ogre::Node::TS_LOCAL);

    return true;


}
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Realistic Light and Shadows Using Vizard and 3DS Max jde Vizard 4 07-13-2012 11:58 AM
Vizard 4 Beta Testing farshizzo Announcements 0 02-01-2011 11:46 AM
Vizard 4 Beta Testing farshizzo Vizard 0 02-01-2011 11:46 AM
.3DS importing in Vizard and 3D Studio jde Vizard 1 08-28-2009 04:14 PM
Vizard tech tip: Using the Python Imaging Library (PIL) Jeff Vizard 0 03-23-2009 12:13 PM


All times are GMT -7. The time now is 02:31 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC