exporting a vector from C# to ABB robot studio [moved from RobotStudio]
Hello
Could you please help me with an example, how to make some function for exporting a vector to RobotStudio?
i am doing my own add-in , using API Documentation i can use the DataDeclerationInstruction example to declare my force vector, but i could not export the vector itself
I will be grateful for any information.
Best regards,
Post edited by Jonathan Karlsson on
0
Comments
-
Hello,Could you be more specific in what you mean by "exporting to RobotStudio"? Do you want to get the vector into a RAPID program you have on a virtual controller?0
-
Hello Joman,yes , i create a class '' MatrixCalculation '' , in this class finally i have two force vector in the x and y directions .i need to export these two vector to rapid program in ABB RS .Note: these two vector are varying according to an excel sheet that have the coordinates of the original workpiece ( so everytime i might use different data )0
-
Ok, then I understand. There have been several discussions about similiar objectives before, and if you wish to read more broadly about it check out http://developercenter.robotstudio.com/Index.aspx?DevCenter=RobotCommunication&OpenDocument&Url=../RobotCommunicationAppManual/doc30.html .For your problem I can provide the following example, given you have a RAPID module which has the variable you wish to manipulate. As far as I know there is no data type called "vector" in RAPID, but I could be wrong. This example manipulates a robot target variable, you can change the data type to fit with your application.// Get a reference to the controller. This example simply picks the first controller available, you probably want to swap this for something more elegantrobotCont = new Controller(ABB.Robotics.RobotStudio.Controllers.ControllerManager.ControllerReferences[0].SystemId);//find the task the vector variable is inABB.Robotics.Controllers.RapidDomain.Task tRob1 = robotCont.Rapid.GetTask("T_ROB1");//get the data of the variable, NOTE: change "theMod" to your module and "myVar" to the name of your variableABB.Robotics.Controllers.RapidDomain.RapidData rd = tRob1.GetRapidData("theMod", "myVar");//This example modifes a robot target, not a vectorABB.Robotics.Controllers.RapidDomain.RobTarget newTarget = new ABB.Robotics.Controllers.RapidDomain.RobTarget();if (rd.Value is ABB.Robotics.Controllers.RapidDomain.RobTarget){//Request mastership of Rapid before writing to the controllerusing (Mastership.Request(robotCont.Rapid)){newTarget.FillFromString2("[ [1800, 1000, 1600"], [1, 0, 0, 0], [1, 1, 0, 0], [ 9E9, 9E9, 9E9, 9E9, 9E9, 9E9] ]");rd.Value = newTarget;}}Hope this helps.0
-
thank you so much , i will change to use pc sdk instead of using API alone, i hope it works, i will get back to you when i am donei am looking forward to make it working well0
-
Hello Joman,i did it correctly using API , but i have small question : the code in C# which have the vector and i declare it successfully to rapid is below:// ***This example requires a running VC***Station station = Project.ActiveProject as Station;// this defines the name of my vector '' myMatrix1'' and it is datatype is '' num'' , and dimension is an array called '' valuesxValues'' ,now here is my question ( please see//the question by the end of the code )RsGenericDataDeclaration myGenDDString1 = new RsGenericDataDeclaration("myMatrix1", "num", CalMat.valuesxValues);// Set the InitialExpression of the DataDeclaration.myGenDDString1.InitialExpression = "\"xValues\"";// Set the module name the DataDeclaration should be syncronized to.myGenDDString1.ModuleName = "myModule_xValue";// Define the DataDeclaration as variable.myGenDDString1.StorageType = RapidStorageType.Variable;// Make sure the DataDeclaration is synchroinized when the task is.myGenDDString1.Synchronize = true;// Add the DataDeclaration to the ActiveTask.station.ActiveTask.DataDeclarations.Add(myGenDDString1);// Syncronize the DataDeclarations to the VC.System.Collections.Generic.List<SyncLogMessage> syncLog_2 = new System.Collections.Generic.List<SyncLogMessage>();station.ActiveTask.SyncData(myGenDDString1.ModuleName + "/" + myGenDDString1.Name, SyncDirection.ToController, syncLog_2);Question: how to see the elements of this array in rapid?0
-
Do you mean how to look at the value of this newly created RAPID VAR (myMatrix1) using c#? In that case that line in my exampleABB.Robotics.Controllers.RapidDomain.RapidData rd = tRob1.GetRapidData("theMod", "myVar");Is what reads variables in RAPID modules, and as in the example you should make sure that what you're getting back is the correct type.Sorry if I misunderstood.0
-
Hello,i am reading from C# to rapid .and i dont use ABB.Robotics.Controllers ( i think this is for SDK) , if i switch from API to use SDK i think also i can not read my vector because as in your exampleusing (Mastership.Request(robotCont.Rapid)){newTarget.FillFromString2("[ [1800, 1000, 1600"], [1, 0, 0, 0], [1, 1, 0, 0], [ 9E9, 9E9, 9E9, 9E9, 9E9, 9E9] ]");rd.Value = newTarget;}you have a constant values of newTarget, but in my case i dont know it , i just have the name of the vector.regards,0
-
It's possible to include both ABB.Robotics.Controllers and ABB.Robotics.RobotStudio.Controllers at the same time. You just have to write out or use "using" to specify which one you mean at each instance.But what I meant was that after usingABB.Robotics.Controllers.RapidDomain.RapidData rd = tRob1.GetRapidData("theMod", "myVar");With "theMod" as myModule_xValue" and "myVar" as "myMatrix1" you would then get the value in the "rd" variable.0
-
Hey Joman,i am trying to apply your code but i have an error :'' that robotCont is not used in the contest!! ''// Get a reference to the controller. This example simply picks the first controller available, you probably want to swap this for something more elegantrobotCont = new Controller(ABB.Robotics.RobotStudio.Controllers.ControllerManager.ControllerReferences[0].SystemId);0
-
Are you sure you have declared robotCont somewhere before that line? ( Controller robotCont; )0
-
yes!0
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