Closed quanheng123 closed 5 years ago
Here is what I doing, I just personal modified the routplanner file to give them a fixed location and route and write a python scripts to generate massive of cpp and h just changing location data in every cpp and h file, just like this
`#include "Carla.h"
static AWheeledVehicleAIController GetVehicleController10 (AActor Actor)
{
auto *Vehicle = (Actor->IsPendingKill() ? nullptr : Cast
static const USplineComponent PickARoute10 (
URandomEngine &RandomEngine,
const TArray<USplineComponent > &Routes,
const TArray
auto Index = RandomEngine.GetIntWithWeight(Probabilities); check((Index >= 0) && (Index < Routes.Num())); return Routes[Index]; }
// Sets default values
AMyRoutPlanner0 :: AMyRoutPlanner0 (const FObjectInitializer& ObjectInitializer) :
Super(ObjectInitializer)
{ RootComponent = ObjectInitializer.CreateDefaultSubobject
RouteDirection0 = CreateDefaultSubobject
}
void AMyRoutPlanner0 ::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) {
Super::PostEditChangeProperty(PropertyChangedEvent);
const auto Size = Routes.Num();
if (PropertyChangedEvent.Property && (Size != Probabilities.Num()))
{
Probabilities.Reset(Size);
for (auto i = 0; i < Size; ++i)
{
Probabilities.Add(1.0f / static_cast
// Called when the game starts or when spawned void AMyRoutPlanner0 ::BeginPlay() { Super::BeginPlay(); if (!TriggerVolume0->OnComponentBeginOverlap.IsAlreadyBound(this, &AMyRoutPlanner0::OnTriggerBeginOverlap)) { TriggerVolume0->OnComponentBeginOverlap.AddDynamic(this, &AMyRoutPlanner0::OnTriggerBeginOverlap); }
}
void AMyRoutPlanner0::EndPlay(const EEndPlayReason::Type EndPlayReason) { //Endplay Insert Tag, don't delete! if (TriggerVolume0->OnComponentBeginOverlap.IsAlreadyBound(this, &AMyRoutPlanner0::OnTriggerBeginOverlap)) { TriggerVolume0->OnComponentBeginOverlap.RemoveDynamic(this, &AMyRoutPlanner0::OnTriggerBeginOverlap); }
Super::EndPlay(EndPlayReason);
}
void AMyRoutPlanner0 ::OnTriggerBeginOverlap( UPrimitiveComponent /OverlappedComp/, AActor OtherActor, UPrimitiveComponent /OtherComp/, int32 /OtherBodyIndex/, bool /bFromSweep/, const FHitResult & /SweepResult*/) {
auto Controller = GetVehicleController10 (OtherActor); auto RandomEngine = (Controller != nullptr ? Controller->GetRandomEngine() : nullptr); if (RandomEngine != nullptr) { auto Route = PickARoute10 (RandomEngine, Routes, Probabilities);
TArray<FVector> WayPoints;
const auto Size = Route->GetNumberOfSplinePoints();
check(Size > 1);
WayPoints.Reserve(Size);
for (auto i = 1; i < Size; ++i)
{
WayPoints.Add(Route->GetLocationAtSplinePoint(i, ESplineCoordinateSpace::World));
}
Controller->SetFixedRoute(WayPoints);
} } `
and the H files:
`#pragma once
UCLASS() class CARLA_API AMyRoutPlanner0 : public AActor { GENERATED_BODY()
public: // Sets default values for this actor's properties AMyRoutPlanner0(const FObjectInitializer& ObjectInitializer);
protected:
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
// Called when the game starts or when spawned
virtual void BeginPlay() override;
virtual void EndPlay(EEndPlayReason::Type EndPlayReason) override;
UFUNCTION() void OnTriggerBeginOverlap( UPrimitiveComponent OverlappedComp, AActor OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult);
public:
UPROPERTY(EditAnywhere) USplineComponent* RouteDirection0;
UPROPERTY(EditAnywhere) UBoxComponent *TriggerVolume0;
UPROPERTY(BlueprintReadWrite, Category="Traffic Routes", EditAnywhere) TArray<USplineComponent *> Routes;
UPROPERTY(BlueprintReadWrite, Category="Traffic Routes", EditAnywhere, EditFixedSize)
TArray
}; `
because the size of the map ,I generated 800 cpp and h files, when I want to rebuild, I always get error about
`In file included from /home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Development/Carla/Module.Carla.gen.2_of_2.cpp:21:
In file included from /home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficLightBase.gen.cpp:9:
In file included from ../../../carla/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/TrafficLightBase.h:9:
../../../carla/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/TrafficSignBase.h:55:3: error:
unknown type name 'UTrafficSignAgentComponent'
UTrafficSignAgentComponent TrafficSignAgentComponent;
^
../../../carla/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/TrafficSignBase.h:31:3: error:
cannot initialize return object of type 'UObject ' with an rvalue of type
'ATrafficSignBase *'
GENERATED_BODY()
^~~~
Runtime/CoreUObject/Public/UObject/ObjectMacros.h:585:29: note: expanded from
macro 'GENERATED_BODY'
...BODY_MACRO_COMBINE(CURRENT_FILEID,,LINE,_GENERATED_BODY);
^~~~~~~~~~~~~~
Runtime/CoreUObject/Public/UObject/ObjectMacros.h:580:37: note: expanded from
macro 'BODY_MACRO_COMBINE'
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Runtime/CoreUObject/Public/UObject/ObjectMacros.h:579:43: note: expanded from macro 'BODY_MACRO_COMBINE_INNER'
^~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see
all)
../../../carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficSignBase.generated.h:124:2: note:
expanded from macro
'CarlaUE4_Plugins_Carla_Source_Carla_Traffic_TrafficSignBase_h_31_GENERATED_BODY'
...CarlaUE4_Plugins_Carla_Source_Carla_Traffic_TrafficSignBase_h_31_ENHANCED_CONSTRUCTORS \
^~~~~~~~~~~~~~~~~~
../../../carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficSignBase.generated.h:96:60: note:
expanded from macro
'CarlaUE4_Plugins_Carla_Source_Carla_Traffic_TrafficSignBase_h_31_ENHANCED_CONSTRUCTORS'
DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, ATrafficSignBase); \
^
Runtime/CoreUObject/Public/UObject/ObjectMacros.h:1387:11: note: expanded from
macro '\
DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER'
...new (EC_InternalUseOnlyConstructor, (UObject)GetTransientPackage(), NAME_None, RF_NeedLoad | RF_ClassDefaultObject | RF_TagGarbageTemp) TClass(Helper); \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Development/Carla/Module.Carla.gen.2_of_2.cpp:21:
In file included from /home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficLightBase.gen.cpp:9:
../../../carla/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Traffic/TrafficLightBase.h:21:3: error:
cannot initialize return object of type 'UObject ' with an rvalue of type
'ATrafficLightBase *'
GENERATED_BODY()
^~~~
Runtime/CoreUObject/Public/UObject/ObjectMacros.h:585:29: note: expanded from
macro 'GENERATED_BODY'
...BODY_MACRO_COMBINE(CURRENT_FILEID,,LINE,_GENERATED_BODY);
^~~~~~~~~~~~~~
Runtime/CoreUObject/Public/UObject/ObjectMacros.h:580:37: note: expanded from
macro 'BODY_MACRO_COMBINE'
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Runtime/CoreUObject/Public/UObject/ObjectMacros.h:579:43: note: expanded from macro 'BODY_MACRO_COMBINE_INNER'
^~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see
all)
../../../carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficLightBase.generated.h:172:2: note:
expanded from macro
'CarlaUE4_Plugins_Carla_Source_Carla_Traffic_TrafficLightBase_h_21_GENERATED_BODY'
...CarlaUE4_Plugins_Carla_Source_Carla_Traffic_TrafficLightBase_h_21_ENHANCED_CONSTRUCTORS \
^~~~~~~~~~~~~~~~~~~
../../../carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficLightBase.generated.h:139:61: note:
expanded from macro
'CarlaUE4_Plugins_Carla_Source_Carla_Traffic_TrafficLightBase_h_21_ENHANCED_CONSTRUCTORS'
DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, ATrafficLightBase); \
^
Runtime/CoreUObject/Public/UObject/ObjectMacros.h:1387:11: note: expanded from
macro '\
DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER'
...new (EC_InternalUseOnlyConstructor, (UObject*)GetTransientPackage(), NAME_None, RF_NeedLoad | RF_ClassDefaultObject | RF_TagGarbageTemp) TClass(Helper); \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Development/Carla/Module.Carla.gen.2_of_2.cpp:21:
/home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficLightBase.gen.cpp:35:16: error:
cannot initialize object parameter of type 'const UObject' with an
expression of type 'ATrafficLightBase'
ProcessEvent(FindFunctionChecked(NAMEATrafficLightBase...
^~~~~~~
/home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficLightBase.gen.cpp:196:206: error:
non-constant-expression cannot be narrowed from type 'unsigned long' to
'int32' (aka 'int') in initializer list [-Wc++11-narrowing]
...1, nullptr, STRUCT_OFFSET(ATrafficLightBase, Vehicles), METADATA_PARAMS(...
^~~~~~~~~~
/home/heng/UnrealEngine_4.18/Engine/Source/Runtime/Core/Public/Templates/UnrealTemplate.h:143:40: note:
expanded from macro 'STRUCT_OFFSET'
^~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/llvm-5.0/lib/clang/5.0.1/include/stddef.h:120:24: note: expanded from macro 'offsetof'
^~~~~~~~~~~~~~~~~~~~~~~~
/home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficLightBase.gen.cpp:196:206: note:
insert an explicit cast to silence this issue
...1, nullptr, STRUCT_OFFSET(ATrafficLightBase, Vehicles), METADATA_PARAMS(...
^~~~~~~~~~
static_cast
^~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/llvm-5.0/lib/clang/5.0.1/include/stddef.h:120:24: note: expanded from macro 'offsetof'
^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Development/Carla/Module.Carla.gen.2_of_2.cpp:21:
/home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficLightBase.gen.cpp:204:198: error:
non-constant-expression cannot be narrowed from type 'unsigned long' to
'int32' (aka 'int') in initializer list [-Wc++11-narrowing]
...1, nullptr, STRUCT_OFFSET(ATrafficLightBase, State), Z_Construct_UEnum_C...
^~~~~~~~~~~
/home/heng/UnrealEngine_4.18/Engine/Source/Runtime/Core/Public/Templates/UnrealTemplate.h:143:40: note:
expanded from macro 'STRUCT_OFFSET'
^~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/llvm-5.0/lib/clang/5.0.1/include/stddef.h:120:24: note: expanded from macro 'offsetof'
^~~~~~~~~~~~~~~~~~~~~~~~
/home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficLightBase.gen.cpp:204:198: note:
insert an explicit cast to silence this issue
...1, nullptr, STRUCT_OFFSET(ATrafficLightBase, State), Z_Construct_UEnum_C...
^~~~~~~~~~~
static_cast
^~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/llvm-5.0/lib/clang/5.0.1/include/stddef.h:120:24: note: expanded from macro 'offsetof'
^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Development/Carla/Module.Carla.gen.2_of_2.cpp:24:
/home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficSignBase.gen.cpp:185:242: error:
non-constant-expression cannot be narrowed from type 'unsigned long' to
'int32' (aka 'int') in initializer list [-Wc++11-narrowing]
...1, nullptr, STRUCT_OFFSET(ATrafficSignBase, TrafficSignAgentComponent), ...
^~~~~~~~~~~~~~
/home/heng/UnrealEngine_4.18/Engine/Source/Runtime/Core/Public/Templates/UnrealTemplate.h:143:40: note:
expanded from macro 'STRUCT_OFFSET'
^~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/llvm-5.0/lib/clang/5.0.1/include/stddef.h:120:24: note: expanded from macro 'offsetof'
^~~~~~~~~~~~~~~~~~~~~~~~
/home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficSignBase.gen.cpp:185:242: note:
insert an explicit cast to silence this issue
...1, nullptr, STRUCT_OFFSET(ATrafficSignBase, TrafficSignAgentComponent), ...
^~~~~~~~~~~~~~
static_cast
^~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/llvm-5.0/lib/clang/5.0.1/include/stddef.h:120:24: note: expanded from macro 'offsetof'
^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Development/Carla/Module.Carla.gen.2_of_2.cpp:24:
/home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficSignBase.gen.cpp:192:220: error:
non-constant-expression cannot be narrowed from type 'unsigned long' to
'int32' (aka 'int') in initializer list [-Wc++11-narrowing]
...1, nullptr, STRUCT_OFFSET(ATrafficSignBase, TrafficSignState), Z_Constru...
^~~~~~~~~~~~~
/home/heng/UnrealEngine_4.18/Engine/Source/Runtime/Core/Public/Templates/UnrealTemplate.h:143:40: note:
expanded from macro 'STRUCT_OFFSET'
^~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/llvm-5.0/lib/clang/5.0.1/include/stddef.h:120:24: note: expanded from macro 'offsetof'
^~~~~~~~~~~~~~~~~~~~~~~~
/home/heng/carla/Unreal/CarlaUE4/Plugins/Carla/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Carla/TrafficSignBase.gen.cpp:192:220: note:
insert an explicit cast to silence this issue
...1, nullptr, STRUCT_OFFSET(ATrafficSignBase, TrafficSignState), Z_Constru...
^~~~~~~~~~~~~
static_cast
^~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/llvm-5.0/lib/clang/5.0.1/include/stddef.h:120:24: note: expanded from macro 'offsetof'
^~~~~~~~~~~~~~~~~~~~~~~~
8 errors generated. `
Why there is a error with relation of traffic light and traffic sign ? I dont get it.... then I just try to rebuild just with fisrt 12 files, I always succssed. How can I fix this ? Any help will be appriciated!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I know this over a year and a half old, but commenting anyways for posterity in case anyone else runs into this issue. I am also working on some custom code. It is, as the first compiler error indicates, a unknown type issue. All the macro expansion errors are red herrings (which led me to waste two good weeks). You need to add an explicit #include
for UTrafficSignComponent.h
.
I found the solution here: https://answers.unrealengine.com/questions/730971/unknown-type-name-utextrendercomponent-while-follo.html.
My hunch as to why this happens is the Unreal build tools, which fills in the UFUNCTION
, UPROPERTY
, etc, macros before the code is compiled by the C++ compiler. I found that if I commented some very specific UFUNCTION
macros out (before I included the explicit #include
), the code would compile successfully. Perhaps, depending on where Unreal macros are, the include order of headers get shuffled up in the autogenerated files. But that's just a hunch. I guess, to be on the safe side, it's good practice to have explicit #includes
for all the classes used in each file, given the Include What You Use model.
Hi, I have a question about routeplanner, here i want to create massive of routeplanners in editor, with massive of coordination points data which for the locations of triggervolume , splinepoints and so on , is there any loluntion that i can automatically genrate these routeplanners ?
thanks.