Help with RAPID: user functions & structures?
mhannan
✭
I am using the RAPID language to create a relatively complex application to control my ABB robot that utilizes both laser sensors and cameras. I have had a lot of success with the RAPID programming language, but there are several items that I am use to in traditional "C" programing that I cannot figure out how to implement in RAPID.
1) How do I write a user "function" that returns a value? I have been able to use PROC with input arguments, but it does not seem to let you return a result. There are plenty of "functions" that are called in the code that take input arguments and return results. I must be missing something on how to write my own.
2) How do you create a "structure" in RAPID? Again, they are used all the time (e.g., pose), but I have yet to figure out how to create a user "struct."
3) Can you create "enumerated" data types in RAPID?
Where can I find information on these more "advanced" topics in the RAPID programming language?
Thanks
Michael
1) How do I write a user "function" that returns a value? I have been able to use PROC with input arguments, but it does not seem to let you return a result. There are plenty of "functions" that are called in the code that take input arguments and return results. I must be missing something on how to write my own.
2) How do you create a "structure" in RAPID? Again, they are used all the time (e.g., pose), but I have yet to figure out how to create a user "struct."
3) Can you create "enumerated" data types in RAPID?
Where can I find information on these more "advanced" topics in the RAPID programming language?
Thanks
Michael
0
Comments
-
Hi MichaelTry to find Rapid Reference manuals called RAPID Kernal and RAPID Overview.There you will find a lot of goodies such as:
FUNC num veclen (pos vector)
RETURN Sqrt(Pow(vector.x,2)+Pow(vector.y,2)+Pow(vector.z,2));
ENDFUNC
and
RECORD newtype
num x;
ENDRECORD
I guess the manuals are included on the DVD - get back here if you cannot find them.
Good luck
/GA?ran Manske0 -
I put RECORD
RECORD Moldstring Name;num Mold_number;num Cannon_number;pos P{6};num W{6};num M_zone{6};num M_speed{6};ENDRECORDIn MainModule in front of PROC Main()and I define new record like thisPERS Mold Mold1;In PROC Main()But when run, I received this error messageExpected 'trap' but found 'record'What could be the problem?I also have 2 traps PROC after Main()Please help, Thank you in advanceAke0 -
Hi Ake,Arrays in RECORD are unfortunately not supported - I guess you need to solve this in another way. Perhaps you can use arrays of molds or multiple data in the RECORD e.g.:pos p1;pos p2;pos p3;etc.Also when creating PERS data I believe you need to give it a value:PERS mold mold1:=["Hello",12,....];Personally I always keep my PERS data as global data - that is NOT in the main PROC.If you need the data locally in a PROC without an initial value - use VAR!Good luck!GA?ran0
-
hey Ake and GA?ran,to use structs (record) in S4C+ robots you need an option called developers function, in IRC5 robots you basically need an option used advanced rapid, unless you boot the system with one of the latest bootware versions (I think advanced rapid is free as from robotware 5.13for the problem that an array is not supported in a record. I know it is a problem but I solve it following way: if I need eg an array of 20 nums in a record, I first create a record with 20 num "elements" and use this record in the record I was intented to build. I also write a "get"-function with parameters the 20 num record and the number of element I want to access and a "set" procedure with parameters the 20 num rocord (defined as Inout parameter), the number of Item I want to change and the new value.......about pers variables: yes, you have to give them a value, and no you can not declare them within a routine (because there life time is only that routine, and there value can not be stored)......hope this helps you,bartbest regards,
bart0
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)
- 800 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings