Teach Instruction via API
Saibel
✭
in RobotStudio
Hi!
How to teach a Move instruction via API? I have found how to set active tool, wobj, task and path. But what shall I do next?
Thanks a lot!
Best regards,
Sergej Saibel
Sergej Saibel
0
Comments
-
Hi Saibel
Here is code for teaching targets in API
Private Sub CreateTarget(ByVal X As Single, ByVal y As Single, ByVal Z As Single)
' Check that we have an active station
Dim CurX As Single
Dim CurY As Single
Dim CurZ As Single
Dim CurRX As Single
Dim CurRY As Single
Dim CurRZ As Single
X = X / 1000
y = y / 1000
Z = Z / 1000
Dim station As Station = Project.ActiveProject
If station Is Nothing Then
Exit Sub
End If
Dim activeTask As RsTask = station.ActiveTask
If activeTask Is Nothing Then
Exit Sub
End If
' ' Find an unused name
Dim targetName As String = ""
For i As Int32 = 0 To Int32.MaxValue
targetName = "Jim_1A_" + i.ToString()
If activeTask.DataDeclarations.Contains(targetName) = False Then
Exit For
End If
Next
'Get current TCP position.
' ' Create a robtarget
Dim robTarget As New RsRobTarget()
Dim trans1 As Quaternion
robTarget.Name = targetName
' Add the robtarget to the active task
activeTask.DataDeclarations.Add(robTarget)
' Create a target associated with the robtarget and the active workobject
Dim workObject As RsWorkObject = station.ActiveTask.DataDeclarations("Wobj0")
Dim myTarget As New RsTarget(workObject, robTarget)
myTarget.Name = targetName
' Add the target to the active task
activeTask.Targets.Add(myTarget)
Logger.AddMessage(New LogMessage("Created " + targetName + " in " + activeTask.Name))
' If the task has an active path procedure, create a new move instruction and add it
Dim path As RsPathProcedure = activeTask.ActivePathProcedure
If path IsNot Nothing Then
Dim tool As RsToolData = activeTask.ActiveTool
CurX = tool.Frame.GlobalMatrix.t.x
CurY = tool.Frame.GlobalMatrix.t.y
CurZ = tool.Frame.GlobalMatrix.t.z
trans1 = tool.Frame.GlobalMatrix.Quaternion
'CurRX = tool.Frame.GlobalMatrix.EulerZYX.x
'CurRY = tool.Frame.GlobalMatrix.EulerZYX.y
'CurRZ = tool.Frame.GlobalMatrix.EulerZYX.z
myTarget.Transform.X = X
myTarget.Transform.Y = y
myTarget.Transform.Z = Z
Dim procDef As RsProcessDefinition = activeTask.ActiveProcessDefinition
Dim procTempl As RsProcessTemplate = procDef.ActiveProcessTemplate
Dim moveInstr As New RsMoveInstruction(activeTask, procDef.Name, _
procTempl.Name, procTempl.ActiveMotionType, _
workObject.Name, robTarget.Name, tool.Name)
path.Instructions.Add(moveInstr)
End If
End Sub
BR KlausBest Regards
Klaus Soenderhegn
www.cadalysator.dk0 -
Thanks!Some questions:
Dim tool As RsToolData = activeTask.ActiveTool
CurX = tool.Frame.GlobalMatrix.t.x
CurY = tool.Frame.GlobalMatrix.t.y
CurZ = tool.Frame.GlobalMatrix.t.z
Here vi get tool position related to wobj0, not to our work object, isnt' it?Another question is axis configurations, are they missed here?Do you know if it's possible just to "click" on the Teach Instruction button control via API?Best regards,
Sergej Saibel0 -
Hi Sergej.First no there ain't any axis config and second i don't know, but you can read the current pos of the robot and then use this sub to teach a new target.BR KlausBest Regards
Klaus Soenderhegn
www.cadalysator.dk0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 786 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings