RoboDK Forum
Python API - External Axis- Printable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API)
+--- Thread: Python API - External Axis (/Thread-Python-API-External-Axis)



Python API - External Axis-Nox-06-05-2019

Hi everyone,
I'm wondering what's the proper way to move an external axis (Mechanism - 3 linear axis (only using 2), without any robot synced). I'm considering this mechanism as another robot. It only has movement on X and Y axis.

Right now I'm having troubles with making targets (it says a lot that the target is not reachable, even when I move the robot manually and teach the current position) and when I try to use move commands with [x,y,0,0,0,0] it actually moves the reference frame of the mechanism and not the mechanism.

I hope that you can understand what I'm saying, thanks!


RE: Python API - External Axis-davidmurray-06-05-2019

Perhaps unrelated, but RoboDK seems to need some time to update positions. We have a linear rail (1 axis), and updating the rail's pose takes some time, so I added a delay:

Code:
pose = robodk.UR_2_Pose([x, 0, 0, 0, 0, 0])
self.rail.setPose(pose)

# HACK: If we don't do this, RoboDK says that we are out of reach.
time.sleep(0.25)

# Insert your robot moves here



RE: Python API - External Axis-Albert-06-12-2019

David,
The delay you mention provokes a render (by default, any delay longer than 0.1 seconds). Instead, you can replace this delay by anUpdateor渲染call. Update is the most efficient call in this case and will simply update the position internally so that you can verify accessibility or move the robot. The Render command will provoke an update and also display the screen.

Nox,
You need to create a target if you want to specify the position of external axes. This example written in Python will give you an idea:

Code:
from robolink import * # RoboDK API
from robodk import * # Robot toolbox
RDK = Robolink()

# Retrieve the robot, reference frame and create a program
robot = RDK.Item('', ITEM_TYPE_ROBOT)
reference = robot.Parent()

# Create a new program
program = RDK.AddProgram('Test')

#定义一个reference pose
pos = transl(100,200,300)*rotx(pi)

# Turn Off automatic rendering (faster)
RDK.Render(False)

# Don't show instructions (faster)
program.ShowInstructions(False)

# Specify the reference frame you want to use
program.setPoseFrame(reference)

for i in range(100):
targetname='Target %i' % i
target=RDK.AddTarget(targetname,reference,robot)
target.setPose(transl(i*100, 0, 0) * pos)

# Set the external axes
axes = [20, i*100]

# For cartesian targets RoboDK will ignore robot joints but not external axes
all_axes = [0]*6 + axes
# Quick way to create an array:
# [0,0,0,0,0,0, ext_axis_1, ext_axis_2]

# Set the target and create a move instruction
target.setJoints(all_axes)
target.setAsCartesianTarget()
program.MoveL(target)

# If you are creating a long program, this helps keeping the tree small (faster)
if i % 20 == 0:
program.ShowTargets(False);

program.ShowTargets(False)

# Show program instructions at the end
program.ShowInstructions(True)