vcRobotSelectionService

Properties

Name Type Access Description
ActiveExecutor vcBehaviour RW Gets or sets active robot executor
ActiveController vcBehaviour RW Gets or sets active robot executor

Events

Name Parameters Description
OnActiveExecutorChanged None Triggered when robot active executor changes
OnActiveControllerChanged None Triggered when robot active controller changes

Examples

Example. Select active robot and controller, also observe their changes

from vcScript import *
from vcCommand import *
 
global app
app = getApplication()
 
def setActiveExecutor(robotName):
    robotSelectionService = app.RobotSelectionService
    robotComp = app.findComponent(robotName)
    exes = robotComp.findBehavioursByType(VC_ROBOTEXECUTOR)
    robotSelectionService.ActiveExecutor = exes[0]
 
def setActiveController(robotName):
    robotSelectionService = app.RobotSelectionService
    robotComp = app.findComponent(robotName)
    controllers = robotComp.findBehavioursByType(VC_ROBOTCONTROLLER)
    robotSelectionService.ActiveController = controllers[0]
 
def OnActiveExecutorChanged():
    global robotSelectionService
    print(robotSelectionService.ActiveExecutor.Component.Name + "'s executor")
 
def OnActiveControllerChanged():
    global robotSelectionService
    print(robotSelectionService.ActiveController.Component.Name + "'s controller")
 
# put in local variable so service won't die
robotSelectionService = app.RobotSelectionService
 
robotSelectionService.OnActiveExecutorChanged = OnActiveExecutorChanged
robotSelectionService.OnActiveControllerChanged = OnActiveControllerChanged