-
Notifications
You must be signed in to change notification settings - Fork 289
Description
Describe the bug
When multiple cameras are simulated, the "cameras" and "visibleTargetPoses" on the debug field flicker.
To Reproduce
Steps to reproduce the behavior:
- Add multiple PhotonCameraSims to the VisionSystemSim by calling addCamera. Use different robotToCameras so they are not on top of each other and can be seen separately.
- Run the simulator.
- Look at the VisionSystemSim Sim Field.
- The cameras on the field flicker. It is a little hard to tell with the visibleTargetPoses, since they jump around a lot, but if not all of the cameras see the target, they will also flicker. Setting 0 calib error on the sim camera properties will make them not jump around to make the flicker more obvious.
The Cause
I am pretty sure the reason for this bug is with the way the update method in VisionSystemSim works. When it loops through the camSimMap.values(), it continues to the next loop if the optTimestamp is empty, which happens if it does not have a new camera frame to process. This means that it will not add the poses to the cameraPoses2d or visTgtPoses2d lists. For just one camera, this is fine, because it doesn't use the lists if they are empty, but for more than one, if one camera has a frame to process, then the camera and visible target poses for the other cameras won't be added to the list, and calling setPoses on the field object will clear the poses that weren't updated.