Skip to content

Commit c9e3f20

Browse files
authored
Merge pull request #111 from HARPLab/dev
Backend overhaul (+Custom EgoVehicles + better autopilot + Auto sign placements)
2 parents 76da276 + 0f0ab1d commit c9e3f20

File tree

107 files changed

+2344
-1145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+2344
-1145
lines changed

CHANGELOG.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
## DReyeVR 0.2.1
2+
- Adding smart (weak) pointers for the major DReyeVR class connections to ensure better pointer validity before dereference. Helps with detecting dangling (freed, but not-null) pointers which happens commonly during map changes and would otherwise crash the replay system.
3+
- Adding PythonAPI startup function (namely a custom `__init__.py` script that is loaded when using `DReyeVR_utils.py`)
4+
- Fix bug with shaders not being cooked in package mode
5+
- Fine-tune ego-vehicle mirrors according to vehicle chassis
6+
- Adding threshold for manual takeover of logitech inputs. Logitech wheel actuation follows autopilot otherwise.
7+
- Disabling shadows for wheel face buttons
8+
- Adding autopilot light indicator
9+
10+
## DReyeVR 0.2.0
11+
- Add face button indicators on the steering wheel
12+
- Revamping `ConfigFile` class rather than a static `ReadConfigFile` helper function
13+
- Adding Config-file check as part of the tracked DReyeVRData, gives you a warning if your loaded ConfigFile is different from the one that was used during recording (so you can match your replay config with that which was recorded)
14+
- Adding per-vehicle configuration files in `Content/DReyeVR/EgoVehicle` that can be selected via parameters. Allows parameterization of all EgoVehicle components, magic numbers (ex. location of camera, mirrors, engine), sound files, mirror meshes, steering wheel types, and enable/disable these on a highly granular basis
15+
- Revamp EgoVehicle input controls to use parent (ACarlaWheeledVehicle) controls and flush
16+
- Disabling (turning invisible) default Carla spectator in map
17+
- Added tutorial for custom EgoVehicle
18+
119
## DReyeVR 0.1.3
220
- Fix bug where other non-ego Autopilto vehicles ignored the EgoVehicle and would routinely crash into it
321
- Fix bug where some EgoVehicle attributes were missing, notably `"number_of_wheels"`
@@ -30,4 +48,4 @@
3048
- Improved vehicle dash with blinking turn signal and fixed bugs with inconsistent gear indicator.
3149
- Fixed bugs and inconsistencies with replayer media control and special actions such as toggling reverse/turn signals in replay.
3250
- Enabled cooking for `Town06` and `Town07` in package/shipping mode.
33-
- Updated documentation and config file
51+
- Updated documentation and config file

Carla/Actor/DReyeVRCustomActor.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ ADReyeVRCustomActor::ADReyeVRCustomActor(const FObjectInitializer &ObjectInitial
4949
Internals.Scale3D = this->GetActorScale3D();
5050
}
5151

52-
ADReyeVRCustomActor::~ADReyeVRCustomActor()
53-
{
54-
this->Deactivate();
55-
this->Destroy(); // UE4 Destroy method
56-
}
57-
5852
bool ADReyeVRCustomActor::AssignSM(const FString &Path, UWorld *World)
5953
{
6054
UStaticMesh *SM = LoadObject<UStaticMesh>(nullptr, *Path);
@@ -164,9 +158,14 @@ void ADReyeVRCustomActor::Tick(float DeltaSeconds)
164158
Internals.Scale3D = this->GetActorScale3D();
165159
Internals.MaterialParams = MaterialParams;
166160
}
161+
UpdateMaterial();
162+
/// TODO: use other string?
163+
}
164+
165+
void ADReyeVRCustomActor::UpdateMaterial()
166+
{
167167
// update the materials according to the params
168168
MaterialParams.Apply(DynamicMat);
169-
/// TODO: use other string?
170169
}
171170

172171
void ADReyeVRCustomActor::SetInternals(const DReyeVR::CustomActorData &InData)

Carla/Actor/DReyeVRCustomActor.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CARLA_API ADReyeVRCustomActor : public AActor // abstract class
2424

2525
public:
2626
ADReyeVRCustomActor(const FObjectInitializer &ObjectInitializer);
27-
~ADReyeVRCustomActor();
27+
~ADReyeVRCustomActor() = default;
2828

