05-06-2022, 08:57 AM
the link here are the commands of robodk, it's based on Python, I think you will get very 'comfortable' to write in python since you have the backgroud of C.
//www.sinclairbody.com/doc/en/PythonAPI/robodk.html
我只使用其中的一些,例如:
connect to robot:
RDK = Robolink()
item = RDK.Item('base')
itemlist = RDK.ItemList()
robot = RDK.ItemUserPick('Select a robot', ITEM_TYPE_ROBOT)
to check if robot is connected, you can write a loop
while True:
success = robot.Connect()
time.sleep(X)
status, status_msg = robot.ConnectedState()
if status != ROBOTCOM_READY:
print(XXX)
else:
break
to execute progrom at robot directly:
RDK.setRunMode(RUNMODE_RUN_ROBOT)
to execute progrom at robodk:
RDK.setRunMode(RUNMODE_SIMULATE)
to set robot speed:
robot.setSpeed(a value)
'robot.setDO' to control digital IO
'robot.MoveJ(joints)' , 'robot.MoveL' to move robot, I wrote a function to do this:
def moverobot1(x_offset,y_offset,z_offset):
target_ref = robot.Pose()
pos_ref = target_ref.Pos()
robot_x = pos_ref[0]+x_offset
robot_y = pos_ref[1]+y_offset
robot_z = pos_ref[2]+z_offset
target_i = Mat(target_ref)
target_i.setPos([robot_x,robot_y,robot_z])
robot.MoveL(target_i)
def moverobotj(a_value,b_value,c_value):
target = robot.Pose()
xyzabc = Pose_2_Fanuc(target)
x,y,z,a,b,c = xyzabc
xyzabc2 = [x,y,z,a+a_value,b+b_value,c+c_value]
target2 = Fanuc_2_Pose(xyzabc2)
robot.MoveJ(target2)
'robot.Joints()' to get the position of robot, it return a 2D list [[x],[y],[z],[rx],[ry],[rz]], if you want to use it, you have to transfer it to 1D list: [x,y,z,rx,ry,rz]
joints_org = robot.Joints()
当你移动your robot to other position, and want to get back to this position : robot.MoveJ(joints_org)
'RelTool' to move rx,ry,rz, I don't know how to explain this. You can try it and you will know the difference between reltool and moveL/moveJ
target2 = robot.Pose()
target2= RelTool(target2,0,0,0,rz=angle value)
robot.MoveJ(target2)
this link was written for the beginner to connect
//www.sinclairbody.com/forum/Thread-CONNECT-...ht=timothy
it is what all I know about RoboDK
//www.sinclairbody.com/doc/en/PythonAPI/robodk.html
我只使用其中的一些,例如:
connect to robot:
RDK = Robolink()
item = RDK.Item('base')
itemlist = RDK.ItemList()
robot = RDK.ItemUserPick('Select a robot', ITEM_TYPE_ROBOT)
to check if robot is connected, you can write a loop
while True:
success = robot.Connect()
time.sleep(X)
status, status_msg = robot.ConnectedState()
if status != ROBOTCOM_READY:
print(XXX)
else:
break
to execute progrom at robot directly:
RDK.setRunMode(RUNMODE_RUN_ROBOT)
to execute progrom at robodk:
RDK.setRunMode(RUNMODE_SIMULATE)
to set robot speed:
robot.setSpeed(a value)
'robot.setDO' to control digital IO
'robot.MoveJ(joints)' , 'robot.MoveL' to move robot, I wrote a function to do this:
def moverobot1(x_offset,y_offset,z_offset):
target_ref = robot.Pose()
pos_ref = target_ref.Pos()
robot_x = pos_ref[0]+x_offset
robot_y = pos_ref[1]+y_offset
robot_z = pos_ref[2]+z_offset
target_i = Mat(target_ref)
target_i.setPos([robot_x,robot_y,robot_z])
robot.MoveL(target_i)
def moverobotj(a_value,b_value,c_value):
target = robot.Pose()
xyzabc = Pose_2_Fanuc(target)
x,y,z,a,b,c = xyzabc
xyzabc2 = [x,y,z,a+a_value,b+b_value,c+c_value]
target2 = Fanuc_2_Pose(xyzabc2)
robot.MoveJ(target2)
'robot.Joints()' to get the position of robot, it return a 2D list [[x],[y],[z],[rx],[ry],[rz]], if you want to use it, you have to transfer it to 1D list: [x,y,z,rx,ry,rz]
joints_org = robot.Joints()
当你移动your robot to other position, and want to get back to this position : robot.MoveJ(joints_org)
'RelTool' to move rx,ry,rz, I don't know how to explain this. You can try it and you will know the difference between reltool and moveL/moveJ
target2 = robot.Pose()
target2= RelTool(target2,0,0,0,rz=angle value)
robot.MoveJ(target2)
this link was written for the beginner to connect
//www.sinclairbody.com/forum/Thread-CONNECT-...ht=timothy
it is what all I know about RoboDK