Set synchronous mode automatically in multi-gpu
This commit is contained in:
parent
9c9eda84bc
commit
4ea29070d2
|
@ -15,7 +15,6 @@ namespace carla {
|
||||||
namespace client {
|
namespace client {
|
||||||
|
|
||||||
ServerSideSensor::~ServerSideSensor() {
|
ServerSideSensor::~ServerSideSensor() {
|
||||||
log_warning("calling sensor destructor ", GetDisplayId());
|
|
||||||
if (IsAlive() && IsListening()) {
|
if (IsAlive() && IsListening()) {
|
||||||
log_warning(
|
log_warning(
|
||||||
"sensor object went out of the scope but the sensor is still alive",
|
"sensor object went out of the scope but the sensor is still alive",
|
||||||
|
|
|
@ -99,10 +99,9 @@ void FCarlaEngine::NotifyInitGame(const UCarlaSettings &Settings)
|
||||||
{
|
{
|
||||||
// we are secondary server, connecting to primary server
|
// we are secondary server, connecting to primary server
|
||||||
bIsPrimaryServer = false;
|
bIsPrimaryServer = false;
|
||||||
Secondary = std::make_shared<carla::multigpu::Secondary>(
|
|
||||||
PrimaryIP,
|
// define the commands executor (when a command comes from the primary server)
|
||||||
PrimaryPort,
|
auto CommandExecutor = [=](carla::multigpu::MultiGPUCommand Id, carla::Buffer Data) {
|
||||||
[=](carla::multigpu::MultiGPUCommand Id, carla::Buffer Data) {
|
|
||||||
struct CarlaStreamBuffer : public std::streambuf
|
struct CarlaStreamBuffer : public std::streambuf
|
||||||
{
|
{
|
||||||
CarlaStreamBuffer(char *buf, std::size_t size) { setg(buf, buf, buf + size); }
|
CarlaStreamBuffer(char *buf, std::size_t size) { setg(buf, buf, buf + size); }
|
||||||
|
@ -151,7 +150,14 @@ void FCarlaEngine::NotifyInitGame(const UCarlaSettings &Settings)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
Secondary = std::make_shared<carla::multigpu::Secondary>(
|
||||||
|
PrimaryIP,
|
||||||
|
PrimaryPort,
|
||||||
|
CommandExecutor
|
||||||
|
);
|
||||||
|
|
||||||
Secondary->Connect();
|
Secondary->Connect();
|
||||||
// set this server in synchronous mode
|
// set this server in synchronous mode
|
||||||
bSynchronousMode = true;
|
bSynchronousMode = true;
|
||||||
|
@ -216,20 +222,31 @@ void FCarlaEngine::OnPreTick(UWorld *, ELevelTick TickType, float DeltaSeconds)
|
||||||
TRACE_CPUPROFILER_EVENT_SCOPE_STR(__FUNCTION__);
|
TRACE_CPUPROFILER_EVENT_SCOPE_STR(__FUNCTION__);
|
||||||
if (TickType == ELevelTick::LEVELTICK_All)
|
if (TickType == ELevelTick::LEVELTICK_All)
|
||||||
{
|
{
|
||||||
// process RPC commands
|
|
||||||
if (bIsPrimaryServer)
|
if (bIsPrimaryServer)
|
||||||
{
|
{
|
||||||
|
if (CurrentEpisode && !bSynchronousMode && SecondaryServer->HasClientsConnected())
|
||||||
|
{
|
||||||
|
// set synchronous mode
|
||||||
|
CurrentSettings.bSynchronousMode = true;
|
||||||
|
CurrentSettings.FixedDeltaSeconds = 1 / 20.0f;
|
||||||
|
OnEpisodeSettingsChanged(CurrentSettings);
|
||||||
|
CurrentEpisode->ApplySettings(CurrentSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
// process RPC commands
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Server.RunSome(10u);
|
Server.RunSome(1u);
|
||||||
}
|
}
|
||||||
while (bSynchronousMode && !Server.TickCueReceived());
|
while (bSynchronousMode && !Server.TickCueReceived());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// process frame data
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Server.RunSome(10u);
|
Server.RunSome(1u);
|
||||||
}
|
}
|
||||||
while (!FramesToProcess.size());
|
while (!FramesToProcess.size());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue