Skip to content

Commit

Permalink
Merge pull request #74 from HARPLab/gamemode
Browse files Browse the repository at this point in the history
Improve general functionality and usability
  • Loading branch information
ajdroid committed Feb 17, 2023
2 parents 8b4a31b + 84653be commit 9e2e2bc
Show file tree
Hide file tree
Showing 191 changed files with 2,568 additions and 2,802 deletions.
Binary file removed Blueprints/Game/CarlaGameMode.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## DReyeVR 0.1.0 (for Carla 0.9.13)
- Replace existing `LevelScript` (`ADReyeVRLevel`) with `GameMode` (`ADReyeVRGameMode`). This allows us to not need to carry the (large) map blueprint files (ue4 binary) and we can use the vanilla Carla maps without modification. By default we spawn the EgoVehicle in the first of the recommended Carla locations, but this default behavior can be changed in the PythonAPI. For instance, you can delay spawning the EgoVehicle until via PythonAPI where you can specify the spawn transform. Existing functionality is preserved using `find_ego_vehicle` and `find_ego_sensor` which spawn the DReyeVR EgoVehicle if it does not exist in the world.
- Added `ADReyeVRFactory` as the Carla-esque spawning and registry functionality so the `EgoVehicle` and `EgoSensor` are spawned with the same "Factory" mechanisms as existing Carla vehicles/sensors/props/etc.
- Renamed DReyeVR-specific actors to be addressible in PythonAPI as `"harplab.dreyevr_$X.$id"` such as `"harplab.dreyevr_vehicle.model3"` and `"harplab.dreyevr_sensor.ego_sensor"`. Avoids conflicts with existing Carla PythonAPI scripts that may filter on `"vehicle.*"`.
- Moved all blueprint (`.uasset`) content out of the Carla content (which is now entirely untouched, no need to re-update) to a separate Content folder that lies in `/Game/Content/DReyeVR/` (renamed to support future DReyeVR blueprint changes without relying on Carla content).
- Adding check that SRanipal is within one of our recommended supported versions: `1.3.1.1`, `1.3.2.0`, & `1.3.3.0`. Also provided links in the documentation to download these versions. Additionally included a workaround for the old `patch-sranipal` which is now no longer needed.
- Added custom `LogDReyeVR` macros (`LOG`, `LOG_WARN`, `LOG_ERROR`) for improved logging with attached file, function, and line number to the message. Done in precompilation to avoid runtime performance overhead.
- Improved `make check` to ensure that a 1:1 file correspondence exists between Carla dest and DReyeVR source, and that all files have equal content.
- Improved vehicle dash with blinking turn signal and fixed bugs with inconsistent gear indicator.
- Fixed bugs and inconsistencies with replayer media control and special actions such as toggling reverse/turn signals in replay.
- Enabled cooking for `Town06` and `Town07` in package/shipping mode.
- Updated documentation and config file
233 changes: 0 additions & 233 deletions Carla/Actor/ActorRegistry.cpp

This file was deleted.

7 changes: 2 additions & 5 deletions Carla/Actor/DReyeVRCustomActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bool ADReyeVRCustomActor::AssignSM(const FString &Path, UWorld *World)
}
else
{
UE_LOG(LogTemp, Error, TEXT("Unable to create static mesh: %s"), *Path);
DReyeVR_LOG_ERROR("Unable to create static mesh: %s", *Path);
return false;
}
ADReyeVRCustomActor::AllMeshCount++;
Expand All @@ -98,14 +98,13 @@ void ADReyeVRCustomActor::AssignMat(const FString &MaterialPath)
for (int i = 0; i < MAX_POSSIBLE_MATERIALS; i++)
ActorMesh->SetMaterial(i, DynamicMat);
else
UE_LOG(LogTemp, Error, TEXT("Unable to access material asset: %s"), *MaterialPath)
DReyeVR_LOG_ERROR("Unable to access material asset: %s", *MaterialPath)
}

void ADReyeVRCustomActor::Initialize(const FString &Name)
{
Internals.Name = Name;
ADReyeVRCustomActor::ActiveCustomActors[TCHAR_TO_UTF8(*Name)] = this;
// UE_LOG(LogTemp, Log, TEXT("Initialized custom actor: %s"), *Name);
}

