Hey, I have the following piece of code that works as intended if the commented lines with the println
statements are included. If they are commented out the if
statement that compares the dictionaries evaluates to true
only once and then never again. However, it does if the println
statements are included as mentioned above, which doesn’t make sense to me at all.
I know there are large pieces of code missing but I don’t know how to transform this into a minimal example as there are a lot of things happening under the hood. My guess is something related to compilation that is easy to spot for a proficient Julia programmer.
@kwdef mutable struct PoseLimitedDatasetIterationState{TWrappedDataset <: AbstractSimulationFrameDataset, VS, N <: Integer}
sensor_locations_wgs84::Dict{String, Tuple{Float64, Float64}} = Dict{String, Tuple{Float64, Float64}}()
sensor_rotations_deg::Dict{String, Float64} = Dict{String, Float64}()
sensor_heights_m::Dict{String, Float64} = Dict{String, Float64}()
wrapped_dataset_iterator::Iterators.Stateful{TWrappedDataset, VS, N}
end
function Base.iterate(dataset::PoseLimitedSimulationFrameDataset)
return iterate(dataset, PoseLimitedDatasetIterationState(wrapped_dataset_iterator = Iterators.Stateful(dataset.dataset)))
end
function Base.iterate(dataset::PoseLimitedSimulationFrameDataset, state::PoseLimitedDatasetIterationState)
dataset_iteration_tuple = nothing
end_wrapped_iteration = false
start_time = time()
while !end_wrapped_iteration && !isempty(state.wrapped_dataset_iterator)
wrapped_dataset_iteration_value = popfirst!(state.wrapped_dataset_iterator)
simulation_frame = get_simulation_frame(dataset)
if !isnothing(simulation_frame)
sensor_locations_wgs84 = Dict{String, Tuple{Float64, Float64}}(map(n -> n => get_sensor_location_wgs84(simulation_frame, n), get_sensor_names(simulation_frame)))
sensor_rotations_deg = Dict{String, Float64}(map(n -> n => get_sensor_rotation_deg(simulation_frame, n), get_sensor_names(simulation_frame)))
sensor_heights_m = Dict{String, Float64}(map(n -> n => get_sensor_height_m(simulation_frame, n), get_sensor_names(simulation_frame)))
if state.sensor_locations_wgs84 != sensor_locations_wgs84 || state.sensor_rotations_deg != sensor_rotations_deg || state.sensor_heights_m != sensor_heights_m
state.sensor_locations_wgs84 = sensor_locations_wgs84
state.sensor_rotations_deg = sensor_rotations_deg
state.sensor_heights_m = sensor_heights_m
dataset_iteration_tuple = (wrapped_dataset_iteration_value, state)
end_wrapped_iteration = true
# println("new pose")
# else
# println("no new pose")
end
end
# this yield statements does the trick to
# yield()
if time() - start_time > dataset.timeout_s
end_wrapped_iteration = true
end
end
return dataset_iteration_tuple
end