World: world methods will use same timeout as client
The world methods: tick, wait_for_tick and apply_settings will use the timeout defined in the client but they still allow to define a custom one.
This commit is contained in:
parent
af26ae35bf
commit
15be33e874
|
@ -53,6 +53,10 @@ namespace client {
|
||||||
uint64_t World::ApplySettings(const rpc::EpisodeSettings &settings, time_duration timeout) {
|
uint64_t World::ApplySettings(const rpc::EpisodeSettings &settings, time_duration timeout) {
|
||||||
rpc::EpisodeSettings new_settings = settings;
|
rpc::EpisodeSettings new_settings = settings;
|
||||||
uint64_t id = _episode.Lock()->SetEpisodeSettings(settings);
|
uint64_t id = _episode.Lock()->SetEpisodeSettings(settings);
|
||||||
|
|
||||||
|
time_duration local_timeout = timeout.milliseconds() == 0 ?
|
||||||
|
_episode.Lock()->GetNetworkingTimeout() : timeout;
|
||||||
|
|
||||||
if (settings.fixed_delta_seconds.has_value()) {
|
if (settings.fixed_delta_seconds.has_value()) {
|
||||||
using namespace std::literals::chrono_literals;
|
using namespace std::literals::chrono_literals;
|
||||||
|
|
||||||
|
@ -68,7 +72,7 @@ namespace client {
|
||||||
if (tics_correct >= 2)
|
if (tics_correct >= 2)
|
||||||
return id;
|
return id;
|
||||||
|
|
||||||
Tick(timeout);
|
Tick(local_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_warning("World::ApplySettings: After", number_of_attemps, " attemps, the settings were not correctly set. Please check that everything is consistent.");
|
log_warning("World::ApplySettings: After", number_of_attemps, " attemps, the settings were not correctly set. Please check that everything is consistent.");
|
||||||
|
@ -129,7 +133,10 @@ namespace client {
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldSnapshot World::WaitForTick(time_duration timeout) const {
|
WorldSnapshot World::WaitForTick(time_duration timeout) const {
|
||||||
return _episode.Lock()->WaitForTick(timeout);
|
time_duration local_timeout = timeout.milliseconds() == 0 ?
|
||||||
|
_episode.Lock()->GetNetworkingTimeout() : timeout;
|
||||||
|
|
||||||
|
return _episode.Lock()->WaitForTick(local_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t World::OnTick(std::function<void(WorldSnapshot)> callback) {
|
size_t World::OnTick(std::function<void(WorldSnapshot)> callback) {
|
||||||
|
@ -141,7 +148,9 @@ namespace client {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t World::Tick(time_duration timeout) {
|
uint64_t World::Tick(time_duration timeout) {
|
||||||
return _episode.Lock()->Tick(timeout);
|
time_duration local_timeout = timeout.milliseconds() == 0 ?
|
||||||
|
_episode.Lock()->GetNetworkingTimeout() : timeout;
|
||||||
|
return _episode.Lock()->Tick(local_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::SetPedestriansCrossFactor(float percentage) {
|
void World::SetPedestriansCrossFactor(float percentage) {
|
||||||
|
|
|
@ -271,7 +271,7 @@ void export_world() {
|
||||||
.def("get_random_location_from_navigation", CALL_RETURNING_OPTIONAL_WITHOUT_GIL(cc::World, GetRandomLocationFromNavigation))
|
.def("get_random_location_from_navigation", CALL_RETURNING_OPTIONAL_WITHOUT_GIL(cc::World, GetRandomLocationFromNavigation))
|
||||||
.def("get_spectator", CONST_CALL_WITHOUT_GIL(cc::World, GetSpectator))
|
.def("get_spectator", CONST_CALL_WITHOUT_GIL(cc::World, GetSpectator))
|
||||||
.def("get_settings", CONST_CALL_WITHOUT_GIL(cc::World, GetSettings))
|
.def("get_settings", CONST_CALL_WITHOUT_GIL(cc::World, GetSettings))
|
||||||
.def("apply_settings", &ApplySettings, (arg("settings"), arg("seconds")=10.0))
|
.def("apply_settings", &ApplySettings, (arg("settings"), arg("seconds")=0.0))
|
||||||
.def("get_weather", CONST_CALL_WITHOUT_GIL(cc::World, GetWeather))
|
.def("get_weather", CONST_CALL_WITHOUT_GIL(cc::World, GetWeather))
|
||||||
.def("set_weather", &cc::World::SetWeather)
|
.def("set_weather", &cc::World::SetWeather)
|
||||||
.def("get_snapshot", &cc::World::GetSnapshot)
|
.def("get_snapshot", &cc::World::GetSnapshot)
|
||||||
|
@ -280,10 +280,10 @@ void export_world() {
|
||||||
.def("get_actors", &GetActorsById, (arg("actor_ids")))
|
.def("get_actors", &GetActorsById, (arg("actor_ids")))
|
||||||
.def("spawn_actor", SPAWN_ACTOR_WITHOUT_GIL(SpawnActor))
|
.def("spawn_actor", SPAWN_ACTOR_WITHOUT_GIL(SpawnActor))
|
||||||
.def("try_spawn_actor", SPAWN_ACTOR_WITHOUT_GIL(TrySpawnActor))
|
.def("try_spawn_actor", SPAWN_ACTOR_WITHOUT_GIL(TrySpawnActor))
|
||||||
.def("wait_for_tick", &WaitForTick, (arg("seconds")=10.0))
|
.def("wait_for_tick", &WaitForTick, (arg("seconds")=0.0))
|
||||||
.def("on_tick", &OnTick, (arg("callback")))
|
.def("on_tick", &OnTick, (arg("callback")))
|
||||||
.def("remove_on_tick", &cc::World::RemoveOnTick, (arg("callback_id")))
|
.def("remove_on_tick", &cc::World::RemoveOnTick, (arg("callback_id")))
|
||||||
.def("tick", &Tick, (arg("seconds")=10.0))
|
.def("tick", &Tick, (arg("seconds")=0.0))
|
||||||
.def("set_pedestrians_cross_factor", CALL_WITHOUT_GIL_1(cc::World, SetPedestriansCrossFactor, float), (arg("percentage")))
|
.def("set_pedestrians_cross_factor", CALL_WITHOUT_GIL_1(cc::World, SetPedestriansCrossFactor, float), (arg("percentage")))
|
||||||
.def("get_traffic_sign", CONST_CALL_WITHOUT_GIL_1(cc::World, GetTrafficSign, cc::Landmark), arg("landmark"))
|
.def("get_traffic_sign", CONST_CALL_WITHOUT_GIL_1(cc::World, GetTrafficSign, cc::Landmark), arg("landmark"))
|
||||||
.def("get_traffic_light", CONST_CALL_WITHOUT_GIL_1(cc::World, GetTrafficLight, cc::Landmark), arg("landmark"))
|
.def("get_traffic_light", CONST_CALL_WITHOUT_GIL_1(cc::World, GetTrafficLight, cc::Landmark), arg("landmark"))
|
||||||
|
|
Loading…
Reference in New Issue