Beispiel #1
0
def robot_script():

    sel_pt = rs.GetPoint("select point")

    #1) Use 6 values
    pose1 = urs.pose(sel_pt.X, sel_pt.Y, sel_pt.Z, 0, 0, 0)
    #2) Use two tuples - vector and orientation
    pose2_pos = (sel_pt.X, sel_pt.Y, sel_pt.Z + 0.15)
    pose2 = urs.pose_by_vectors(pose2_pos, (0, 0, 0))
    #3) Use a Rhino plane
    plane3 = rg.Plane(sel_pt, rg.Vector3d.ZAxis)
    pose3 = urs.pose_by_plane(plane3)
    #4) Use an origin and 2 vectors - same as a plane
    pose4_pos = (sel_pt.X, sel_pt.Y - 0.15, sel_pt.Z + 0.15)
    pose4 = urs.pose_by_origin_axis(pose4_pos, (1, 0, 0), (0, 1, 0))
    #5) Use a listened pose
    pose5_vals = comm.listen(ip)['tool_pose']
    pose5 = urs.pose(*pose5_vals)

    #Create a list of statements
    commands = []
    poses = (pose1, pose2, pose3, pose4)
    #Go through all poses
    for i in range(len(poses)):
        #Add a comment
        commands.append(urs.comment("Movement {}".format(i)))
        #Add a command
        commands.append(urs.movel(poses[i]))
    # return to pose 5 via movej
    commands.append(urs.movej(pose5))

    #3) Create a program using commands as argument
    my_program = urs.create_function("main", commands)
    return my_program
Beispiel #2
0
	base [Generic Data] - A reference plane used as the basis for calculating target pose
	acceleration (in, optional) [Generic Data] - Optional. Tool accel in m/s^2
	velocity (in, optional) [Generic Data] - Optional. Tool speed in m/s
	radius (in, optional) [Generic Data] - Optional. Blend radius in m
Returns:
	out [Text] - The execution information, as output and error streams
	a [Generic Data] - Script variable Python
"""
import scriptcontext as sc
import urscript as ur
import Rhino.Geometry as rg
from Grasshopper.Kernel import GH_RuntimeMessageLevel as gh_msg

error_inputs = []
if not target: error_inputs.append('target')
if not base: error_inputs.append('base')

if not error_inputs:
    target_plane = rg.Plane(target)
    accel = float(accel) if accel else 1.2
    vel = float(vel) if vel else 0.3
    blend = float(radius) if radius else 0.0

    matrix = rg.Transform.PlaneToPlane(rg.Plane.WorldXY, base)
    target_plane.Transform(matrix)
    target_pose = ur.pose_by_plane(target_plane)
    a = ur.movep(target_pose, accel, vel, blend)
else:
    error_message = 'Failed to collect data for {0} required input(s): {1}'.format(
        len(error_inputs), ','.join(error_inputs))
    ghenv.Component.AddRuntimeMessage(gh_msg.Warning, error_message)
Beispiel #3
0
if not start: error_inputs.append('start')
if not end: error_inputs.append('end')

if not error_inputs:
    cut_accel = float(accel) if accel else 0.01
    cut_vel = float(vel) if vel else 0.0085
    cut_blend = float(radius) if radius else 0.01
    start_joints = [float(sj) for sj in start_joints]
    end_joints = [float(ej) for ej in end_joints]

    # Orient the cut planes with reference to robot base and create poses
    matrix = rg.Transform.PlaneToPlane(rg.Plane.WorldXY, base)
    print type(targets[0])
    initial_cut_plane = rg.Plane(targets[0])
    initial_cut_plane.Transform(matrix)
    initial_cut_pose = ur.pose_by_plane(initial_cut_plane)

    cut_planes = targets[1:]
    [cp.Transform(matrix) for cp in cut_planes]
    cut_poses = [ur.pose_by_plane(cp) for cp in cut_planes]

    commands = ur.statements(  #1) Approach start position
        ur.movej(start_joints, 3.0, 3.0),
        #2) Approach first cut pose
        ur.movel(initial_cut_pose, 0.1, 0.1),
        #3) Move through rest of cut poses
        [ur.servoc(cp, cut_accel, cut_vel, cut_blend) for cp in cut_poses],
        #4) Move to end position
        ur.movej(end_joints, 0.1, 0.15))

    a = commands
Beispiel #4
0
"""
Generate UR Script set_tcp (Tool Center Point) command 
Vers:20140307
Input:
	tool plane [Generic Data] - Plane that describes tool pose
Returns:
	out [Text] - The execution information, as output and error streams
	a [Generic Data] - Script variable Python
"""
import urscript as ur
from Grasshopper.Kernel import GH_RuntimeMessageLevel as gh_msg

if not plane:
    ghenv.Component.AddRuntimeMessage(
        gh_msg.Warning, 'Failed to collect data for required input: plane')
else:
    tool_pose = ur.pose_by_plane(plane)
    a = ur.set_tcp(tool_pose)