Merge branch 'master' into manishthani/no_rendering_mode

This commit is contained in:
Manish 2019-02-28 10:38:48 +01:00
commit 847117245a
15 changed files with 115 additions and 9 deletions

View File

@ -22,6 +22,7 @@
* Fixed BP_MultipleFloor, tweaked offset in BaseFloor to adjust meshes between them
* New traffic signs assets: one-way, no-turn, more speed limits, do not enter, arrow floors, Michigan left, and lane end
* Expose traffic sign's trigger volumes on Python API
* Updated the Python API to enable the user to acquire a traffic light's pole index and all traffic lights in it's group
## CARLA 0.9.3

View File

@ -127,6 +127,8 @@
- `get_elapsed_time()`
- `freeze(True)`
- `is_frozen()`
- `get_pole_index()`
- `get_group_traffic_lights()`
## `carla.Sensor(carla.Actor)`

View File

@ -5,8 +5,8 @@
// For a copy, see <https://opensource.org/licenses/MIT>.
#include "carla/client/TrafficLight.h"
#include "carla/client/detail/Simulator.h"
#include "carla/client/ActorList.h"
namespace carla {
namespace client {
@ -55,5 +55,20 @@ namespace client {
return GetEpisode().Lock()->GetActorDynamicState(*this).state.traffic_light_data.time_is_frozen;
}
uint32_t TrafficLight::GetPoleIndex()
{
return GetEpisode().Lock()->GetActorDynamicState(*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;
}
} // namespace client
} // namespace carla

View File

@ -52,6 +52,13 @@ namespace client {
/// @note This function does not call the simulator, it returns the data
/// received in the last tick.
bool IsFrozen() const;
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

View File

@ -247,6 +247,11 @@ namespace detail {
_pimpl->AsyncCall("add_actor_impulse", actor, vector);
}
std::vector<rpc::actor_id_type> Client::GetGroupTrafficLights(const rpc::Actor &trafficLight) {
using return_t = std::vector<rpc::actor_id_type>;
return _pimpl->CallAndWait<return_t>("get_group_traffic_lights", trafficLight);
}
void Client::SubscribeToStream(
const streaming::Token &token,
std::function<void(Buffer)> callback) {

View File

@ -164,6 +164,8 @@ namespace detail {
void DrawDebugShape(const rpc::DebugShape &shape);
std::vector<rpc::actor_id_type> GetGroupTrafficLights(const rpc::Actor &trafficLight);
private:
class Pimpl;

View File

@ -266,6 +266,10 @@ namespace detail {
_client.FreezeTrafficLight(trafficLight.Serialize(), freeze);
}
std::vector<rpc::actor_id_type> GetGroupTrafficLights(TrafficLight &trafficLight) {
return _client.GetGroupTrafficLights(trafficLight.Serialize());
}
/// @}
// =========================================================================
/// @name Debug

View File

@ -99,6 +99,7 @@ namespace detail {
float red_time;
float elapsed_time;
bool time_is_frozen;
uint32_t pole_index;
};
#pragma pack(pop)
} // namespace detail

View File

@ -33,6 +33,16 @@ static auto GetSemanticTags(const carla::client::Actor &self) {
return boost::python::list(iter);
}
static auto GetGroupTrafficLights(carla::client::TrafficLight &self) {
namespace py = boost::python;
auto values = self.GetGroupTrafficLights();
py::list result;
for (auto value : values) {
result.append(value);
}
return result;
}
void export_actor() {
using namespace boost::python;
namespace cc = carla::client;
@ -123,6 +133,8 @@ void export_actor() {
.def("get_elapsed_time", &cc::TrafficLight::GetElapsedTime)
.def("freeze", &cc::TrafficLight::Freeze, (arg("freeze")))
.def("is_frozen", &cc::TrafficLight::IsFrozen)
.def("get_pole_index", &cc::TrafficLight::GetPoleIndex)
.def("get_group_traffic_lights", &GetGroupTrafficLights)
.def(self_ns::str(self_ns::self))
;
}

View File

@ -71,6 +71,7 @@ static auto AWorldObserver_GetActorState(const FActorView &View, const FActorReg
state.traffic_light_data.red_time = TrafficLight->GetRedTime();
state.traffic_light_data.elapsed_time = TrafficLight->GetElapsedTime();
state.traffic_light_data.time_is_frozen = TrafficLight->GetTimeIsFrozen();
state.traffic_light_data.pole_index = TrafficLight->GetPoleIndex();
}
}

View File

@ -589,6 +589,32 @@ void FTheNewCarlaServer::FPimpl::BindActions()
return R<void>::Success();
});
Server.BindSync("get_group_traffic_lights", [this](
const cr::Actor Actor) -> R<std::vector<cr::actor_id_type>>
{
REQUIRE_CARLA_EPISODE();
auto ActorView = Episode->GetActorRegistry().Find(Actor.id);
if (!ActorView.IsValid() || ActorView.GetActor()->IsPendingKill())
{
RESPOND_ERROR("unable to get group traffic lights: actor not found");
}
auto TrafficLight = Cast<ATrafficLightBase>(ActorView.GetActor());
if (TrafficLight == nullptr)
{
RESPOND_ERROR("unable to get group traffic lights: actor is not a traffic light");
}
std::vector<cr::actor_id_type> Result;
for (auto TLight : TrafficLight->GetGroupTrafficLights())
{
auto View = Episode->FindActor(TLight);
if (View.IsValid())
{
Result.push_back(View.GetActorId());
}
}
return Result;
});
Server.BindSync("draw_debug_shape", [this](const cr::DebugShape &shape) -> R<void>
{
REQUIRE_CARLA_EPISODE();

View File

@ -79,6 +79,11 @@ void ATrafficLightBase::Tick(float DeltaSeconds)
if (ElapsedTime > ChangeTime)
{
// Freeze if part of a group and about to turn red
if (GroupTrafficLights.Num() > 0 && State == ETrafficLightState::Yellow)
{
SetTimeIsFrozen(true);
}
SwitchTrafficLightState();
}
}
@ -98,7 +103,6 @@ void ATrafficLightBase::PostEditChangeProperty(FPropertyChangedEvent &Event)
void ATrafficLightBase::SetTrafficLightState(const ETrafficLightState InState)
{
NumChanges++;
ElapsedTime = 0.0f;
State = InState;
SetTrafficSignState(ToTrafficSignState(State));
@ -197,7 +201,6 @@ void ATrafficLightBase::SetTimeIsFrozen(bool InTimeIsFrozen)
TimeIsFrozen = InTimeIsFrozen;
if (!TimeIsFrozen)
{
NumChanges = 0;
ElapsedTime = 0.0f;
}
}
@ -207,7 +210,22 @@ bool ATrafficLightBase::GetTimeIsFrozen() const
return TimeIsFrozen;
}
int ATrafficLightBase::GetNumChanges() const
void ATrafficLightBase::SetPoleIndex(int InPoleIndex)
{
return NumChanges;
PoleIndex = InPoleIndex;
}
int ATrafficLightBase::GetPoleIndex() const
{
return PoleIndex;
}
TArray<ATrafficLightBase *> ATrafficLightBase::GetGroupTrafficLights() const
{
return GroupTrafficLights;
}
void ATrafficLightBase::SetGroupTrafficLights(TArray<ATrafficLightBase *> InGroupTrafficLights)
{
GroupTrafficLights = InGroupTrafficLights;
}

View File

@ -82,7 +82,16 @@ public:
bool GetTimeIsFrozen() const;
UFUNCTION(Category = "Traffic Light", BlueprintCallable)
int GetNumChanges() const;
void SetPoleIndex(int InPoleIndex);
UFUNCTION(Category = "Traffic Light", BlueprintCallable)
int GetPoleIndex() const;
UFUNCTION(Category = "Traffic Light", BlueprintCallable)
TArray<ATrafficLightBase *> GetGroupTrafficLights() const;
UFUNCTION(Category = "Traffic Light", BlueprintCallable)
void SetGroupTrafficLights(TArray<ATrafficLightBase *> InGroupTrafficLights);
protected:
@ -113,5 +122,8 @@ private:
bool TimeIsFrozen = false;
UPROPERTY(Category = "Traffic Light", VisibleAnywhere)
int NumChanges = 0;
int PoleIndex = 0;
UPROPERTY(Category = "Traffic Light", VisibleAnywhere)
TArray<ATrafficLightBase *> GroupTrafficLights;
};

View File

@ -218,7 +218,7 @@ void ACarlaWheeledVehicle::ApplyVehiclePhysicsControl(const FVehiclePhysicsContr
Vehicle4W->SteeringCurve.EditorCurveData = PhysicsControl.SteeringCurve;
// Wheels Setup
for (uint32 i = 0; i < PhysicsControl.Wheels.Num(); ++i)
for (int32 i = 0; i < PhysicsControl.Wheels.Num(); ++i)
{
Vehicle4W->Wheels[i]->DampingRate = PhysicsControl.Wheels[i].DampingRate;
Vehicle4W->Wheels[i]->SteerAngle = PhysicsControl.Wheels[i].SteerAngle;

View File

@ -17,4 +17,4 @@
0.9.1: 1IZDzNQNVL67h8UlGyKuGegLH612Ifd7H
0.9.2: 1RKRGB22U5t80q4zwYXBJvxQXhzNjaaDf
0.9.3: 1jJlStNHpey62CrMkWVfmtQcJGO7PaD0R
Latest: 1Rr30x4BDCDLM7QfAFsQYhduy6De976qQ
Latest: 1LA1dLOozATCaJryqT7U_nOBR_nPVnBC8