Add more options to CARLA settings
This commit is contained in:
parent
1473aa7c39
commit
2443345126
|
@ -16,8 +16,14 @@ UseNetworking=true
|
|||
; the command-line switch `-world-port=N`, write and read ports will be set to
|
||||
; N+1 and N+2 respectively.
|
||||
WorldPort=2000
|
||||
WritePort=2001
|
||||
ReadPort=2002
|
||||
; Time-out in milliseconds for the networking operations.
|
||||
ServerTimeOut=10000
|
||||
; In synchronous mode, CARLA waits every tick until the control from the client
|
||||
; is received.
|
||||
SynchronousMode=true
|
||||
; Send info about every non-player agent in the scene every frame. Slows down
|
||||
; the simulation significantly.
|
||||
SendNonPlayerAgentsInfo=false
|
||||
|
||||
[CARLA/LevelSettings]
|
||||
; Path of the vehicle class to be used for the player. Leave empty for default.
|
||||
|
|
|
@ -114,7 +114,8 @@ void CarlaGameController::Tick(float DeltaSeconds)
|
|||
check(GameState != nullptr);
|
||||
if (Errc::Error == Server->SendMeasurements(
|
||||
*GameState,
|
||||
Player->GetPlayerState())) {
|
||||
Player->GetPlayerState(),
|
||||
CarlaSettings->bSendNonPlayerAgentsInfo)) {
|
||||
Server = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,7 +242,8 @@ static void GetAgentInfo(
|
|||
|
||||
CarlaServer::ErrorCode CarlaServer::SendMeasurements(
|
||||
const ACarlaGameState &GameState,
|
||||
const ACarlaPlayerState &PlayerState)
|
||||
const ACarlaPlayerState &PlayerState,
|
||||
const bool bSendNonPlayerAgentsInfo)
|
||||
{
|
||||
// Measurements.
|
||||
carla_measurements values;
|
||||
|
@ -259,7 +260,9 @@ CarlaServer::ErrorCode CarlaServer::SendMeasurements(
|
|||
Set(player.intersection_offroad, PlayerState.GetOffRoadIntersectionFactor());
|
||||
|
||||
TArray<carla_agent> Agents;
|
||||
GetAgentInfo(GameState, Agents);
|
||||
if (bSendNonPlayerAgentsInfo) {
|
||||
GetAgentInfo(GameState, Agents);
|
||||
}
|
||||
values.non_player_agents = (Agents.Num() > 0 ? Agents.GetData() : nullptr);
|
||||
values.number_of_non_player_agents = Agents.Num();
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@ public:
|
|||
|
||||
ErrorCode SendMeasurements(
|
||||
const ACarlaGameState &GameState,
|
||||
const ACarlaPlayerState &PlayerState);
|
||||
const ACarlaPlayerState &PlayerState,
|
||||
bool bSendNonPlayerAgentsInfo);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -88,8 +88,9 @@ static void LoadSettingsFromConfig(
|
|||
ConfigFile.GetBool(S_CARLA_SERVER, TEXT("UseNetworking"), Settings.bUseNetworking);
|
||||
ConfigFile.GetInt(S_CARLA_SERVER, TEXT("WorldPort"), Settings.WorldPort);
|
||||
ConfigFile.GetInt(S_CARLA_SERVER, TEXT("ServerTimeOut"), Settings.ServerTimeOut);
|
||||
ConfigFile.GetBool(S_CARLA_SERVER, TEXT("SynchronousMode"), Settings.bSynchronousMode);
|
||||
}
|
||||
ConfigFile.GetBool(S_CARLA_SERVER, TEXT("SynchronousMode"), Settings.bSynchronousMode);
|
||||
ConfigFile.GetBool(S_CARLA_SERVER, TEXT("SendNonPlayerAgentsInfo"), Settings.bSendNonPlayerAgentsInfo);
|
||||
// LevelSettings.
|
||||
ConfigFile.GetString(S_CARLA_LEVELSETTINGS, TEXT("PlayerVehicle"), Settings.PlayerVehicle);
|
||||
ConfigFile.GetInt(S_CARLA_LEVELSETTINGS, TEXT("NumberOfVehicles"), Settings.NumberOfVehicles);
|
||||
|
@ -203,6 +204,7 @@ void UCarlaSettings::LogSettings() const
|
|||
UE_LOG(LogCarla, Log, TEXT("World Port = %d"), WorldPort);
|
||||
UE_LOG(LogCarla, Log, TEXT("Server Time-out = %d ms"), ServerTimeOut);
|
||||
UE_LOG(LogCarla, Log, TEXT("Synchronous Mode = %s"), EnabledDisabled(bSynchronousMode));
|
||||
UE_LOG(LogCarla, Log, TEXT("Send Non-Player Agents Info = %s"), EnabledDisabled(bSendNonPlayerAgentsInfo));
|
||||
UE_LOG(LogCarla, Log, TEXT("[%s]"), S_CARLA_LEVELSETTINGS);
|
||||
UE_LOG(LogCarla, Log, TEXT("Player Vehicle = %s"), (PlayerVehicle.IsEmpty() ? TEXT("default") : *PlayerVehicle));
|
||||
UE_LOG(LogCarla, Log, TEXT("Number Of Vehicles = %d"), NumberOfVehicles);
|
||||
|
|
|
@ -80,7 +80,11 @@ public:
|
|||
* client is received.
|
||||
*/
|
||||
UPROPERTY(Category = "CARLA Server", VisibleAnywhere, meta = (EditCondition = bUseNetworking))
|
||||
bool bSynchronousMode = false;
|
||||
bool bSynchronousMode = true;
|
||||
|
||||
/** Send info about every non-player agent in the scene every frame. */
|
||||
UPROPERTY(Category = "CARLA Server", VisibleAnywhere, meta = (EditCondition = bUseNetworking))
|
||||
bool bSendNonPlayerAgentsInfo = false;
|
||||
|
||||
/// @}
|
||||
// ===========================================================================
|
||||
|
|
|
@ -16,6 +16,9 @@ import carla_server_pb2 as carla_protocol
|
|||
|
||||
|
||||
CarlaSettings = """
|
||||
[CARLA/Server]
|
||||
SynchronousMode=true
|
||||
SendNonPlayerAgentsInfo=false
|
||||
[CARLA/LevelSettings]
|
||||
NumberOfVehicles=10
|
||||
NumberOfPedestrians=20
|
||||
|
@ -172,6 +175,7 @@ def test_carla_client():
|
|||
logging.info('received non-initialized measurements')
|
||||
else:
|
||||
logging.info('received valid measurements')
|
||||
logging.info('received info of %d agents', len(data.non_player_agents))
|
||||
logging.info('waiting for images')
|
||||
data = client.read_images()
|
||||
logging.info('received %d bytes of images', len(data) if data is not None else 0)
|
||||
|
|
Loading…
Reference in New Issue