2929
/// factory function to create a new instance of a given type
3030
static ADReyeVRCustomActor *CreateNew(const FString &SM_Path, const FString &Mat_Path, UWorld *World,
@@ -39,6 +39,16 @@ class CARLA_API ADReyeVRCustomActor : public AActor // abstract class
3939
return bIsActive;
4040
}
4141

42+
void SetActorRecordEnabled(const bool bEnabled)
43+
{
44+
bShouldRecord = bEnabled;
45+
}
46+
47+
const bool GetShouldRecord() const
48+
{
49+
return bShouldRecord;
50+
}
51+
4252
void Initialize(const FString &Name);
4353

4454
void SetInternals(const DReyeVR::CustomActorData &In);
@@ -47,14 +57,21 @@ class CARLA_API ADReyeVRCustomActor : public AActor // abstract class
4757

4858
static std::unordered_map<std::string, class ADReyeVRCustomActor *> ActiveCustomActors;
4959

60+
inline class UStaticMeshComponent *GetMesh()
61+
{
62+
return ActorMesh;
63+
}
64+
5065
// function to dynamically change the material params of the object at runtime
5166
void AssignMat(const FString &Path);
67+
void UpdateMaterial();
5268
struct DReyeVR::CustomActorData::MaterialParamsStruct MaterialParams;
5369

5470
private:
5571
void BeginPlay() override;
5672
void BeginDestroy() override;
57-
bool bIsActive = false; // initially deactivated
73+
bool bIsActive = false; // initially deactivated
74+
bool bShouldRecord = true; // should record in the Carla Recorder/Replayer
5875

5976
bool AssignSM(const FString &Path, UWorld *World);
6077

Carla/Recorder/CarlaRecorder.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,15 @@ void ACarlaRecorder::Ticking(float DeltaSeconds)
9191
PlatformTime.UpdateTime();
9292
const FActorRegistry &Registry = Episode->GetActorRegistry();
9393

