Open yuyuyu223 opened 3 months ago
Hi,
there seems to be a race condition in the Lua part of the function. We will fix this in the next version, until then, you can use the following version of the getFullCameraRequest
function (replace the definition in %BNG_HOME%/lua/ge/extensions/tech/sensors.lua
with this one):
local function getFullCameraRequest(sensorId)
Engine.Annotation.enable(true)
AnnotationManager.setInstanceAnnotations(false)
local semanticData = Research.GpuRequestManager.sendBlockingCameraGpuRequest(sensorId)
AnnotationManager.setInstanceAnnotations(true)
local instanceData = Research.GpuRequestManager.sendBlockingCameraGpuRequest(sensorId)
AnnotationManager.setInstanceAnnotations(false)
Engine.Annotation.enable(false)
local out = {}
out['colour'] = instanceData['colour']
out['annotation'] = semanticData['annotation']
out['depth'] = instanceData['depth']
out['instance'] = instanceData['annotation']
return out
end
Also, if you do not need both the instance and object annotation readings, you should use the Camera.poll
function, the GetFullCameraRequest
is much slower.
To avoid despawning the other vehicles, you can make them transparent instead. Try whether this function works for your usecase:
def set_visibility(beamng: BeamNGpy, vehicle: Vehicle, alpha: float):
beamng.queue_lua_command(f'core_vehicle_partmgmt.setHighlightedPartsVisiblity({alpha}, scenetree.findObject("{vehicle.vid}"):getID())')
set_visibility(beamng, ego, 0.0) # make invisible
set_visibility(beamng, ego, 1.0) # make visible
I used pop to avoid affecting the ego car:
traffic_cars.pop("ego")
But what is puzzling is that the other cars in the scene are still visible, while the ego car actually becomes invisible, I want to know what exactly happened.
for car in traffic_cars.values():
set_visibility(beamng, car, 0.0)
Sorry, there has been an error in the set_visibility
function, try this version:
def set_visibility(beamng: BeamNGpy, vehicle: Vehicle, alpha: float):
beamng.queue_lua_command(f'core_vehicle_partmgmt.setHighlightedPartsVisiblity({alpha}, scenetree.findObject("{vehicle.vid}"):getID())')
Also, you should ensure that traffic_cars = beamng.get_current_vehicles()
is called after all the traffic vehicles are spawned.
I want to hide the specified car when shooting with the camera. I bound the camera to the ego car and removed the remaining cars before shooting with the camera. However, the following error message will appear. How can I implement this function? Does beamng have a visible interface?
I used traffic flow and captured all participating vehicles:
I retrieve vehicle information through the following code, and then delete the vehicle:
Then I capture images:
But I received the following error message:![image](https://github.com/BeamNG/BeamNGpy/assets/60428269/629946c3-c621-4af2-bb15-dbbc23ecc6a3)
BeamNG 0.31.3 BeamNGpy 1.28