Two-way physics path control

Hello,

I would like to model a physics conveyor with a two direction path. As there is no standard behaviour for a two way PhysicsPath, I tryed to change the ordered list of Frame features in the path property.
With this approach, I have to rebuild the component every time I change the direction. The performance of the simulation drops significantly. Is there a way to just update the property “Path” of the PhysicsPath-behaviour and not have to rebuild the whole component every time?

I also found out that if I leave the property-window of the PhysicsPath open while the simulation is running, I no longer need the rebuild method.

PyhtonScript:
comp = getComponent()
path = comp.findBehaviour(‘PhysicsPath’)

#Frames
start = comp.findFeature(‘Start_Frame’)
end = comp.findFeature(‘End_Frame’)

def forward():
path.Path = [start, ende]
path.Enabled = True
comp.rebuild()

def backward():
path.Path = [ende, start]
path.Enabled = True
comp.rebuild()

def off():
path.Enabled = False

Layout - Dualing Physics Paths.vcmx (64.0 KB)

I would not change the frames. Like you said, very costly. And I doubt you would see that done in any eCat component.

Let’s talk about bottle return machine. Create Physics Path going one direction. Another Physics Path going opposite direction. Use signals to turn paths on/off. You can even get crazy and not turn them off at all and modify their speeds.

Avoid scripting if you can, and let the good times roll.

1 Like

Thanks for your response zesty!

I’ve tried this exact approach, but haven’t had any success with it. :thinking: I don’t know what I did wrong back then. This is actually how it works. Thank you!

Regarding the speed:
Is it possible to change them during the simulation without having to rebuild the component? As in my previous code? (I have a PLC connected that transfers a target speed to the conveyor)

Thanks in advance!

If you tried to do it via scripting, physics can be tricky with the Python API.

Idk about the rebuild. The Physics Conveyor in the VC eCat allows you to change speed using Real property “ConveyorSpeed” that will trigger rebuild when value is changed. The value change event has a handler in the script that sets the Physics Path “Speed” property to the value of ConveyorSpeed.

It is a behavior update, and the speed change would need to be updated in simulation. I don’t think it should require node rebuild and feature tree evaluation, but I’m not the best person to speak on this.

What PLC are you using if I may ask?

I’ve also seen the approach with the value change event in the Physics Conveyor in VC eCat. But here I also had the problem that the component was rebuilt. But I’m no longer sure whether I turned the option “Rebuild” in the property “Conveyor Speed” off or not.

Setting the speed to the path via Python also seems to work that way and does not require a rebuilding of the component. I will now use this approach.

I use a Siemens S7 with OPC UA.

Many thanks for the help!

Physics path allows also negative speed that drivers the conveyor to opposite direction e.g.:

def OnRun():
  path = getComponent().findBehaviour('PhysicsPath')
  path.Speed = 400.0
  delay(5.0)
  path.Speed = -150.0
  delay(5.0)
  path.Speed = 500.0
4 Likes

@jouha i can’t wait to find it in documentation and unlock the secrets that are negative speed and absolute values. alas, i can finally simulate a bottle return machine not accepting Freeway cola bottles and Saku bought in Estonia. so the Speed property also controls direction…
tim-and-eric-mind-blown

1 Like

would be very helpful if such information were included in the documentation. That would have saved me a lot of time … :wink:

Maybe someone can change the topic name in pyhsics path two-way-direction?