I want to get the origin position of the part (which grasped to the robot) and set the position of it to the new base of robot. Later, I want to use this base for programming the robot with external TCP.
I am new to python programming, so I appreciate the help.
The python API can be daunting when you are just starting to use it. I would recommend taking your time and exploring the Python API documentation in the help file to familiarize with the commands. Many of the pages there have example code at the bottom of the page that you can copy to your python scripts to get a better understanding on what is happening.
The relevant python commands here are related to the component container (vcComponentContainer) and the robot controller bases (vcRobotController.Bases). You can get access to these behaviours with the findBehaviour() method. I made an example layout for you and the base setting code goes as follows:
from vcScript import *
comp = getComponent()
def cont_trans(part, arrive):
print part.Name, arrive
base1.Node = part
print base1.Name, 'Node set to', part.Name
controller = comp.findBehaviour('Controller')
bases = controller.Bases
base1 = bases
container = comp.findBehaviour('GraspContainer')
container.OnTransition = cont_trans
Hope this helps!
Dynamic_base_example.vcmx (837.1 KB)