Python read IO from signals

Hi!

I am quite new to VC and stuck on a problem. I was wondering if someone can help me out.

I have a robot arm which I have given it’s own Boolean signal out. I want to connect this boolean to another part so I can activate the servo controller when the robot gives a true statement to the signal.

For some reason I can’t find anything about how connect this signal to the input. What am I doing wrong? Is there another function that I can use?

Are you trying to connect the signals via Python? Or are you trying to set a signals value?

Hello DennisP!
It seems to be a very strange way of writing, getApplication is missing “()”, and then about your question, it seems that you want to monitor the SignalMapIn of comp, but there is a problem, comp is a component type, which is vcComponent. You can check it by “print comp”. After pressing F1 to enter the help file, search for vcComponent. You will find that it does not have the properties or methods of SignalMapIn, so you should not listen to comp.
Search for SignalMapIn in the help file and you will find that it is a property of vcHelpers.Robot and vcHelpers.Robot2. That is to say, to use this property, you must be a robot component. As you can see, where you write this code, it is just a Simply an institution, not a robot. To use this attribute, first you need to have a robot controller instead of a servo, then get the robot handle through getRobot(), and finally listen to the SignalMapIn of this handle. This is what should be done when the component is a robot. But what we have to consider is that we don’t always want a moving component to be a complex robot. For simple components, we prefer it to be driven by a servo. Therefore, Visual Components also has another way to monitor SignalMap.
Near the location where the servo driver is generated, there is a function called “Executor”, which is generally used together with the driver (at least that’s what I do). When you open it, you will find that it has two properties, one is “DigitalInputSignals” The other one is “DigitalOutputSignals”, so, as you can imagine, by connecting the SignalMap to the Executor and then to the driver, you can work by listening to the Executor’s DigitalInputSignals property.
I hope my explanation can help you, and I wish you a good day! :melting_face:

1 Like

Im trying to set the signal value of input or output with a Python script. The functions I tried using all ended in errors. Im looking for a function to do this

You can find these infos and more in the article vcBoolSignal in the PythonAPI helpfile.

@BAD 's post refers to vcHelpers.Robot2, which you can read more about in this academy article:

1 Like

Thank you very much for your answer! I’m still very new to VC and Python so that probably explains the strange way of writing code. Still learning everyday :slight_smile: . Anyway thanks a lot for your explanation!

1 Like