Creation of TrafficLight and Sign Components on UE
This commit is contained in:
parent
c4cb43d023
commit
853317b594
|
@ -11,64 +11,64 @@
|
|||
namespace carla {
|
||||
namespace client {
|
||||
|
||||
void TrafficLight::SetState(rpc::TrafficLightState state) {
|
||||
GetEpisode().Lock()->SetTrafficLightState(*this, state);
|
||||
}
|
||||
void TrafficLight::SetState(rpc::TrafficLightState state) {
|
||||
GetEpisode().Lock()->SetTrafficLightState(*this, state);
|
||||
}
|
||||
|
||||
rpc::TrafficLightState TrafficLight::GetState() const {
|
||||
return GetEpisode().Lock()->GetActorSnapshot(*this).state.traffic_light_data.state;
|
||||
}
|
||||
rpc::TrafficLightState TrafficLight::GetState() const {
|
||||
return GetEpisode().Lock()->GetActorSnapshot(*this).state.traffic_light_data.state;
|
||||
}
|
||||
|
||||
void TrafficLight::SetGreenTime(float green_time) {
|
||||
GetEpisode().Lock()->SetTrafficLightGreenTime(*this, green_time);
|
||||
}
|
||||
void TrafficLight::SetGreenTime(float green_time) {
|
||||
GetEpisode().Lock()->SetTrafficLightGreenTime(*this, green_time);
|
||||
}
|
||||
|
||||
float TrafficLight::GetGreenTime() const {
|
||||
return GetEpisode().Lock()->GetActorSnapshot(*this).state.traffic_light_data.green_time;
|
||||
}
|
||||
float TrafficLight::GetGreenTime() const {
|
||||
return GetEpisode().Lock()->GetActorSnapshot(*this).state.traffic_light_data.green_time;
|
||||
}
|
||||
|
||||
void TrafficLight::SetYellowTime(float yellow_time) {
|
||||
GetEpisode().Lock()->SetTrafficLightYellowTime(*this, yellow_time);
|
||||
}
|
||||
void TrafficLight::SetYellowTime(float yellow_time) {
|
||||
GetEpisode().Lock()->SetTrafficLightYellowTime(*this, yellow_time);
|
||||
}
|
||||
|
||||
float TrafficLight::GetYellowTime() const {
|
||||
return GetEpisode().Lock()->GetActorSnapshot(*this).state.traffic_light_data.yellow_time;
|
||||
}
|
||||
float TrafficLight::GetYellowTime() const {
|
||||
return GetEpisode().Lock()->GetActorSnapshot(*this).state.traffic_light_data.yellow_time;
|
||||
}
|
||||
|
||||
void TrafficLight::SetRedTime(float red_time) {
|
||||
GetEpisode().Lock()->SetTrafficLightRedTime(*this, red_time);
|
||||
}
|
||||
void TrafficLight::SetRedTime(float red_time) {
|
||||
GetEpisode().Lock()->SetTrafficLightRedTime(*this, red_time);
|
||||
}
|
||||
|
||||
float TrafficLight::GetRedTime() const {
|
||||
return GetEpisode().Lock()->GetActorSnapshot(*this).state.traffic_light_data.red_time;
|
||||
}
|
||||
float TrafficLight::GetRedTime() const {
|
||||
return GetEpisode().Lock()->GetActorSnapshot(*this).state.traffic_light_data.red_time;
|
||||
}
|
||||
|
||||
float TrafficLight::GetElapsedTime() const {
|
||||
return GetEpisode().Lock()->GetActorSnapshot(*this).state.traffic_light_data.elapsed_time;
|
||||
}
|
||||
float TrafficLight::GetElapsedTime() const {
|
||||
return GetEpisode().Lock()->GetActorSnapshot(*this).state.traffic_light_data.elapsed_time;
|
||||
}
|
||||
|
||||
void TrafficLight::Freeze(bool freeze) {
|
||||
GetEpisode().Lock()->FreezeTrafficLight(*this, freeze);
|
||||
}
|
||||
void TrafficLight::Freeze(bool freeze) {
|
||||
GetEpisode().Lock()->FreezeTrafficLight(*this, freeze);
|
||||
}
|
||||
|
||||
bool TrafficLight::IsFrozen() const {
|
||||
return GetEpisode().Lock()->GetActorSnapshot(*this).state.traffic_light_data.time_is_frozen;
|
||||
}
|
||||
bool TrafficLight::IsFrozen() const {
|
||||
return GetEpisode().Lock()->GetActorSnapshot(*this).state.traffic_light_data.time_is_frozen;
|
||||
}
|
||||
|
||||
uint32_t TrafficLight::GetPoleIndex()
|
||||
{
|
||||
return GetEpisode().Lock()->GetActorSnapshot(*this).state.traffic_light_data.pole_index;
|
||||
}
|
||||
uint32_t TrafficLight::GetPoleIndex()
|
||||
{
|
||||
return GetEpisode().Lock()->GetActorSnapshot(*this).state.traffic_light_data.pole_index;
|
||||
}
|
||||
|
||||
std::vector<SharedPtr<TrafficLight>> TrafficLight::GetGroupTrafficLights() {
|
||||
std::vector<SharedPtr<TrafficLight>> result;
|
||||
auto ids = GetEpisode().Lock()->GetGroupTrafficLights(*this);
|
||||
for (auto id : ids) {
|
||||
SharedPtr<Actor> actor = GetWorld().GetActors()->Find(id);
|
||||
result.push_back(boost::static_pointer_cast<TrafficLight>(actor));
|
||||
}
|
||||
return result;
|
||||
std::vector<SharedPtr<TrafficLight>> TrafficLight::GetGroupTrafficLights() {
|
||||
std::vector<SharedPtr<TrafficLight>> result;
|
||||
auto ids = GetEpisode().Lock()->GetGroupTrafficLights(*this);
|
||||
for (auto id : ids) {
|
||||
SharedPtr<Actor> actor = GetWorld().GetActors()->Find(id);
|
||||
result.push_back(boost::static_pointer_cast<TrafficLight>(actor));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
} // namespace carla
|
||||
|
|
|
@ -12,54 +12,57 @@
|
|||
namespace carla {
|
||||
namespace client {
|
||||
|
||||
class TrafficLight : public TrafficSign {
|
||||
public:
|
||||
class TrafficLight : public Actor {
|
||||
|
||||
explicit TrafficLight(ActorInitializer init) : TrafficSign(std::move(init)) {}
|
||||
public:
|
||||
|
||||
void SetState(rpc::TrafficLightState state);
|
||||
explicit TrafficLight(ActorInitializer init) : Actor(std::move(init)) {}
|
||||
|
||||
/// Return the current state of the traffic light.
|
||||
///
|
||||
/// @note This function does not call the simulator, it returns the data
|
||||
/// received in the last tick.
|
||||
rpc::TrafficLightState GetState() const;
|
||||
void SetState(rpc::TrafficLightState state);
|
||||
|
||||
void SetGreenTime(float green_time);
|
||||
/// Return the current state of the traffic light.
|
||||
///
|
||||
/// @note This function does not call the simulator, it returns the data
|
||||
/// received in the last tick.
|
||||
rpc::TrafficLightState GetState() const;
|
||||
|
||||
/// @note This function does not call the simulator, it returns the data
|
||||
/// received in the last tick.
|
||||
float GetGreenTime() const;
|
||||
void SetGreenTime(float green_time);
|
||||
|
||||
void SetYellowTime(float yellow_time);
|
||||
/// @note This function does not call the simulator, it returns the data
|
||||
/// received in the last tick.
|
||||
float GetGreenTime() const;
|
||||
|
||||
/// @note This function does not call the simulator, it returns the data
|
||||
/// received in the last tick.
|
||||
float GetYellowTime() const;
|
||||
void SetYellowTime(float yellow_time);
|
||||
|
||||
void SetRedTime(float red_time);
|
||||
/// @note This function does not call the simulator, it returns the data
|
||||
/// received in the last tick.
|
||||
float GetYellowTime() const;
|
||||
|
||||
/// @note This function does not call the simulator, it returns the data
|
||||
/// received in the last tick.
|
||||
float GetRedTime() const;
|
||||
void SetRedTime(float red_time);
|
||||
|
||||
/// @note This function does not call the simulator, it returns the data
|
||||
/// received in the last tick.
|
||||
float GetElapsedTime() const;
|
||||
/// @note This function does not call the simulator, it returns the data
|
||||
/// received in the last tick.
|
||||
float GetRedTime() const;
|
||||
|
||||
void Freeze(bool freeze);
|
||||
/// @note This function does not call the simulator, it returns the data
|
||||
/// received in the last tick.
|
||||
float GetElapsedTime() const;
|
||||
|
||||
/// @note This function does not call the simulator, it returns the data
|
||||
/// received in the last tick.
|
||||
bool IsFrozen() const;
|
||||
void Freeze(bool freeze);
|
||||
|
||||
uint32_t GetPoleIndex();
|
||||
/// @note This function does not call the simulator, it returns the data
|
||||
/// received in the last tick.
|
||||
bool IsFrozen() const;
|
||||
|
||||
/// Return all traffic lights in the group this one belongs to.
|
||||
///
|
||||
/// @note This function calls the simulator
|
||||
std::vector<SharedPtr<TrafficLight>> GetGroupTrafficLights();
|
||||
};
|
||||
/// Returns the index of the pole in the traffic light group
|
||||
uint32_t GetPoleIndex();
|
||||
|
||||
/// Return all traffic lights in the group this one belongs to.
|
||||
///
|
||||
/// @note This function calls the simulator
|
||||
std::vector<SharedPtr<TrafficLight>> GetGroupTrafficLights();
|
||||
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
} // namespace carla
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB). This work is licensed under the terms of the MIT license. For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
|
||||
#include "SignComponent.h"
|
||||
|
||||
|
||||
// Sets default values for this component's properties
|
||||
USignComponent::USignComponent()
|
||||
{
|
||||
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
|
||||
// off to improve performance if you don't need them.
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
|
||||
// Called when the game starts
|
||||
void USignComponent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
// ...
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Called every frame
|
||||
void USignComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
||||
// ...
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB). This work is licensed under the terms of the MIT license. For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "SignComponent.generated.h"
|
||||
|
||||
|
||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
||||
class CARLA_API USignComponent : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this component's properties
|
||||
USignComponent();
|
||||
|
||||
protected:
|
||||
// Called when the game starts
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||
|
||||
|
||||
|
||||
};
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB). This work is licensed under the terms of the MIT license. For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
|
||||
#include "TrafficLightComponent.h"
|
||||
|
||||
|
||||
// Sets default values for this component's properties
|
||||
UTrafficLightComponent::UTrafficLightComponent()
|
||||
{
|
||||
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
|
||||
// off to improve performance if you don't need them.
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
|
||||
// Called when the game starts
|
||||
void UTrafficLightComponent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
// ...
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Called every frame
|
||||
void UTrafficLightComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
||||
// ...
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB). This work is licensed under the terms of the MIT license. For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "TrafficLightComponent.generated.h"
|
||||
|
||||
|
||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
||||
class CARLA_API UTrafficLightComponent : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this component's properties
|
||||
UTrafficLightComponent();
|
||||
|
||||
protected:
|
||||
// Called when the game starts
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||
|
||||
};
|
Loading…
Reference in New Issue