Created
February 19, 2025 23:34
-
-
Save lizTheDeveloper/a5088833b15a742d08a49235cae70eac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VAR socketdev client_socket; | |
VAR string received_data; | |
VAR jointtarget target_joints; | |
VAR num joint_speed := 100; | |
VAR num joint_zone := 50; | |
PROC main() | |
! Create socket and bind to ABB’s IP | |
SocketCreate client_socket; | |
SocketBind client_socket, "192.168.125.1", 1025; | |
SocketListen client_socket; | |
WHILE TRUE DO | |
SocketAccept client_socket; | |
WHILE TRUE DO | |
! Read incoming command | |
SocketRead client_socket, received_data; | |
Write received_data; | |
! Handle "GET_STATE" command | |
IF received_data = "GET_STATE" THEN | |
VAR jointtarget current_joints := CRobT(); | |
SocketSend client_socket, | |
NumToStr(current_joints.robax.rax_1, 3) + "," + | |
NumToStr(current_joints.robax.rax_2, 3) + "," + | |
NumToStr(current_joints.robax.rax_3, 3) + "," + | |
NumToStr(current_joints.robax.rax_4, 3) + "," + | |
NumToStr(current_joints.robax.rax_5, 3) + "," + | |
NumToStr(current_joints.robax.rax_6, 3); | |
! Handle "EXECUTE_ACTION" command | |
ELSEIF StrFind(received_data, "EXECUTE_ACTION", 1) > 0 THEN | |
target_joints.robax.rax_1 := StrToVal(SplitStr(received_data, ",")); | |
target_joints.robax.rax_2 := StrToVal(SplitStr(received_data, ",")); | |
target_joints.robax.rax_3 := StrToVal(SplitStr(received_data, ",")); | |
target_joints.robax.rax_4 := StrToVal(SplitStr(received_data, ",")); | |
target_joints.robax.rax_5 := StrToVal(SplitStr(received_data, ",")); | |
target_joints.robax.rax_6 := StrToVal(SplitStr(received_data, ",")); | |
MoveJ target_joints, vjoint_speed, zjoint_zone, tool0; | |
SocketSend client_socket, "Action Executed"; | |
ENDIF | |
ENDFOR | |
SocketClose client_socket; | |
ENDWHILE | |
ENDPROC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment