vcHelpers.Robot2
vcHelpers.Robot2 is a library of useful classes and methods designed to simplify common robot programming tasks.
Constructors
vcRobot is the object type used for programming a robot, its controller and executor with this library.
Name | Return Type | Parameters | Description |
getRobot | vcHelpers.Robot.vcRobot | String interface_name
or vcComponent robot_component or [no argument] |
Creates a new vcRobot object for a given component which must have a robot executor.
One option is to give the name of an interface a robot is connected to in a component as an argument, for example a robot mounted on a pedestal. If found, the robot connected at the interface is used by the constructor. A second option is to give the component of a robot you want to program as an argument. A third option is to not give any argument, thereby a component owning the script is used by the constructor. |
Properties
Name | Type | Access | Description |
Acc | Real | RW | Defines the Cartesian acceleration of robot for linear movements. |
ActiveTool | String/Integer | RW | Defines the active tool frame of robot by referencing the name or index of a tool frame in Tools property. |
AngularAcc | Real | RW | Defines the angular acceleration of robot for linear movements. |
AngularSpeed | Real | RW | Defines the angular speed of robot for linear movements. |
Bases | List of vcBaseFrame | R | Gets a list of all base frames available in robot. |
Component | vcComponent | R | Gets the component of robot. |
Configuration | String/Integer | RW | Defines the configuration of robot.
Set this property to None to use the current configuration of the robot. Note: The default configuration is -1/last configuration in ConfigurationsList. |
ConfigurationsList | List of String | R | Gets a list of robot's configurations by name. |
Controller | vcRobotController | R | Gets the controller of robot. |
Executor | vcExecutor | R | Gets the executor of robot. |
GraspContainer | vcContainer | RW | Defines the Component Container behavior in the robot's flange node used to contain components grabbed by the robot. |
Joints | List of vcJoint | R | Gets a list of joints used by robot. |
JointForce | Real | RW | Defines the joint force (0-100%) used by robot for joint/point-to-point movements. |
JointSpeed | Real | RW | Defines the joint speed (0-100%) used by robot for joint/point-to-point movements. |
MotionTime | Real | RW | Defines a time used for scaling the acceleration and speed of robot motions to match the given time.
If zero value, a motion's acceleration and speed determines its motion time. That is, this property has no effect. |
RecordRoutine | String | RW | Defines a sequence in the robot where new statements are added when RecordRSL is set to True.
This property must be defined before setting RecordRSL to True. You can refer to the main routine of robot program as 'MainRoutine', the name of an existing subroutine, or give a name for a new subroutine that will be created during the recording. |
RecordRSL | Boolean | RW | Defines if actions executed by the robot are recorded as statements in the robot's program.
If True, statements are added to a routine defined by RecordRoutine. |
SignalMapIn | vcBooleanSignalMap | R | Gets the Boolean Signal Map behavior used for robot inputs. |
SignalMapOut | vcBooleanSignalMap | R | Gets the Boolean Signal Map behavior used for robot outputs. |
Speed | Real | RW | Defines the Cartesian speed used by the robot for linear movements. |
Tools | List of vcBaseFrame | R | Gets a list of the robot's tool frames. |
Methods
Name | Return Type | Parameters | Description |
callSubRoutine | None | String rName | Calls a predefined routine by name in the robot's program. |
comment | None | String comment | Prints a given comment to the Output panel and records a Comment statement for this action in the robot's program. |
delay | None | Real delay | Executes a timed delay (in seconds) and records a Delay statement for this action in the robot's program. |
driveJoints | None | [Real j1], [Real j2], [Real j3], [Real j4], [Real j5], [Real j6], [Real motiontime], [Boolean relative], [Real ExtraJoints] | Drives one or more joints in the robot to given target values.
If no value is given for a joint, the current value of the joint is used by the robot. Optional arguments j1 to j6 are target values for joints 1 through 6 in a robot, with six joints being common in articulated robots. An optional motiontime argument can be given to scale the acceleration and speed of the robot's motion to match the given time. The default value is zero in which scaling is disabled. An optional relative argument can be used to set target values as relative to the current value of each joint. The default value is False in which target values are absolute joint values. An optional ExtraJoints argument can be given as a list of joint values for additional joints in a robot, for example external joints of a robot mounted on a track and remotely connected to a workpiece positioner. Tip: Joints can be individually driven by controller; see methods in vcServoController. |
followNode | None | vcNode Basenode, [Real FollowTime] | Defines a node in the 3D world to be followed by the robot for a set amount of time.
An optional FollowTime argument can be given to set the amount of time the robot should follow the target node. The default value is 1.0/one second. |
getConfigNames | List of String | vcExecutor executor, vcRobotController controller | Returns a list of available configurations by name for the robot. |
graspComponent | None | vcComponent graspthis | Grasps a given component using robot. |
graspComponents | None | List of vcComponent graspthese | Grasps a given list of components using the robot. |
jointMoveRel | None | [Real Tx], [Real Ty], [Real Tz], [Real Rx], [Real Ry], [Real Rz] | Executes a joint movement relative to the current pose of robot based in active tool's coordinate system.
Optional arguments Tx, Ty and Tz are translation movements in the XYZ coordinate axes. Optional arguments Rx, Ry and Rz are rotation offsets for the XYZ coordinate axes. |
jointMoveToComponent | None | vcNode ToComp, [Real Tx], [Real Ty], [Real Tz], [Real Rx], [Real Ry], [Real Rz], [vcFeature/String ToFrame], [String OnFace] | Executes a joint movement to a given component, which by default is the component's origin.
Optional arguments Tx, Ty and Tz are offsets for target position. The default value for translations is zero. Optional arguments Rx, Ry and Rz are offsets for target orientation. The default value for rotations is zero. An optional ToFrame argument can be used to set the target location to be a Frame feature in a component. A Frame feature can be given as a vcFeature object or referenced by name. An optional OnFace argument can be used to set the target location to be a face of a component's bound box. A bound box face can be referenced by using one of six recognized names (top, bottom, left, right, front, back). If ToFrame and OnFace arguments are given, the method will first try to use ToFrame. |
jointMoveToMtx | None | [vcMatrix ToMtx], [Real Tx], [Real Ty], [Real Tz], [Real Rx], [Real Ry], [Real Rz], [String CS] | Executes a joint movement to a given target matrix, otherwise the 3D world origin.
An optional ToMtx argument defines the target matrix in the selected coordinate system for this method. By default, the identity matrix is based on World origin. Optional arguments Tx, Ty and Tz are offsets for target matrix position. The default value for translations is zero. Optional arguments Rx, Ry and Rz are offsets for target matrix orientation. The default value for rotations is zero. An optional CS argument can be used to set the coordinate system used for target calculation, which by default is the World coordinate system. The argument can be either "world" or "irobot" which is the robot's coordinate system. |
jointMoveToPosition | None | Real Tx, Real Ty, Real Tz, Real Rx, Real Ry, Real Rz, String CS | Executes a joint movement to a target defined by given XYZ coordinate values and roll, pitch and yaw values based in a given coordinate system.
The Tx, Ty and Tz arguments define the target's XYZ coordinate values. The Rx, Ry and Rz arguments define the target's orientation or ABC values. Rx Ry Rz The CS argument defines the coordinate system used for target calculation, which default is World coordinate system. The argument can be either "world" or "irobot" which is the robot's coordinate system. After the target is calculated, a point-to-point motion statement is created in the robot's program which uses the robot's first indexed tool frame. The orientation of that tool frame can affect the TargetABC properties of the motion statement. |
linearMoveRel | None | Real Tx, Real Ty, Real Tz, Real Rx, Real Ry, Real Rz | Executes a linear movement relative to the current pose of robot based in active tool's coordinate system.
The Tx, Ty and Tz arguments are translation movements in XYZ coordinate axes. The Rx, Ry and Rz arguments are rotation offsets for XYZ coordinate axes. |
linearMoveToComponent | None | vcNode ToComp, [Real Tx], [Real Ty], [Real Tz], [Real Rx], [Real Ry], [Real Rz], [vcFeature/String ToFrame], [String OnFace] | Executes a linear movement to a given component, which by default is the component's origin.
Optional arguments Tx, Ty and Tz are offsets for target position. The default value for translations is zero. Optional arguments Rx, Ry and Rz are offsets for target orientation. The default value for rotations is zero. An optional ToFrame argument can be used to set the target location to be a Frame feature in a component. A Frame feature can be given as a vcFeature object or referenced by name. An optional OnFace argument can be used to set the target location to be a face of a component's bound box. A bound box face can be referenced by using one of six recognized names (top, bottom, left, right, front, back). If ToFrame and OnFace arguments are given, the method will first try to use ToFrame. |
linearMoveToMtx | None | [vcMatrix ToMtx], [Real Tx], [Real Ty], [Real Tz], [Real Rx], [Real Ry], [Real Rz], [String CS] | Executes a linear movement to a given target matrix, otherwise the 3D world origin.
An optional ToMtx argument defines the target matrix in the selected coordinate system for this method. By default, the identity matrix is based on World origin. Optional arguments Tx, Ty and Tz are offsets for target matrix position. The default value for translations is zero. Optional arguments Rx, Ry and Rz are offsets for target matrix orientation. The default value for rotations is zero. An optional CS argument can be used to set the coordinate system used for target calculation, which by default is the World coordinate system. The argument can be either "world" or "irobot" which is the robot's coordinate system. |
linearMoveToMtx_ExternalBase | None | vcNode Basenode, vcMatrix ToMtx, [Real Tx], [Real Ty], [Real Tz], [Real Rx], [Real Ry], [Real Rz] | Executes a linear movement to a given target matrix based in given node's coordinate system.
Generally, this method is used when a robot needs to motion to a moving part, for example a pallet on a conveyor. Optional arguments Tx, Ty and Tz are offsets for target matrix position. The default value for translations is zero. Optional arguments Rx, Ry and Rz are offsets for target matrix orientation. The default value for rotations is zero. |
linearMoveToPosition | None | Real Tx, Real Ty, Real Tz, Real Rx, Real Ry, Real Rz, String CS | Executes a linear movement to a target defined by given XYZ coordinate values and roll, pitch and yaw values based in a given coordinate system.
The Tx, Ty and Tz arguments define the target's XYZ coordinate values. The Rx, Ry and Rz arguments define the target's orientation or ABC values. Rx Ry Rz The CS argument defines the coordinate system used for target calculation, which default is World coordinate system. The argument can be either "world" or "irobot" which is the robot's coordinate system. After the target is calculated, a linear motion statement is created in the robot's program which uses the robot's first indexed tool frame. The orientation of that tool frame can affect the TargetABC properties of the motion statement. |
mountTool | None | vcComponent Tool | Mounts a given component to flange node of robot. |
moveAway | None | [Real Tz] | Executes a linear retraction movement relative to current pose of robot.
An optional Tz argument can be given to set retraction distance, which by default is 200. |
pick | None | vcComponent Part, [Real Approach], [Real Tx], [Real Ty], [Real Tz], [Real Rx], [Real Ry], [Real Rz], [String OnFace], [String ApproachAxis] | Executes a sequence of actions in order for robot to pick a given component.
Action 1 Action 2 Action 3 Action 4 All three motions executed by the robot are created dynamically during a simulation. By default, the robot will use an approach distance of 200 aligned to Z-axis in order to pick from the top face of a given component's bound box. The pick location can be offset using the optional Tx, Ty, Tz, Rx, Ry, and Rz arguments. An optional OnFace argument allows you to set which face of Part bound box to use for Action 2. An optional ApproachAxis argument sets the axis of alignment. |
pickFromPallet | vcComponent | vcComponent Pallet, [Real Approach], [Boolean InversedOrder], [Integer Index] | Executes a sequence of actions in order for the robot to pick a component from a given Pallet.
Action 1 Action 2 Action 3 Action 4 Action 5 Action 6 All three motions executed by the robot are created dynamically during a simulation. By default, the robot will use an approach distance of 200 to pick the last component of a list of child components for Pallet. An optional Approach argument can be used to change the approach and retract distance used by robot. An optional InversedOrder argument can be used to reverse the list of child components acquired in Action 1. A True value reverses the order, so last component attached to Pallet is first in list. The default value is False. An optional Index argument can be used to select which child component of Pallet is picked by robot. The default value is -1, so last component in Action 1 child components list. |
pickMovingPart | None | vcComponent Part, [Real Approach], [Real Tx], [Real Ty], [Real Tz], [Real Tz], [Real Rx], [Real Ry], [Real Rz] | Executes a sequence of actions in order for the robot to pick a given component that is not stationary.
Action 1 Action 2 Action 3 Action 4 All three motions executed by the robot are created dynamically during a simulation. By default, the robot will use an approach distance of 200 and calculate motion targets based on speed of Part. The pick location can be offset using the optional Tx, Ty, Tz, Rx, Ry, and Rz arguments. |
place | None | vcComponent ToComp, [Real Approach], [Real Tx], [Real Ty], [Real Tz], [Real Rx], [Real Ry], [Real Rz], [vcComponent Part], [String ApproachAxis] | Executes a sequence of actions in order for the robot to place a grasped component at a given component.
Action 1 Action 2 Action 3 Action 4 All three motions executed by the robot are created dynamically during a simulation. By default, a robot will use an approach distance of 200 and the bound box of grasped component to calculate motion targets. The place location can be offset using optional Tx, Ty, Tz, Rx, Ry, and Rz arguments. An optional Part argument can be used to define which component is placed to ToComp. The default is the first component listed in robot's GraspContainer. An optional ApproachAxis argument can be used to define the axis of alignment. |
placeInPattern | None | vcComponent ToComp, Integer X_index, Integer Y_index, Integer Z_index, Integer PatternSize_X, PatternSize_Y, Integer PatternSize_Z, [Real Approach], [vcComponent Part], [Real StepSizeX], [Real StepSizeY], [Real StepSizeZ], [Real Rz] | Executes a sequence of actions in order for the robot to place components in a given pattern.
Action 1 Action 2 Action 3 Action 4 All three motions executed by the robot are created dynamically during a simulation. By default, a robot will use an approach distance of 200, the bound box of grasped component and the given pattern to calculate motion targets. The X_index, Y_index and Z_index arguments define the index position for placing a component based on pattern size. The PatternSize_X, PatternSize_Y and PatternSize_Z arguments define the pattern size. An optional ApproachAxis argument can be used to define the axis of alignment. An optional Part argument can be used to define which component is placed to ToComp. The default is the first component listed in robot's GraspContainer. Optional StepSizeX, StepSizeY and StepSizeZ arguments can be used to define the pattern step size for XYZ axes. The default step size values are length, width and height of Part. An optional Rz argument can be used to define a Z-axis rotation offset for place location. |
releaseAllComponents | None | vcNode/vcContainer ToObject | Attaches all components of robot's GraspContainer to a given node or container type behavior.
If ToObject is a component, a target container is searched for automatically in the component. If not found, the components are directly attached to the given node. |
releaseComponent | None | vcNode/vcContainer ToObject, vcNode ReleaseThis | Attaches a component to a given node or container type behavior.
If ToObject is a component, a target container is searched for automatically in the component. If not found, the released component is directly attached to the given node. The ReleaseThis argument is the component to be detached from robot; otherwise the method will search the robot's GraspContainer. |
rsl_BinIn | None | Integer Index, Boolean Value | Waits for a signal mapped to a given port to have the given value.
The Index argument defines the port in the robot's inputs, Boolean Signal Map behavior. The Value argument defines the value that should be received at the port in order to complete execution. If RecordRSL is set to True, this action is recorded as a new input statement in the robot's program. |
rsl_BinOut | None | Integer Index, Boolean Value | Sends a given value to a signal mapped to a given port.
The Index argument defines the port in the robot's outputs, Boolean Signal Map behavior. The Value argument defines the value that should be sent to the mapped signal. If RecordRSL is set to True, this action is recorded as a new output statement in the robot's program. |
traceOff | None | Integer Index | Turns off the tracing of the robot's motions at given tool frame.
The Index argument defines the index position of a tool frame in the robot's Tools which is mapped to a port used for tracing. |
traceOn | None | Integer Index | Turns on the tracing of the robot's motions at given tool frame.
The Index argument defines the index position of a tool frame in the robot's Tools which is mapped to a port used for tracing. |
unmountTool | None | vcComponent Tool, vcContainer ToObject
or vcComponent Tool, vcComponent ToObject |
Dismounts a tool mounted on the robot to either a container type behavior or component.
The Tool argument needs to be a tool component mounted on the robot. |
Miscellaneous Methods
The following methods are functions that can be used by importing the vcHelpers.Robot library.
Name | Return Type | Parameters | Description |
getSelectedRobotsData | List of robot data (vcExecutor, vcRoutine, vcRobotController, String BaseName, String Toolname, List of String BaseNames, List of String ToolNames, Integer RobotConfig, List of String RobotConfigs) | None | Returns a list of data for the currently selected robot component in the 3D world.
The list of data contains the following: robot program, current routine, robot controller, name of active base frame, name of active tool frame, list of names for all base frames, list of names for all tool frames, index of current configuration, and list of names for all configurations. |
printMatrix | None | vcMatrix mtx | Prints a given matrix in a clear, readable format to the Output panel. |
Examples
Example. Control a robot with vcHelpers.Robot
#Place this code in a Python Script editor |
from vcScript import * from vcHelpers.Robot2 import * robot = getRobot() #move all 6 joints with method robot.driveJoints(0, 0, 90, 0, 45, 180) #moves 4th joint to 45 degrees via controller #joint numbering starts at 0, so 4th joint is numbered 3 robot.Controller.moveJoint(3, 45) #move extra joints, e.g robot connected to track robot.driveJoints(0, 0, 0, 0, 0, 0, 0, False, [-2000]) |
Example. Follow a Part with a Robot
from vcScript import * from vcHelpers.Robot2 import * #script is located in conveyor with sensor and signal comp = getComponent() app = getApplication() r = getRobot(app.findComponent("Articulated Robot")) def OnSignal(signal): global parts #get part if signal.Value == True: path = comp.findBehaviour("MainPath") node = path.Components[0] parts.append(node) def OnRun(): global parts parts = [] condition(lambda: parts) p = parts.pop(0) #move to part r.linearMoveToMtx_ExternalBase(p, Tz = 100, Ry = 180) #follow part r.followNode(p, 1) #grab part r.graspComponent(p) r.moveAway() |
Example. Set motion time for movements
robo = getRobot() robo.MotionTime = 3 robo.jointMoveToComponent('Part') |
Example. Record actions as statements in robot program
#pick a component named 'Part' robo = getRobot() part = getApplication().findComponent('Part') #define the location for RSL statements robo.RecordRoutine = 'MyRecordRoutine' robo.RecordRSL = True robo.jointMoveToComponent( part, Tz = 100) robo.linearMoveToComponent( part, Tz = 0) robo.graspComponent(part) robo.moveAway(100) |