Track icons along SVG path?

Hello,

I need to track icons along certain SVG paths that are representative of real-world position.

I'm given tags for each "icon" which represent the object's absolute position relative to the start of the each path, which will help me determine how far along the path my icon should be. I'm using a view canvas to populate the vehicle icons on the view.

Is there a way to get the position of the track at a certain distance from its origin and set the x and y values of my view canvas instance to that position?

you are highlighting path, but that is a path to a file, not the drawing of the track no?

It would be quite easy with js... Idk if there is something similar with python
SVGGeometryElement.getPointAtLength()

maybe one of these

1 Like

Are you looking for infinitely variable position (difficult on a path) or discreet possible positions which could be stored in a lookup table with columns PositionId, X, Y.

... the object's absolute position relative to the start ...

Absolute or relative? It can't be both.

1 Like

It's an icon component that points to an SVG drawing of the paths.

I was thinking that I may need to use the javascript injection hack with that getPointAtLength() method...

The millimeter position stored in the tag that I'm reading from is the distance (length along the track) that the object is away from the path's origin. It's a single value - not a set of coordinates

If the value were coordinates that were on the path, this would be very easy to do in a single SVG, or even with CSS.

As it is translating a single relative length to a coordinate on the path is not trivial.

You didn't really answer my question whether or not the positions are discreet.

The millimeter position ...

So will a precision of 1 mm be adequate?

... is the distance (length along the track) that the object is away from the path's origin.

I understood this to mean the linear distance travelled along a closed loop.

It's a single value - not a set of coordinates.

The distance travelled may be a single value but its position on your SVG path will be a pair of (x, y) coordinates. That's why I proposed a lookup table.

2 Likes

I understand your question now. A lookup table would theoretically work for this, and a precision of 1mm would be adequate. I imagine that building this table and retrieving from it at the scan rate of my PLC would be cumbersome on the host machine (especially with all of the other tags I'm reading into components on embedded views on this canvas) given the resolution of 1mm across an entire plant layout. The possible positions for my object are indeed discrete 1mm values.

You can control the amount of data being handled by setting an appropriate Tag Group (used to be called Scan Class) - with, say, a 5 s update rate - for reading the position tags. Further reduction in traffic can be achieved by setting the tag group's Mode to Leased.

On the tags themselves you can set a deadband of 5 mm or 100 mm (depending on the scale of your operation and resolution required). That way the tags won't update unless there's a significant change and - depending on how you set it up - the Perspective client won't re-evaluate the position because the tag won't have changed. And, the larger you make the deadband, the smaller your lookup table has to be as you will have fewer discrete positions.

You'll have to determine how to round the actual position values to the nearest lookup table position - but that shouldn't be too difficult.

1 Like

A further thought: If you do the position rounding in the PLC you would simplify the Ignition side of the application. You could have the PLC round to an INT value in multiples of 5 or whatever and set your Ignition tag deadband quite low as the PLC is, effectively, determining the deadband.

1 Like