Skip to content

Instantly share code, notes, and snippets.

@roxlu
Created November 7, 2014 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roxlu/d2d8fc693ad807193868 to your computer and use it in GitHub Desktop.
Save roxlu/d2d8fc693ad807193868 to your computer and use it in GitHub Desktop.
MODULE Server
PERS tooldata myTool:=[TRUE,[[0,0,1],[1,0,0,0]],[1,[0,0,0.1],[1,0,0,0],0,0,0]];
TASK PERS wobjdata myWobj:=[FALSE,TRUE,"",[[400,0,400],[1,0,0,0]],[[0,0,0],[1,0,0,0]]];
!CONST robtarget myRobtarget:=[[0,0,0],[0.707107,0,0.707107,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
VAR robtarget myRobtarget:=[[0,0,0],[1,0,0,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
VAR socketdev server_socket;
VAR socketdev client_socket;
PROC main()
! SocketCreate server_socket;
! Move all axis into their start position.
MoveAbsJ [[0,0,0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]],vmax,z0,tool0;
! We turn of `Configuration Joint` and `Configuration Linear` which
! means that the robot can use different confirations than that which
! was programmed.
ConfJ\Off;
ConfL\Off;
! Rotate the `tcp` around the world Y-axis so that X will point
! down and Z forwad. This gives us move freedom to move the
! robot.
myRobtarget.rot := OrientZYX(0, 90, 0);
MoveJ myRobtarget,vmax,fine,tool0\WObj:=myWobj;
MoveL Offs(myRobtarget,0, -680, -300),vmax,z0,tool0, \WObj:=myWobj;
MoveL Offs(myRobtarget,0, 680, -300),vmax,z0,tool0, \WObj:=myWobj;
MoveL Offs(myRobtarget,0, 680, 220),vmax,z0,tool0, \WObj:=myWobj;
MoveL Offs(myRobtarget,0, -680, 220),vmax,z0,tool0, \WObj:=myWobj;
! Move the robot using the coordinates of the tool. In the current situation
! X is pointing up/down, Y left right.
! MoveL RelTool(myRobtarget, 0, -600, 0\Rx:=-30), vmax, z0, tool0, \WObj:=myWobj;
! MoveL RelTool(myRobtarget, 0, 600, 0\Rx:=30), vmax, z0, tool0, \WObj:=myWobj;
ENDPROC
! Socket communication: http://forums.robotstudio.com/discussion/2613/socket-communication-in-robot-studio
! The code below can be read as follows:
! The `myRobTarget` is the position to which the `tcp` should be moved relative to the
! given `myWobj`. The `myWobj` defines the orientation in which we will move. By using this
! optional `WObj` we make sure that the 0,0,0 is relative to `myWobj`, so this is just [400,0,400]
! TASK PERS wobjdata myWobj:=[FALSE,TRUE,"",[[400,0,400],[1,0,0,0]],[[0,0,0],[1,0,0,0]]];
! CONST robtarget myRobtarget:=[[0,0,0],[0.707107,0,0.707107,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
!
! object.rot := OrientZYX(0, 90, 0);
! TPWrite "O.q1: "\Num:=object.rot.q1; ! prints 0.707107
! TPWrite "O.q2: "\Num:=object.rot.q2; ! prints 0
! TPWrite "O.q3: "\Num:=object.rot.q3; ! prints 0.707107
! MoveJ myRobtarget,vmax,fine,tool0\WObj:=myWobj;
! Sockets http://forums.robotstudio.com/discussion/comment/23263#Comment_23263
ENDMODULE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment