Proper way to handle lost connection from Servo Robot

baldwindcbaldwindc Knoxville, Tn
Hi all, 

I've developed an application in C# that monitors different signals and variables coming from the robot. I'm wondering what the proper way to handle an accidental disconnect is. 

Currently I'm doing something like this (pseudocode): 
Thread { 
(if controller.connected == false) { 
Thread { // Create Thread to re-establish connection
controller.logoff(); // Just in case, logoff so we can log back on
controller.dispose(); 
NetworkScanner scan = new NetworkScanner() ; 
scan.Scan(); 
.....
.....
ControllerInfoCollection cic = scan.Controllers
// Some logic to determine which controller I want
controller = ControllerFactory.CreateFrom(c); 
// Some error checking to make sure I'm connected
Thread { // Thread that establishes a connection to a signal and starts monitoring said signal
sig = manager.controller.IOSystem.GetSignal(signal_source_str); // Where signal_source_str is a known good signal



This is not a threading issue. In order to test (as well as make sure it handles extreme cases) I am warm starting the controller in RobotStudio. So I connect, go to RS and then warm start, and then I get

An unhandled exception of type 'ABB.Robotics.GenericControllerException' occurred in ABB.Robotics.Adapters.IRC5.dll

The controller start-up process also freezes and doesn't continue until I stop debugging my application. So my question is this, how do I ask the controller:
 "Hey is it okay if I get a signal now, or should I wait a bit longer? 

Comments

  • Did you ever come up with a solution for this? I am at the same point with my development and looking for a good way of handling dis/connects. Thanks.
  • SverrirSverrir Germany
    For posterity, 

    I've found it tricky to accurately handle recovery of Controllers after a Warm restart. However the following sequence works the best:
    1. Use NetworkWatcher to monitor Found and Lost
    2. NetworkWatcher.OnLost -> Unsubscribe signals for any existing controllers
    3. NetworkWatcher.OnFound -> Subscribe to ConnectionChanged event on Controller
    4. When Controller.ConnectionChanged is Connected == True -> Subscribe to Controller.StateChanged + Logon Controller
    5. When Controller.StateChanged is NewState == MotorsOn -> Subscribe to signals.
    If you skip step 4 and jump from OnFound directly to StateChanged then you will have scenarios where you get this GenericControllerException as you need to access the .State property etc and things are not ready on the Controller. 

    BCT Technology AG, Im Lossenfeld 9, 77731 Willstätt, Germany, https://www.bct-technology.com
    Vorstand/Officers: Klaus Erdrich, Jürgen Hillemann. Registergericht/Registry Court: Amtsgericht Freiburg, HRB 371105
    Aufsichtsrat/Supervisory Board: Prof. Dr. h.c. Horst Weitzmann (Vorsitzender/Chairman), Katja Weber, Markus Menges 

Sign In or Register to comment.