94+
// Skip the spectator actor
95+
FCarlaActor* CarlaSpectator = Episode->FindCarlaActor(Episode->GetSpectatorPawn());
96+
9497
// through all actors in registry
9598
for (auto It = Registry.begin(); It != Registry.end(); ++It)
9699
{
97100
FCarlaActor* View = It.Value().Get();
98101

99-
if (View->GetActorId() == 0)
102+
if (CarlaSpectator && (View->GetActor() == CarlaSpectator->GetActor()))
100103
continue; // don't record the spectator
101104

102105
switch (View->GetActorType())
@@ -277,18 +280,20 @@ void ACarlaRecorder::AddActorBoundingBox(FCarlaActor *CarlaActor)
277280

278281
void ACarlaRecorder::AddDReyeVRData()
279282
{
283+
static bool bAddedConfigFile;
284+
if (!bAddedConfigFile) {
285+
// add DReyeVR config files (only once at the beginning of recording)
286+
DReyeVRConfigFileData.Add(ADReyeVRSensor::ConfigFile);
287+
bAddedConfigFile = true;
288+
}
289+
280290
// Add the latest instance of the DReyeVR snapshot to our data
281291
DReyeVRAggData.Add(DReyeVRDataRecorder<DReyeVR::AggregateData>(ADReyeVRSensor::Data));
282292

283-
TArray<AActor *> FoundActors;
284-
if (Episode != nullptr && Episode->GetWorld() != nullptr)
293+
for (auto &ActiveCAs : ADReyeVRCustomActor::ActiveCustomActors)
285294
{
286-
UGameplayStatics::GetAllActorsOfClass(Episode->GetWorld(), ADReyeVRCustomActor::StaticClass(), FoundActors);
287-
}
288-
for (AActor *A : FoundActors)
289-
{
290-
ADReyeVRCustomActor *CustomActor = Cast<ADReyeVRCustomActor>(A);
291-
if (CustomActor != nullptr && CustomActor->IsActive())
295+
ADReyeVRCustomActor *CustomActor = ActiveCAs.second;
296+
if (CustomActor != nullptr && CustomActor->IsActive() && CustomActor->GetShouldRecord())
292297
{
293298
DReyeVRCustomActorData.Add(DReyeVRDataRecorder<DReyeVR::CustomActorData>(&(CustomActor->GetInternals())));
294299
}
@@ -427,6 +432,7 @@ void ACarlaRecorder::Clear(void)
427432
TrafficLightTimes.Clear();
428433
DReyeVRAggData.Clear();
429434
DReyeVRCustomActorData.Clear();
435+
DReyeVRConfigFileData.Clear();
430436
Weathers.Clear();
431437
}
432438

@@ -470,6 +476,14 @@ void ACarlaRecorder::Write(double DeltaSeconds)
470476
// custom DReyeVR Actor data write
471477
DReyeVRCustomActorData.Write(File);
472478

479+
// only write this once (at the beginning)
480+
static bool bWroteConfigFile = false;
481+
if (!bWroteConfigFile) {
482+
// DReyeVR configuration/parameters
483+
DReyeVRConfigFileData.Write(File);
484+
bWroteConfigFile = true;
485+
}
486+
473487
// weather state
474488
Weathers.Write(File);
475489

Carla/Recorder/CarlaRecorder.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class ATrafficLightBase;
4747

4848
#define DREYEVR_PACKET_ID 139
4949
#define DREYEVR_CUSTOM_ACTOR_PACKET_ID 140
50+
#define DREYEVR_CONFIG_FILE_PACKET_ID 141
5051

5152
enum class CarlaRecorderPacketId : uint8_t
5253
{
@@ -70,8 +71,9 @@ enum class CarlaRecorderPacketId : uint8_t
7071
TriggerVolume,
7172
Weather,
7273
// "We suggest to use id over 100 for user custom packets, because this list will keep growing in the future"
73-
DReyeVR = DREYEVR_PACKET_ID, // our custom DReyeVR packet (for raw sensor data)
74-
DReyeVRCustomActor = DREYEVR_CUSTOM_ACTOR_PACKET_ID // custom DReyeVR actors (not raw sensor data)
74+
DReyeVR = DREYEVR_PACKET_ID, // our custom DReyeVR packet (for raw sensor data)
75+
DReyeVRCustomActor = DREYEVR_CUSTOM_ACTOR_PACKET_ID, // custom DReyeVR actors (not raw sensor data)
76+
DReyeVRConfigFile = DREYEVR_CONFIG_FILE_PACKET_ID // DReyeVR configuration files (parameters)
7577
};
7678

7779
/// Recorder for the simulation
@@ -205,6 +207,7 @@ class CARLA_API ACarlaRecorder : public AActor
205207
CarlaRecorderWeathers Weathers;
206208
DReyeVRDataRecorders<DReyeVR::AggregateData, DREYEVR_PACKET_ID> DReyeVRAggData;
207209
DReyeVRDataRecorders<DReyeVR::CustomActorData, DREYEVR_CUSTOM_ACTOR_PACKET_ID> DReyeVRCustomActorData;
210+
DReyeVRDataRecorders<DReyeVR::ConfigFileData, DREYEVR_CONFIG_FILE_PACKET_ID> DReyeVRConfigFileData;
208211

209212
// replayer
210213
CarlaReplayer Replayer;

Carla/Recorder/CarlaRecorderQuery.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,27 @@ std::string CarlaRecorderQuery::QueryInfo(std::string Filename, bool bShowAll)
604604
else
605605
SkipPacket();
606606
break;
607+
608+
// DReyeVR data (ConfigFileData)
609+
case static_cast<char>(CarlaRecorderPacketId::DReyeVRConfigFile):
610+
if (bShowAll)
611+
{
612+
ReadValue<uint16_t>(File, Total);
613+
if (Total > 0 && !bFramePrinted)
614+
{
615+
PrintFrame(Info);
616+
bFramePrinted = true;
617+
}
618+
Info << " DReyeVR config files: " << Total << std::endl;
619+
for (i = 0; i < Total; ++i)
620+
{
621+
DReyeVRConfigFileDataInstance.Read(File);
622+
Info << DReyeVRConfigFileDataInstance.Print() << std::endl;
623+
}
624+
}
625+
else
626+
SkipPacket();
627+
break;
607628
// frame end
608629
case static_cast<char>(CarlaRecorderPacketId::FrameEnd):
609630
// do nothing, it is empty

Carla/Recorder/CarlaRecorderQuery.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class CarlaRecorderQuery
7272
// custom DReyeVR packets
7373
DReyeVRDataRecorder<DReyeVR::AggregateData> DReyeVRAggDataInstance;
7474
DReyeVRDataRecorder<DReyeVR::CustomActorData> DReyeVRCustomActorDataInstance;
75+
DReyeVRDataRecorder<DReyeVR::ConfigFileData> DReyeVRConfigFileDataInstance;
7576

7677
// read next header packet
7778
bool ReadHeader(void);

0 commit comments

Comments
 (0)