Send Position as a String
SteveMob
✭
in RobotStudio
Hello,
I have a current RAPID program that is communicating with LabVIEW. I want the RAPID program to send LV a string of it's current position, with tool and axis configurations as well as the robtarget name, once the robot has reached a position.
This is my code:
MODULE Module1
CONST robtarget Home:=[[374,0,630],[0.707106781,0,0.707106781,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
CONST robtarget Target_10:=[[526.3896,0,477.5962],[0.707106781,0,0.707106781,0],[0,0,0,1],[9E9,9E9,9E9,9E9,9E9,9E9]];
CONST robtarget Target_10_2:=[[526.3896,190.5,528.3962],[0.707106781,0,0.707106781,0],[0,0,-1,1],[9E9,9E9,9E9,9E9,9E9,9E9]];
VAR socketdev client_socket;
VAR socketdev RS;
VAR num retry_no:=0;
VAR rawbytes parse_data;
VAR num peek_value:=0;
VAR num bytes_available:=0;
VAR byte command:=255;
VAR num i;
VAR num MoveNext:=0;
PROC Path_10()
SocketClose client_socket;
Socketcreate client_socket;
SocketConnect client_socket,"192.168.125.5",3333;
!127.0.0.1 for self
SocketSend client_socket\Str:="Connection Successful, you are the server, I am the client!"\NoOfBytes:=59;
IF ERRNO=ERR_SOCK_TIMEOUT THEN
ENDIF
! Clear the port of any data
ClearRawBytes parse_data;
i:=1;
WHILE i=1 DO
peek_value:=SocketPeek(client_socket);
IF peek_value>=1 THEN
ClearRawBytes parse_data;
SocketReceive client_socket\RawData:=parse_data\Time:=25;
bytes_available:=RawBytesLen(parse_data);
SocketSend client_socket\RawData:=parse_data;
IF bytes_available>=1 THEN
UnpackRawBytes parse_data,1,command\Hex1;
IF command=105 THEN
command:=0;
Incr MoveNext;
IF MoveNext=1 THEN
SocketSend client_socket\Str:="FALSE",\NoOfBytes:=5;
! MoveJ Home,v100,z10,tool0\WObj:=wobj0;
! WaitTime 1;
SocketSend client_socket\Str:="TRUE",\NoOfBytes:=4;
ENDIF
IF MoveNext=2 THEN
SocketSend client_socket\Str:="FALSE",\NoOfBytes:=5;
MoveJ Target_10,v100,z10,tool0\WObj:=wobj0;
WaitTime 1;
SocketSend client_socket\Str:="TRUE",\NoOfBytes:=4;
SocketSend client_socket\Data:=Current_Pos;
ENDIF
IF MoveNext=3 THEN
SocketSend client_socket\Str:="FALSE",\NoOfBytes:=5;
MoveJ Target_10_2,v100,z10,tool0\WObj:=wobj0;
WaitTime 1;
SocketSend client_socket\Str:="TRUE",\NoOfBytes:=4;
ENDIF
:
:
:
IF MoveNext>=27000 THEN
SocketSend client_socket\Str:="FALSE",\NoOfBytes:=5;
MoveNext:=0;
SocketSend client_socket\Str:="TRUE",\NoOfBytes:=4;
ENDIF
IF ERRNO>0 THEN
IF ERRNO=ERR_SOCK_TIMEOUT THEN
ELSE
i:=0;
ENDIF
ENDIF
WaitTime 1;
ENDIF
ENDIF
ENDIF
ENDWHILE
ENDPROC
ENDMODULE
I looked into the Cpos and CRobT functions in the manual, but it didn't really help me. Essentially I just need to take the current position, convert it to a string, and send that string to LV for each position. The problem is I have a ton of positions so I can't just go in and say "your at position # 5,267", that would take too long. If someone has done this before, I would greatly appreciate any examples or pointers!
Thanks in advance for any help!
SM
I have a current RAPID program that is communicating with LabVIEW. I want the RAPID program to send LV a string of it's current position, with tool and axis configurations as well as the robtarget name, once the robot has reached a position.
This is my code:
MODULE Module1
CONST robtarget Home:=[[374,0,630],[0.707106781,0,0.707106781,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
CONST robtarget Target_10:=[[526.3896,0,477.5962],[0.707106781,0,0.707106781,0],[0,0,0,1],[9E9,9E9,9E9,9E9,9E9,9E9]];
CONST robtarget Target_10_2:=[[526.3896,190.5,528.3962],[0.707106781,0,0.707106781,0],[0,0,-1,1],[9E9,9E9,9E9,9E9,9E9,9E9]];
VAR socketdev client_socket;
VAR socketdev RS;
VAR num retry_no:=0;
VAR rawbytes parse_data;
VAR num peek_value:=0;
VAR num bytes_available:=0;
VAR byte command:=255;
VAR num i;
VAR num MoveNext:=0;
PROC Path_10()
SocketClose client_socket;
Socketcreate client_socket;
SocketConnect client_socket,"192.168.125.5",3333;
!127.0.0.1 for self
SocketSend client_socket\Str:="Connection Successful, you are the server, I am the client!"\NoOfBytes:=59;
IF ERRNO=ERR_SOCK_TIMEOUT THEN
ENDIF
! Clear the port of any data
ClearRawBytes parse_data;
i:=1;
WHILE i=1 DO
peek_value:=SocketPeek(client_socket);
IF peek_value>=1 THEN
ClearRawBytes parse_data;
SocketReceive client_socket\RawData:=parse_data\Time:=25;
bytes_available:=RawBytesLen(parse_data);
SocketSend client_socket\RawData:=parse_data;
IF bytes_available>=1 THEN
UnpackRawBytes parse_data,1,command\Hex1;
IF command=105 THEN
command:=0;
Incr MoveNext;
IF MoveNext=1 THEN
SocketSend client_socket\Str:="FALSE",\NoOfBytes:=5;
! MoveJ Home,v100,z10,tool0\WObj:=wobj0;
! WaitTime 1;
SocketSend client_socket\Str:="TRUE",\NoOfBytes:=4;
ENDIF
IF MoveNext=2 THEN
SocketSend client_socket\Str:="FALSE",\NoOfBytes:=5;
MoveJ Target_10,v100,z10,tool0\WObj:=wobj0;
WaitTime 1;
SocketSend client_socket\Str:="TRUE",\NoOfBytes:=4;
SocketSend client_socket\Data:=Current_Pos;
ENDIF
IF MoveNext=3 THEN
SocketSend client_socket\Str:="FALSE",\NoOfBytes:=5;
MoveJ Target_10_2,v100,z10,tool0\WObj:=wobj0;
WaitTime 1;
SocketSend client_socket\Str:="TRUE",\NoOfBytes:=4;
ENDIF
:
:
:
IF MoveNext>=27000 THEN
SocketSend client_socket\Str:="FALSE",\NoOfBytes:=5;
MoveNext:=0;
SocketSend client_socket\Str:="TRUE",\NoOfBytes:=4;
ENDIF
IF ERRNO>0 THEN
IF ERRNO=ERR_SOCK_TIMEOUT THEN
ELSE
i:=0;
ENDIF
ENDIF
WaitTime 1;
ENDIF
ENDIF
ENDIF
ENDWHILE
ENDPROC
ENDMODULE
I looked into the Cpos and CRobT functions in the manual, but it didn't really help me. Essentially I just need to take the current position, convert it to a string, and send that string to LV for each position. The problem is I have a ton of positions so I can't just go in and say "your at position # 5,267", that would take too long. If someone has done this before, I would greatly appreciate any examples or pointers!
Thanks in advance for any help!
SM
0
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings