In order to set the default pozyx tag, we need to clear all of the pozyx inputs when the user selects a new pozyx tag, otherwise, pozyx inputs happily continues to use the existing default value.
These are the inputs coming from api-input.StartTrackerVisual() — the two lines are 64-65:
The actual map function is defined in dc-inputs.ENTITY_TO_COBJ (line 242)
Essentially I believe what I want to do is force the objects to be removed so that they can get recreated.
Explanation
SyncMaps don't have the notion of being able to reset their source, probably, as each connected device is considered to be a constant source of input data that is managed behind the scenes.
If I understand correctly you want to reset the buffer in a SyncMap instance.
Looks like you need to add code to the class that calls the MappedPool instance. There are two calls in the statement for line 171 that will give you an idea:
Essentially you need to get all the allocated objects. This segment of the class-mapped-pool shows how the sync is generating a list of objects that have beeb marked for deletion:
So you would write something like this in class-mapped-pool
and then expose it in class-syncmap though I see there is already a clearMappedObjects() call there that just calls pool.reset()... I'm not sure if ther mapping has to be more precise; clearing the pool probably just works becauase the next updated will then run the remove commands.
The only other user of the existing clearMappedObjects() in SyncMap is in ac-bueprints via sim-agents for clearing the renderer displaylist.
So you might just try calling SyncMap.clearMappedObjects() and see if that does what you want.
Providing an empty array to the call to syncFromArray() doesn't work because it's a sync operation, not a set operation. This runs with partial inputs and dropped frames, so it explicitly has to check that something has disappeared from PTrack by aging it.
If you start with [o1, o2 o3] on frame 1, then pass [], the SyncMap assumes that there just wasn't any update and increments the age on the entries its maintaining on o1, o2, o3.
POZYX might have a more explicit add/drop protocol which is why you'd want to move it out of in-ptrack
I did try SyncMap.clearMappedObjects, but I think while that'll clear the mapped objects, the source objects remain, so I think they simply get recreated via the update (at least that's what I think is happening). The simpler solution is probably to force a project reload.
If that’s the case, then the method I suggested of purposely removing them should work. You may have to add the ability to disable ptrack, do the purge of the pool using the deallocate, switch the source, then turn it back on. There is also a “seen objects” collection that is maintaining the persistence in syncmap.
Ptrack runs async which is why you need to do extra guards because your ui code probably isn’t synced to it…the way input is designed is so you don’t have to do that type of sync as is pretty tricky to do it cleanly.
See slack discussion
The Problem
In order to set the default pozyx tag, we need to clear all of the pozyx inputs when the user selects a new pozyx tag, otherwise, pozyx inputs happily continues to use the existing default value. These are the inputs coming from
api-input.StartTrackerVisual()
— the two lines are 64-65:The actual map function is defined in
dc-inputs.ENTITY_TO_COBJ
(line 242) Essentially I believe what I want to do is force the objects to be removed so that they can get recreated.Explanation
SyncMaps don't have the notion of being able to reset their source, probably, as each connected device is considered to be a constant source of input data that is managed behind the scenes.
If I understand correctly you want to reset the buffer in a SyncMap instance.
Looks like you need to add code to the class that calls the MappedPool instance. There are two calls in the statement for line 171 that will give you an idea:
Essentially you need to get all the allocated objects. This segment of the
class-mapped-pool
shows how the sync is generating a list of objects that have beeb marked for deletion:So you would write something like this in class-mapped-pool
and then expose it in
class-syncmap
though I see there is already aclearMappedObjects()
call there that just callspool.reset()
... I'm not sure if ther mapping has to be more precise; clearing the pool probably just works becauase the next updated will then run the remove commands. The only other user of the existingclearMappedObjects()
in SyncMap is in ac-bueprints via sim-agents for clearing the renderer displaylist. So you might just try callingSyncMap.clearMappedObjects()
and see if that does what you want. Providing an empty array to the call to syncFromArray() doesn't work because it's a sync operation, not a set operation. This runs with partial inputs and dropped frames, so it explicitly has to check that something has disappeared from PTrack by aging it.If you start with [o1, o2 o3] on frame 1, then pass [], the SyncMap assumes that there just wasn't any update and increments the age on the entries its maintaining on o1, o2, o3.
POZYX might have a more explicit add/drop protocol which is why you'd want to move it out of
in-ptrack
I did try
SyncMap.clearMappedObjects
, but I think while that'll clear the mapped objects, the source objects remain, so I think they simply get recreated via the update (at least that's what I think is happening). The simpler solution is probably to force a project reload.If that’s the case, then the method I suggested of purposely removing them should work. You may have to add the ability to disable ptrack, do the purge of the pool using the deallocate, switch the source, then turn it back on. There is also a “seen objects” collection that is maintaining the persistence in syncmap.
Ptrack runs async which is why you need to do extra guards because your ui code probably isn’t synced to it…the way input is designed is so you don’t have to do that type of sync as is pretty tricky to do it cleanly.