Error in script that controls robot action based on HMI button

I am trying to turnoff a robot arm through VR HMI by connecting the signals through an additional “PowerSignal” signal. I programmed “IsEnabled” property to reflect the status of the button … thinking that it would stop the robot’s operations/routine altogether.

Is my judgement right? If yes, what do you think is causing the error?

Expected Behaviour: red robot stops moving when the button is clicked
Current Behaviour: red robot continues working regardless of the button’s state
Visual Components Version: 4.5 Premium
07-02.vcmx (1.3 MB)

Action Script for HH30L #4 (My code starts after the comment “define the powerSignal”):

#  Action Script v. 2021-08-16 (yyyy-mm-dd)
#
#  Generic Action (grasp,release,mount,unmount,traceon,traceoff, sweptvolumeon, sweptvolumeoff) execution
#  by triggering a specific robot output with a specific value
#    Default Signal mapping:
#      signals 01...16: grasp/release
#      signals 17...32: trace_on/trace_off
#      signals 33...48: mount_tool/unmount_tool
#      signals 49...80: trace_extTCP_on/trace_extTCP_off
#      signal  81:      swept_volume_on/swept_volume_off
#
from vcScript import *
import vcVector
import vcMatrix

global grasp_association
from collections import defaultdict
comp = getComponent()
app = getApplication()
sim = getSimulation()
normal_vec = vcVector.new(0,0,1)
default_detection_volume = vcVector.new(50,50,50)
EPSILON = 10e-5

controller_flange_node = None
flange_node_tool_interface = None
detection_volume_tool = None
detection_volume_tools_list = []

ignore_as_release_target_filter_props = ['ExcludeRobotReleasingTo']
ignore_as_grasp_object_filter_props = ['ExcludeRobotGrasping']


# Define the powerSignal
signal = getComponent().getBehaviour("PowerSignal")
if signal.Value == False:
  IsEnabled = True
else:
  IsEnabled = False

.
.
.
.

Hi,

Your definition is on global scope so it runs only once upon saving/compiling (thus, nothing happens when you click it). Now, when you start clicking on the actual signal itself you have to “catch” the signal via an event. This event is called OnSignal that gives you a type of VcSignal as its argument.

image

Now you can filter out the signal types and give whatever logic you wish via if statements. You can also check this thread on emergency stops with robots:

br,
Lefa

1 Like

Thanks for the detailed help.

I managed to get the function working, just need to program the logic for stop/start.