Reading targets from RS station [moved from RobotStudio]
Hi, i have many modules inside my active station in RS, at least three modules have three different targets sets, am trying to read the targets from only one of these modules and export it to my program in C# , i have no problem in reading the targets if i have only one modules with one set, but whenever i try it on the station which has different modules i got an error, and i can not import the targets.
any help in this topic is really appreciated.
Post edited by Jonathan Karlsson on
0
Comments
-
What exactly is the problem with the station that has multiple modules? It is possible to get all the modules in a station by:ABB.Robotics.Controllers.RapidDomain.Task tRob1 = robotCont.Rapid.GetTask("T_ROB1"); //or whatever specififies your taskmodules = tRob1.GetModules().ToList();And then just iterate through the modules and use the code that worked for you earlier for each one. Also, this snippet extracts all robottargets regardless of how many modules there are:ABB.Robotics.Controllers.RapidDomain.RapidSymbolSearchProperties searchOpt = ABB.Robotics.Controllers.RapidDomain.RapidSymbolSearchProperties.CreateDefaultForData(true);robotCont = new Controller(ABB.Robotics.RobotStudio.Controllers.ControllerManager.ControllerReferences[0].SystemId); //or however you can identify your controller, this just grabs the first oneABB.Robotics.Controllers.RapidDomain.Task tRob1 = robotCont.Rapid.GetTask("T_ROB1"); //get the tasktry{foreach (ABB.Robotics.Controllers.RapidDomain.RapidSymbol rsymb in tRob1.SearchRapidSymbol(searchOpt)) //loop through all rapid symbols found in task{if (ABB.Robotics.Controllers.RapidDomain.RapidSymbol.IsData(rsymb)) //check if it is data (we're looking for a robottarget variable){ABB.Robotics.Controllers.RapidDomain.RapidData tempData = new ABB.Robotics.Controllers.RapidDomain.RapidData(robotCont, rsymb); //convert the symbol to data//check if it is a robot target typeif ( tempData.Value is ABB.Robotics.Controllers.RapidDomain.RobTarget)//if so, do whatever you want with it here.}}}catch (Exception ex){}If this doesn't solve the problem please post more specifics.0
-
Hello ,i think i have problem in the basics ( how to define the controller and modules) because it gives an error that they are not in the contest :shall i define the controller by this way ? Controller robotCont = new Controller();please see the program below,,it is a copy from what you sent, i opened a class library project in C# and added the references then copy your programusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Drawing;using ABB.Robotics.RobotStudio.Environment;using ABB.Robotics.RobotStudio.Stations;using ABB.Robotics.RobotStudio;using ABB.Robotics.Math;using ABB.Robotics;using ABB.Robotics.Controllers;using ABB.Robotics.Controllers.Discovery;using ABB.Robotics.Controllers.RapidDomain;using ABB.Robotics.RobotStudio.Controllers;namespace Targets_Modules{public class Class1{public static void AddinMain()// Project.UndoContext.BeginUndoStep("Targets_Modules");{// Controller robotCont = new Controller();Controller robotCont = new Controller();ABB.Robotics.Controllers.RapidDomain.RapidSymbolSearchProperties searchOpt = ABB.Robotics.Controllers.RapidDomain.RapidSymbolSearchProperties.CreateDefaultForData(true);robotCont = new Controller(ABB.Robotics.RobotStudio.Controllers.ControllerManager.ControllerReferences[0].SystemId); //or however you can identify your controller, this just grabs the first oneABB.Robotics.Controllers.RapidDomain.Task tRob1 = robotCont.Rapid.GetTask("IRB4400_60_1.96_249T_ROB1"); //or whatever specififies your taskmodules = tRob1.GetModules().ToList();try{foreach (ABB.Robotics.Controllers.RapidDomain.RapidSymbol rsymb in tRob1.SearchRapidSymbol(searchOpt)) //loop through all rapid symbols found in task{if (ABB.Robotics.Controllers.RapidDomain.RapidSymbol.IsData(rsymb)) //check if it is data (we're looking for a robottarget variable){ABB.Robotics.Controllers.RapidDomain.RapidData tempData = new ABB.Robotics.Controllers.RapidDomain.RapidData(robotCont, rsymb); //convert the symbol to data//check if it is a robot target typeif (tempData.Value is ABB.Robotics.Controllers.RapidDomain.RobTarget){ //if so, do whatever you want with it here.}}}}catch (Exception ex){}}}}0
-
I'm afraid I don't know what you mean by "in the contest"? Could you please provide the full description of the exception that occurs, assuming you mean that an exception occurs?0
-
Hello Again,i am sorry i wrote it by mistake , i meant in not in the context. please see a snapshot of the error i got , again i opened a class library project, the references are the same as above and the same program as above, the errors are :Error 7 The type or namespace name 'ControllerManager' does not exist in the namespace 'ABB.Robotics.Controllers' (are you missing an assembly reference?)Error 8 The name 'robotCont' does not exist in the current contextError 9 The name 'modules' does not exist in the current context0
-
Aah, It can seem a bit confusing but there are 2 "Controllers" namespace, one from ABB.Robotics.Controllers (PC SDK) and one from ABB.Robotics.Robotstudio.Controllers (RobotStudio SDK). Controllermanager is in ABB.Robotics.Robotstudio.Controllers, so you need to add it is a reference as well, not just the PC SDK version.0
-
Hello ,the problem of is ControllerManager is solved (thanks alot!) according to your suggestion:Error 7 The type or namespace name 'ControllerManager' does not exist in the namespace 'ABB.Robotics.Controllers' (are you missing an assembly reference?)but still having the other errors for both the robotCont and modules, shall i define themError 8 The name 'robotCont' does not exist in the current contextError 9 The name 'modules' does not exist in the current contextut shall i add something to the code ? or open it in another window ( not as class library) or maybe change the method ... i am tryin different things but i can not connect to the controller, also shall i open the virtual controller in RS before for example! it seems am missing something! and i dont know what is it...1
-
Yes, you need to open the station/virtual controller in RobotStudio first, as otherwise there will be nothing to choose from. Also, the project type should of course be a class library since the resulting file is the .dll file that should be added to the RobotStudio add-in folder, as per: http://developercenter.robotstudio.com:80/Index.aspx?DevCenter=RobotStudio&OpenDocument&Url=html/08a465af-bdcc-4f65-a647-764c14005d00.htm .0
-
ok, now i opened my virtual controller which is the same as my station, shall i get more information from the RSlike IP Address or something like that to put it in the C# program,and how to define the controller which is called ControllerSFB in robot studio , with RobotCont in C# ?can you please help me0
-
Saharqaadan, you shouldn't need an IP adress if your controller is virtual. The controller references that the control manager has have names, so you could simply:foreach (ABB.Robotics.RobotStudio.Controllers.ControllerObjectReference objRef in ABB.Robotics.RobotStudio.Controllers.ControllerManager.ControllerReferences){if (objRef.Name.Equals("ControllerSFB"))robotCont = new Controller(objRef.SystemId);}0
-
Hello, i still have the problem is there any vedio or something rather than the reference or application manual for pc sdk that i can read regarding the tips of getting the pc sdk working0
-
I don't know of any videos I'm afraid.Error 9 The name 'modules' does not exist in the current contextis simply because you have not declared the modules variable. May I ask what background you have in previous programming?0
-
Could you post your code and specify what line your error about robotCont occurs at?0
-
Finally Solved, the problem was not even with the Controller, my C# code need ascending order of data to calculate the staff .the data were repeated and i did not notice that till today:P0
-
Thanks alot0
-
Glad to hear it worked out.1
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 799 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings