Simulation timer variable


I am working with Visual Components and OPC-UA connectivity. I have programmed a trajectory in Visual Components and connected the joint variables with their respective variables from my OPC-UA server written in VScode to be able to read the joint values as the robot moves.

I am looking for a variable that is able to, preferably, store the simulation time which I can store the same way I store the joint values. By this I mean that I would like some sort of a counter that shows how fast or slow the simulation is, depending on what speed I choose. If this is not possible, I would like to store a true/false value which outputs true if the simulation is running, and false if the simulation is not running.

I have searched for both these alternatives, but I have not found any variables that are related to the simulation…

I hope I was able to explain my question clearly, thanks for any help!

Simulation time is discrete, i.e. it jumps from one value to another, and can change thousands of times per real time second.

To sample the simulation time at some reasonable interval, you’ll need to make a simple Python script that reads the current value from API and writes it to a signal, which you can then send out using Connectivity.

Or in fact you can just make a simulation time “timer” by having a loop in Python script OnRun() that uses delay to “wake up” at certain interval in simulation time and write new value to a signal.

See the example on vcSimulation page of the Python API help file. You will need VC Professional or better.

Thank you for your answer. I am having trouble understanding how I can write value to signal.

Under “modeling” in component graph, I have tried adding a signal from “behaviors”. The signal lies within the robot node which is the “base” node. I have also added a script as in the example of the vcSimulation page.

When running the simulation, I get the output:

IsRunning True 0.0
IsRunning True 1.0

I am however not able to retrieve any signal when pairing variables and running simulation, so I am assuming I’m not actually assigning the values to a signal.

Do you have any tips on how to do this?

You will need to learn basics of Python scripting in VC and signal behaviors.

Take a look at these tutorials for example, and the vcSignal page in the Python API reference.