void ADReyeVRCustomActor::BeginPlay()
Expand All @@ -122,7 +121,6 @@ void ADReyeVRCustomActor::BeginDestroy()
void ADReyeVRCustomActor::Deactivate()
{
const std::string s = TCHAR_TO_UTF8(*Internals.Name);
// UE_LOG(LogTemp, Log, TEXT("Disabling custom actor: %s"), *Internals.Name);
if (ADReyeVRCustomActor::ActiveCustomActors.find(s) != ADReyeVRCustomActor::ActiveCustomActors.end())
{
ADReyeVRCustomActor::ActiveCustomActors.erase(s);
Expand All @@ -136,7 +134,6 @@ void ADReyeVRCustomActor::Deactivate()

void ADReyeVRCustomActor::Activate()
{
// UE_LOG(LogTemp, Log, TEXT("Enabling custom actor: %s"), *Internals.Name);
const std::string s = TCHAR_TO_UTF8(*Internals.Name);
if (ADReyeVRCustomActor::ActiveCustomActors.find(s) == ADReyeVRCustomActor::ActiveCustomActors.end())
ADReyeVRCustomActor::ActiveCustomActors[s] = this;
Expand Down
85 changes: 85 additions & 0 deletions Carla/Carla.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.

// This file is included before any other file in every compile unit within the
// plugin.
#pragma once


#include "Util/NonCopyable.h"
#include "Logging/LogMacros.h"
#include "Modules/ModuleInterface.h"

DECLARE_LOG_CATEGORY_EXTERN(LogCarla, Log, All);
DECLARE_LOG_CATEGORY_EXTERN(LogCarlaServer, Log, All);

// DisplayName, GroupName, Third param is always Advanced.
// DECLARE_STATS_GROUP(TEXT("Carla"), STATGROUP_Carla, STATCAT_Advanced);
DECLARE_STATS_GROUP(TEXT("CarlaSensor"), STATGROUP_CarlaSensor, STATCAT_Advanced);

//DECLARE_MEMORY_STAT(TEXT("CARLAMEMORY"), STATGROUP_CARLAMEMORY, STATCAT_Advanced)

DECLARE_CYCLE_STAT(TEXT("Read RT"), STAT_CarlaSensorReadRT, STATGROUP_CarlaSensor);
DECLARE_CYCLE_STAT(TEXT("Copy Text"), STAT_CarlaSensorCopyText, STATGROUP_CarlaSensor);
DECLARE_CYCLE_STAT(TEXT("Buffer Copy"), STAT_CarlaSensorBufferCopy, STATGROUP_CarlaSensor);
DECLARE_CYCLE_STAT(TEXT("Stream Send"), STAT_CarlaSensorStreamSend, STATGROUP_CarlaSensor);

// Options to compile with extra debug log.
#if WITH_EDITOR
// #define CARLA_AI_VEHICLES_EXTRA_LOG
// #define CARLA_AI_WALKERS_EXTRA_LOG
// #define CARLA_ROAD_GENERATOR_EXTRA_LOG
// #define CARLA_SERVER_EXTRA_LOG
// #define CARLA_TAGGER_EXTRA_LOG
// #define CARLA_WEATHER_EXTRA_LOG
#endif // WITH_EDITOR

class FCarlaModule : public IModuleInterface
{
void RegisterSettings();
void UnregisterSettings();
bool HandleSettingsSaved();
void LoadChronoDll();

public:

/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;

};

///////////////////////////////////////////////////////////////////////////////
//////////////////////DReyeVR logging from CarlaUE4.h//////////////////////////
///////////////////////////////////////////////////////////////////////////////

// fancy logging that includes [filename::function:line] prefix
#ifndef __DReyeVR_LOG

/// TODO: remove duplicate code! (Also defined in CarlaUE4.h)
constexpr inline const char *file_name_only(const char *path)
{
// note since this is a constexpr function, it gets evaluated at compile time rather
// than runtime so there is no runtime performance overhead!
#ifdef _WIN32
constexpr char os_sep = '\\';
#else
constexpr char os_sep = '/';
#endif
const char *filename_start = path;
while (*path)
{
if (*path++ == os_sep) // keep searching until found last os sep
filename_start = path;
}
return filename_start; // includes extension
}


#define __DReyeVR_LOG(msg, verbosity, ...) \
UE_LOG(LogCarla, verbosity, TEXT("[%s::%s:%d] %s"), UTF8_TO_TCHAR(file_name_only(__FILE__)), \
UTF8_TO_TCHAR(__func__), __LINE__, *FString::Printf(TEXT(msg), ##__VA_ARGS__));
#endif

#define DReyeVR_LOG(msg, ...) __DReyeVR_LOG(msg, Log, ##__VA_ARGS__);
#define DReyeVR_LOG_WARN(msg, ...) __DReyeVR_LOG(msg, Warning, ##__VA_ARGS__);
#define DReyeVR_LOG_ERROR(msg, ...) __DReyeVR_LOG(msg, Error, ##__VA_ARGS__);
Loading

0 comments on commit 9e2e2bc

Please sign in to comment.