diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/TheNewCarlaServer.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/TheNewCarlaServer.cpp index d140df8f7..d761341fc 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/TheNewCarlaServer.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/TheNewCarlaServer.cpp @@ -117,6 +117,16 @@ void FTheNewCarlaServer::FPimpl::BindActions() return carla::version(); }); + // ~~ Tick ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Server.BindSync("tick_cue", [this]() -> R + { + ++TickCuesReceived; + return R::Success(); + }); + + // ~~ Load new episode ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Server.BindAsync("get_available_maps", [this]() -> R> { const auto MapNames = UCarlaStatics::GetAllMapNames(); @@ -129,12 +139,6 @@ void FTheNewCarlaServer::FPimpl::BindActions() return result; }); - Server.BindSync("tick_cue", [this]() -> R - { - ++TickCuesReceived; - return R::Success(); - }); - Server.BindSync("load_new_episode", [this](const std::string &map_name) -> R { REQUIRE_CARLA_EPISODE(); @@ -145,6 +149,8 @@ void FTheNewCarlaServer::FPimpl::BindActions() return R::Success(); }); + // ~~ Episode settings and info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Server.BindSync("get_episode_info", [this]() -> R { REQUIRE_CARLA_EPISODE(); @@ -193,6 +199,8 @@ void FTheNewCarlaServer::FPimpl::BindActions() return Episode->SerializeActor(ActorView); }); + // ~~ Weather ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Server.BindSync("get_weather_parameters", [this]() -> R { REQUIRE_CARLA_EPISODE(); @@ -217,6 +225,8 @@ void FTheNewCarlaServer::FPimpl::BindActions() return R::Success(); }); + // ~~ Actor operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Server.BindSync("get_actors_by_id", [this]( const std::vector &ids) -> R> { @@ -309,6 +319,8 @@ void FTheNewCarlaServer::FPimpl::BindActions() return R::Success(); }); + // ~~ Actor physics ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Server.BindSync("set_actor_location", [this]( cr::Actor Actor, cr::Location Location) -> R @@ -411,8 +423,7 @@ void FTheNewCarlaServer::FPimpl::BindActions() return R::Success(); }); - - Server.BindSync("get_physics_control", [this]( + Server.BindSync("get_physics_control", [this]( cr::Actor Actor) -> R { REQUIRE_CARLA_EPISODE(); @@ -469,6 +480,8 @@ void FTheNewCarlaServer::FPimpl::BindActions() return R::Success(); }); + // ~~ Apply control ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Server.BindSync("apply_control_to_vehicle", [this]( cr::Actor Actor, cr::VehicleControl Control) -> R @@ -536,6 +549,8 @@ void FTheNewCarlaServer::FPimpl::BindActions() return R::Success(); }); + // ~~ Traffic lights ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Server.BindSync("set_traffic_light_state", [this]( cr::Actor Actor, cr::TrafficLightState trafficLightState) -> R @@ -631,6 +646,34 @@ void FTheNewCarlaServer::FPimpl::BindActions() return R::Success(); }); + Server.BindSync("get_group_traffic_lights", [this]( + const cr::Actor Actor) -> R> + { + REQUIRE_CARLA_EPISODE(); + auto ActorView = Episode->GetActorRegistry().Find(Actor.id); + if (!ActorView.IsValid() || ActorView.GetActor()->IsPendingKill()) + { + RESPOND_ERROR("unable to get group traffic lights: actor not found"); + } + auto TrafficLight = Cast(ActorView.GetActor()); + if (TrafficLight == nullptr) + { + RESPOND_ERROR("unable to get group traffic lights: actor is not a traffic light"); + } + std::vector Result; + for (auto TLight : TrafficLight->GetGroupTrafficLights()) + { + auto View = Episode->FindActor(TLight); + if (View.IsValid()) + { + Result.push_back(View.GetActorId()); + } + } + return Result; + }); + + // ~~ Logging and playback ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Server.BindSync("start_recorder", [this](std::string name) -> R { REQUIRE_CARLA_EPISODE(); return R(Episode->StartRecorder(name)); @@ -677,31 +720,7 @@ void FTheNewCarlaServer::FPimpl::BindActions() follow_id)); }); - Server.BindSync("get_group_traffic_lights", [this]( - const cr::Actor Actor) -> R> - { - REQUIRE_CARLA_EPISODE(); - auto ActorView = Episode->GetActorRegistry().Find(Actor.id); - if (!ActorView.IsValid() || ActorView.GetActor()->IsPendingKill()) - { - RESPOND_ERROR("unable to get group traffic lights: actor not found"); - } - auto TrafficLight = Cast(ActorView.GetActor()); - if (TrafficLight == nullptr) - { - RESPOND_ERROR("unable to get group traffic lights: actor is not a traffic light"); - } - std::vector Result; - for (auto TLight : TrafficLight->GetGroupTrafficLights()) - { - auto View = Episode->FindActor(TLight); - if (View.IsValid()) - { - Result.push_back(View.GetActorId()); - } - } - return Result; - }); + // ~~ Draw debug shapes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Server.BindSync("draw_debug_shape", [this](const cr::DebugShape &shape) -> R {