Organize rpc bindings
This commit is contained in:
parent
365eecbb7f
commit
38963872ef
|
@ -117,6 +117,16 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
return carla::version();
|
||||
});
|
||||
|
||||
// ~~ Tick ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Server.BindSync("tick_cue", [this]() -> R<void>
|
||||
{
|
||||
++TickCuesReceived;
|
||||
return R<void>::Success();
|
||||
});
|
||||
|
||||
// ~~ Load new episode ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Server.BindAsync("get_available_maps", [this]() -> R<std::vector<std::string>>
|
||||
{
|
||||
const auto MapNames = UCarlaStatics::GetAllMapNames();
|
||||
|
@ -129,12 +139,6 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
return result;
|
||||
});
|
||||
|
||||
Server.BindSync("tick_cue", [this]() -> R<void>
|
||||
{
|
||||
++TickCuesReceived;
|
||||
return R<void>::Success();
|
||||
});
|
||||
|
||||
Server.BindSync("load_new_episode", [this](const std::string &map_name) -> R<void>
|
||||
{
|
||||
REQUIRE_CARLA_EPISODE();
|
||||
|
@ -145,6 +149,8 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
return R<void>::Success();
|
||||
});
|
||||
|
||||
// ~~ Episode settings and info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Server.BindSync("get_episode_info", [this]() -> R<cr::EpisodeInfo>
|
||||
{
|
||||
REQUIRE_CARLA_EPISODE();
|
||||
|
@ -193,6 +199,8 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
return Episode->SerializeActor(ActorView);
|
||||
});
|
||||
|
||||
// ~~ Weather ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Server.BindSync("get_weather_parameters", [this]() -> R<cr::WeatherParameters>
|
||||
{
|
||||
REQUIRE_CARLA_EPISODE();
|
||||
|
@ -217,6 +225,8 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
return R<void>::Success();
|
||||
});
|
||||
|
||||
// ~~ Actor operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Server.BindSync("get_actors_by_id", [this](
|
||||
const std::vector<FActorView::IdType> &ids) -> R<std::vector<cr::Actor>>
|
||||
{
|
||||
|
@ -309,6 +319,8 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
return R<void>::Success();
|
||||
});
|
||||
|
||||
// ~~ Actor physics ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Server.BindSync("set_actor_location", [this](
|
||||
cr::Actor Actor,
|
||||
cr::Location Location) -> R<void>
|
||||
|
@ -411,8 +423,7 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
return R<void>::Success();
|
||||
});
|
||||
|
||||
|
||||
Server.BindSync("get_physics_control", [this](
|
||||
Server.BindSync("get_physics_control", [this](
|
||||
cr::Actor Actor) -> R<cr::VehiclePhysicsControl>
|
||||
{
|
||||
REQUIRE_CARLA_EPISODE();
|
||||
|
@ -469,6 +480,8 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
return R<void>::Success();
|
||||
});
|
||||
|
||||
// ~~ Apply control ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Server.BindSync("apply_control_to_vehicle", [this](
|
||||
cr::Actor Actor,
|
||||
cr::VehicleControl Control) -> R<void>
|
||||
|
@ -536,6 +549,8 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
return R<void>::Success();
|
||||
});
|
||||
|
||||
// ~~ Traffic lights ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Server.BindSync("set_traffic_light_state", [this](
|
||||
cr::Actor Actor,
|
||||
cr::TrafficLightState trafficLightState) -> R<void>
|
||||
|
@ -631,6 +646,34 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
return R<void>::Success();
|
||||
});
|
||||
|
||||
Server.BindSync("get_group_traffic_lights", [this](
|
||||
const cr::Actor Actor) -> R<std::vector<cr::ActorId>>
|
||||
{
|
||||
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<ATrafficLightBase>(ActorView.GetActor());
|
||||
if (TrafficLight == nullptr)
|
||||
{
|
||||
RESPOND_ERROR("unable to get group traffic lights: actor is not a traffic light");
|
||||
}
|
||||
std::vector<cr::ActorId> 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<std::string> {
|
||||
REQUIRE_CARLA_EPISODE();
|
||||
return R<std::string>(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<std::vector<cr::ActorId>>
|
||||
{
|
||||
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<ATrafficLightBase>(ActorView.GetActor());
|
||||
if (TrafficLight == nullptr)
|
||||
{
|
||||
RESPOND_ERROR("unable to get group traffic lights: actor is not a traffic light");
|
||||
}
|
||||
std::vector<cr::ActorId> 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<void>
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue