Show / Hide Table of Contents

Online Monitor

The OnlineMonitor Add-In serves as an example of how you can get joint values from a real controller to see its movement in RobotStudio. It contains two commands.

View Robot : The first one "View Robot" is a button on the Online Tab, Monitor Group. By selecting a controller in the online browser, and pressing the button, a new graphic window will be opened displaying the real robot (the corresponding .rslib file has to be located by the user and loaded. The default location of .rslib files of Robots is C:\Program Files (x86)\ABB\RobotStudio version\ABB Library\Robots.

Feed Joint Values to VC : The other command "Feed Joint Values to VC" is implemented as a context menu group on the online controller (in the online controller browser). For each VC/mechanism in the station, a sub menu item appears. By selecting for example the virtual system "MySystem1", the joint values from the selected online controller will be fed to the mechanism of "MySystem1".

Example: Right click on "MyRealSystem" in the online browser, and select "Feed Joint Values to VC" / "MyVirtualSystem". Now the mechanism of "MyVirtualSystem" will move according to "MyRealSystem". It is up to you to make sure that the robot models are identical.

Download

Click here to download

Note

If you encounter some build errors when add-in is built, you need to add the DLL references from RobotStudio application folder.

Refer to the How to add a reference to your Add-in section in Creating a RobotStudio Add-in tutorial.

Limitation

  • The base frame of the real robot is not considered.

  • View Robot does not work for paint robots.

Internals

While Opening or Creating a station, AddinMain () static function gets called by the RobotStudio.

Execution of main function does registration of two commands:

  1. View Robot

  2. Feed Joint Values to VC

Details follow below:

  1. View Robot: On Invocation of click event of “view robot command” the GetSelectedController() gets called which returns the currently selected controller in the Online browser. If only one controller exists, it is returned even if it is not selected with the assumption that this controller is the one the user wants to view.

    private Controller GetSelectedController()
    {
        try
        {
            Guid selectedSystem = Guid.Empty;
            try
            {
                ControllerObjectReference ctrlRef = 
                    Selection.SelectedObjects.SingleSelectedObject as ControllerObjectReference;
                if (ctrlRef != null)
                {
                    selectedSystem = ctrlRef.SystemId;
                }                              
                if (selectedSystem == Guid.Empty && 
                    ControllerManager.ControllerReferences.Count == 1)
                {
                    selectedSystem = ControllerManager.ControllerReferences[0].SystemId;
                }
            }
            catch
            {
                return null;
            }                  
            return selectedSystem == Guid.Empty ? null : new Controller(selectedSystem);
        }
        catch(Exception ex)
        {
            Logger.AddMessage(new LogMessage(ex.Message));
        }
        return null;
    }
    

    Then OpenRobotWindow() gets called next which gets the currently selected controller in the Online browser, and loads the corresponding mechanism model into a "secret" station, which is then displayed in a GraphicControl.

    private void OpenRobotWindow()
    {
    
        string libFilePath = string.Empty;
    
        // Load the mechanism library that corresponds to the 
        OpenFileDialog dialog = new OpenFileDialog();
        dialog.Filter =
            "rslib files (*.rslib)|*.rslib";
        dialog.InitialDirectory = "C:";
        dialog.Title = "Load the mechanism model corresponding to Controller Robot Type";
    
        if (dialog.ShowDialog() == DialogResult.OK)
            libFilePath = dialog.FileName;
        if (libFilePath == string.Empty)
            return;
      
        EnsureTimer();
    
        Controller controller = GetSelectedController();
        Window w = UIEnvironment.Windows[controller.SystemId];
    
        if (w != null)
        {
            Window.ActiveWindow = w;
            return;
        }
    
        MechanismData mechData = new MechanismData();
        GraphicControl graphicControl = new GraphicControl();
    
        // Check Motion domain in CFG to find the robot model information to be used to load the correct robot library (Mechanism)
        ABB.Robotics.Controllers.ConfigurationDomain.Type type = 
            controller.Configuration.MotionControl.Types[controller.Configuration.MotionControl.Types.IndexOf("ROBOT")];
    
        //Get an array of object instance of ROBOT Type
        Instance[] instances = type.GetObjects();
    
        for (int i = 0; i < instances.Length; i++)
        {
            string robotType = instances[i].GetAttribute("use_robot_type") as string;
            string mechanismModel = controller.Configuration.Read("MOC", "ROBOT_TYPE", robotType, "name");
    
            Mechanism mechanism = LoadMechanism(libFilePath);
            graphicControl.RootObject = mechanism;
    
            mechData.VirtualMechanism = mechanism;
            mechData.RealController = controller;
            mechData.MechUnit = mechData.RealController.MotionSystem.MechanicalUnits[0];
    
            w = new DocumentWindow(controller.SystemId, graphicControl);
            w.Caption = "System: " + controller.SystemName;
            UIEnvironment.Windows.Add(w);
            w.Closed += new EventHandler(w_Closed);
            _mech2window.Add(mechData, w);
        }
    }
    
  2. Feed Joint Values to VC : This Command setup a real controller connection to virtual controller. FeedJointValuesToVC is a private instance method which takes 2 argument parameter. first argument is real controller reference and second argument is virtual controller object reference.

    private void FeedJointValuesToVC(ControllerObjectReference realControllerRef, RsIrc5Controller virtualController)
    {
        EnsureTimer();
    
        MechanismData mechData = new MechanismData();
        mechData.RealController = new Controller(realControllerRef.SystemId);
        mechData.MechUnit = mechData.RealController.MotionSystem.MechanicalUnits[0];
        mechData.VirtualMechanism = virtualController.MechanicalUnits[0].Mechanism;
        mechData.VirtualController = virtualController;
        _mech2window.Add(mechData, null);
    }
    
    • EnsureTimer() is private instance method of a module which ensures that Timer is started and tick event of timer is also subscribed.

    • _timer_Tick is an event handler of timer tick event. This handler gets the joint position from real robot, convert to radians, and set joint values on RobotStudio mechanism.

      void _timer_Tick(object sender, EventArgs e)
      {
          try
          {
              foreach (MechanismData data in _mech2window.Keys)
              {
                  JointTarget jt = data.MechUnit.GetPosition();
                  double[] jv = new double[]{
                  Globals.DegToRad(jt.RobAx.Rax_1), 
                  Globals.DegToRad(jt.RobAx.Rax_2), 
                  Globals.DegToRad(jt.RobAx.Rax_3), 
                  Globals.DegToRad(jt.RobAx.Rax_4), 
                  Globals.DegToRad(jt.RobAx.Rax_5), 
                  Globals.DegToRad(jt.RobAx.Rax_6)};
                  data.VirtualMechanism.SetJointValues(jv ,false);
                  GraphicControl.UpdateAll();
              }
          }
          catch(Exception ee)
          {
              string s = ee.Message;
          }        
      }
      

How to run an Addin

  1. Load Addin: OnlineMonitor Add-In will appear under General node of Add-Ins tab. Right click the addin to see load options. Click on "Load Add-In" to see the addin in ribbon.

  2. View Robot Button: View Robot button will appear in monitor group. Invoke this button to launch the new station with real robot mechanism.

  3. Set "Jog Joint" option in Freehand group of Home tab.

  4. Jog the robot in left side window to see the automatic jogging of the robot on right side window.

Required Namespaces

ABB.Robotics.Math

ABB.Robotics.RobotStudio

ABB.Robotics.RobotStudio.Environment

ABB.Robotics.RobotStudio.Stations

ABB.Robotics.Controllers

ABB.Robotics.RobotStudio.Stations.Forms

ABB.Robotics.Controllers.ConfigurationDomain

ABB.Robotics.Controllers.RapidDomain

ABB.Robotics.Controllers.MotionDomain

ABB.Robotics.RobotStudio.Controllers

In this article
Back to top Copyright © 2025 ABB