RoboDK Forum
RoboDK crash when enabling SetCollisionActive- Printable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+ - - -论坛:RoboDK错误(//www.sinclairbody.com/forum/Forum-RoboDK-bugs)
+--- Thread: RoboDK crash when enabling SetCollisionActive (/Thread-RoboDK-crash-when-enabling-SetCollisionActive)



RoboDK crash when enabling SetCollisionActive-joebgold-03-16-2023

RoboDK crashes after calling SetCollisionActive in the API whenever there is already a collision happening or while a program is running. The crash seems to only occur whenever the existing collision's were found or whenever the program is started through the API functions.

This is the error message that appears when enabling SetCollisionActive:

Quote:System.Net.Sockets.SocketException: 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'


RoboDK v5.5.4
C# API


RE: RoboDK crash when enabling SetCollisionActive-Albert-03-16-2023

This issue looks specific to your project. It looks like the API times out, maybe because RoboDK takes too long to calculate collisions.

Can you share the RoboDK project file and steps for us to reproduce?


RE: RoboDK crash when enabling SetCollisionActive-joebgold-03-22-2023

I found the cause, it was because I was also using RoboDK's event channel at the same time.


RE: RoboDK crash when enabling SetCollisionActive-Albert-03-22-2023

OK thanks for letting us know. The event channel should be used on a separate Robolink instance.

If you can share a way to reproduce we can try to prevent a crash.


RE: RoboDK crash when enabling SetCollisionActive-joebgold-03-23-2023

In essence, I had two threads for handling robodk, the first has a queue which i use to send commands to robodk. This is so that robodk doesn't timeout and crash because two or more commands are running at the same time like what had happened in this post; also so that it doesn't freeze the main thread for the UI when sending a command like collision checking. The other thread is to handle robodk events, mainly used to check if the user has selected an object from the tree in the scene.

Code:
async void DequeueCommands()
Code:
{
while (true)
{
if (commandsQueue.Count > 0)
{
await Task.Run(() => DO ROBODK STUFF);
}

await Task.Delay(25);
}
}


Code:
void RDKEventThread()
{
while (true)
{
EventResult eventResult = null;
try
{
eventResult = eventChannel.WaitForEvent();
}
catch (Exception e)
{
eventResult = null;
}
finally
{
if (eventResult != null)
{
switch (eventResult.EventType)
{
case EventType.Selection3DChanged:

break;
default:
break;
}
}
}

}
}