by PedroR » Mon Jul 09, 2012 6:44 pm
by PedroR
Mon Jul 09, 2012 6:44 pm
[EDIT: we have revised the code for ConnectToRB to eliminate this deadlock.
Please make sure to re-download the ZIP file for this demo to get the latest version. (you may need to clean your browser cache to make sure you get the new version) [/EDIT]
Hi Kondo
I don't have access to the complete set up at the moment (PC with VB 2010, Kinect and Robobuilder) but as soon as I have the opportunity I will look at this bug in more detail.
If you are familiar with VB.Net, then open the VB Solution in the ZIP file, and then open the code for "MainWindow" (it's file MainWindow.xaml.vb)
Now look for the function called "ConnectToRB". I have pasted bellow the code of the function and marked the place where you need to insert a Breakpoint:
- Code: Select all
Private Sub ConnectToRB(ByVal sCOMMNum As String)
On Error GoTo ErrHandler
commRb = New SerialPort("COM" & sCOMMNum, 115200, Parity.None, 8, StopBits.One) '''----- INSERT BREAKPOINT HERE
commRb.Open()
'rbPCR = New RobobuilderLib.PCremote("COM" & sCOMMNum)
rbPCR = New RobobuilderLib.PCremote(commRb)
Thread.Sleep(400)
rbPCR.setDCmode(False)
rbPCR.runMotion(7) ' basic posture
Thread.Sleep(2000)
rbPCR.setDCmode(True)
Thread.Sleep(500)
rbWCK = New RobobuilderLib.wckMotion(rbPCR)
Thread.Sleep(300)
Me.txtRBComStatus.Text = "Connected"
bRBConnected = True
Exit Sub
ErrHandler:
MsgBox("Unable to Connect to Robobuilder" & vbCrLf & vbCrLf & Err.Description, vbCritical And vbOKOnly, "Error Connecting")
rbPCR = Nothing
If Not commRb Is Nothing And commRb.IsOpen Then commRb.Close()
commRb = Nothing
Err.Clear()
End Sub
Insert the breakpoint on that line because the program sometimes hangs on the next line.
(to insert a breakpoint, put the cursor on that line and press "F9")
After inserting the Breakpoint (the line will become red) start the program.
When you connet to Robobuilder, the program will stop at the line where you inserted the Breakpoint. Now
- Press the keyboard key "F8" to execute the line
- Wait a bit
- Press "F8" again to execute the next line (it may also hang here)
- Wait a bit
- Press "F8" again to execute the next line (it may also hang here)
- Wait a bit
- Press "F8" again to execute the next line (it may also hang here)
- Wait a bit
- If this has succeeded now press F5 to resume the program.
You can see in the code that there are some "Sleep" commands.
This is a Quick and dirty fix for the bug you are experiencing. It seems to have fixed the problem for us but you can also try increasing the amount of time in "Sleep" and see if it solves the problem for you as well.
To work around this issue, the solution is probably to disable Kinect before connecting to Robobuilder and then re enabling it after sucessful connection.
If/when we have the time, we'll modify the code to check if this solves the issue.
Regards
Pedro.
[EDIT: we have revised the code for ConnectToRB to eliminate this deadlock.
Please make sure to re-download the ZIP file for this demo to get the latest version. (you may need to clean your browser cache to make sure you get the new version) [/EDIT]
Hi Kondo
I don't have access to the complete set up at the moment (PC with VB 2010, Kinect and Robobuilder) but as soon as I have the opportunity I will look at this bug in more detail.
If you are familiar with VB.Net, then open the VB Solution in the ZIP file, and then open the code for "MainWindow" (it's file MainWindow.xaml.vb)
Now look for the function called "ConnectToRB". I have pasted bellow the code of the function and marked the place where you need to insert a Breakpoint:
- Code: Select all
Private Sub ConnectToRB(ByVal sCOMMNum As String)
On Error GoTo ErrHandler
commRb = New SerialPort("COM" & sCOMMNum, 115200, Parity.None, 8, StopBits.One) '''----- INSERT BREAKPOINT HERE
commRb.Open()
'rbPCR = New RobobuilderLib.PCremote("COM" & sCOMMNum)
rbPCR = New RobobuilderLib.PCremote(commRb)
Thread.Sleep(400)
rbPCR.setDCmode(False)
rbPCR.runMotion(7) ' basic posture
Thread.Sleep(2000)
rbPCR.setDCmode(True)
Thread.Sleep(500)
rbWCK = New RobobuilderLib.wckMotion(rbPCR)
Thread.Sleep(300)
Me.txtRBComStatus.Text = "Connected"
bRBConnected = True
Exit Sub
ErrHandler:
MsgBox("Unable to Connect to Robobuilder" & vbCrLf & vbCrLf & Err.Description, vbCritical And vbOKOnly, "Error Connecting")
rbPCR = Nothing
If Not commRb Is Nothing And commRb.IsOpen Then commRb.Close()
commRb = Nothing
Err.Clear()
End Sub
Insert the breakpoint on that line because the program sometimes hangs on the next line.
(to insert a breakpoint, put the cursor on that line and press "F9")
After inserting the Breakpoint (the line will become red) start the program.
When you connet to Robobuilder, the program will stop at the line where you inserted the Breakpoint. Now
- Press the keyboard key "F8" to execute the line
- Wait a bit
- Press "F8" again to execute the next line (it may also hang here)
- Wait a bit
- Press "F8" again to execute the next line (it may also hang here)
- Wait a bit
- Press "F8" again to execute the next line (it may also hang here)
- Wait a bit
- If this has succeeded now press F5 to resume the program.
You can see in the code that there are some "Sleep" commands.
This is a Quick and dirty fix for the bug you are experiencing. It seems to have fixed the problem for us but you can also try increasing the amount of time in "Sleep" and see if it solves the problem for you as well.
To work around this issue, the solution is probably to disable Kinect before connecting to Robobuilder and then re enabling it after sucessful connection.
If/when we have the time, we'll modify the code to check if this solves the issue.
Regards
Pedro.
Last edited by PedroR on Tue Jul 10, 2012 6:23 pm, edited 2 times in total.