Login
Username:

Password:


Lost Password?

Register now!
Main Menu
H3D.org Feeds
H3D.org Forum Index
   Programming Issues
     releaseDevice error?
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
bobbie
Posted on: 2009/12/2 11:01
Not too shy to talk
Joined: 2009/9/10
From: The Netherlands
Posts: 8
releaseDevice error?
When my application is closing it runs the destructor:


Form_Main::~Form_Main()
{
	//remove all programmer threads
	RemoveThreads();

	//release force
	hd.releaseDevice(); <----------------------

	//move robot to homing point
	myRobot->InitialiserenRobotFast();
}


But sometimes it hangs on hd.releaseDevice();
What's wrong????

greets,

Bob van Ratingen
The Netherlands
Markus
Posted on: 2009/12/4 8:26
Webmaster
Joined: 2006/3/27
From: SenseGraphics
Posts: 1531
Re: releaseDevice error?
Where in the releaseDevice code does it hang? (Run in debug mode in visual studio if that is what you are using). Are you using your own device (myRobot?) or one of those which HAPI/H3DAPI has support for?
bobbie
Posted on: 2009/12/4 9:55
Not too shy to talk
Joined: 2009/9/10
From: The Netherlands
Posts: 8
Re: releaseDevice error?
It hangs in DEBUG-mode and RELEASE-mode. myRobot is a REAL robot. Not important in this case. hd is a PhantomHapticsDevice.

I hope you can help me!

gr.

Bob van Ratingen
bobbie
Posted on: 2009/12/4 15:17
Not too shy to talk
Joined: 2009/9/10
From: The Netherlands
Posts: 8
Re: releaseDevice error?
I think i have found it. I must first release the hd and than remove the threads!

still thanks,

Bob
Markus
Posted on: 2009/12/4 16:36
Webmaster
Joined: 2006/3/27
From: SenseGraphics
Posts: 1531
Re: releaseDevice error?
That could be it. If your threads are calling functions which interferes with the haptics rendering (such as hd->getPosition or other get functions) then it might have been the cause of your problems. Or something like that. Maybe your thread was waiting for the haptics thread to finish while at the same time the haptics thread was waiting for yours to finish.
bobbie
Posted on: 2010/1/5 14:01
Not too shy to talk
Joined: 2009/9/10
From: The Netherlands
Posts: 8
Re: releaseDevice error?
I have the same problem again!

I have a thread (ThreadControlling). Below are the first 7 lines of this thread. In the 7th line, the thread wait until the button is pressed by a Phantom.

hd: PhantomHapticsDevice hd;

m_frame->ConsoleMessage("Controlling started");
m_frame->ConsoleMessage("Initializing Phantom");
m_frame->hd.initDevice(); 
m_frame->ConsoleMessage("Enable Phantom");
m_frame->hd.enableDevice();	
m_frame->ConsoleMessage("Click on the black button to initialize the robot!");
while(!m_frame->hd.getButtonStatus(0));


I start this thread with this function:

void Form_Main::StartControlling() 
{
	ConsoleMessage("Start Controlling!");

	threadStartControlling = CreateThread();
	if ( threadStartControlling->Run() != wxTHREAD_NO_ERROR )
	{
		ConsoleMessage("Can't start threadStartControlling!");
	}
}


and stop the thread with this function:

void Form_Main::StopControlling() 
{
	ConsoleMessage("Stop Controlling!");

	// Disable device.
	ConsoleMessage("Disable device!");
	hd.disableDevice();
	
	// Release device.
	ConsoleMessage("Release device");
	hd.releaseDevice();

	//remove all programmer threads (INCLUDE THE CONTROLLING one)
	RemoveThreads();
 
	ConsoleMessage("Threads KILLed");

	ConsoleMessage("Controlling stopped");
}


but some times when I start and stop sequence the program hangs on
hd.disableDevice();


This is because somtimes when the thread start it pass over
m_frame->ConsoleMessage("Enable Phantom");
m_frame->hd.enableDevice();


WHY???

THANK YOU SO MUCH!!!

gr Bob van Ratingen
Markus
Posted on: 2010/1/8 11:11
Webmaster
Joined: 2006/3/27
From: SenseGraphics
Posts: 1531
Re: releaseDevice error?
What do you mean with "pass over"? Does it skip the two lines you mention?

Where is this code located?
m_frame->ConsoleMessage("Controlling started");
m_frame->ConsoleMessage("Initializing Phantom");
m_frame->hd.initDevice(); 
m_frame->ConsoleMessage("Enable Phantom");
m_frame->hd.enableDevice();	
m_frame->ConsoleMessage("Click on the black button to initialize the robot!");
while(!m_frame->hd.getButtonStatus(0));


Is it in the constructor or in the thread function of the thread?
Threaded | Newest First Previous Topic | Next Topic | Top

Register To Post
 



(C) 2004 SenseGraphics AB    ---    Powered by XOOPS