diff --git a/LibCarla/source/carla/client/Actor.h b/LibCarla/source/carla/client/Actor.h index 359ddd424..09c2e2859 100644 --- a/LibCarla/source/carla/client/Actor.h +++ b/LibCarla/source/carla/client/Actor.h @@ -15,7 +15,7 @@ namespace client { class Actor : public EnableSharedFromThis, - private detail::ActorState { + public detail::ActorState { using Super = detail::ActorState; public: @@ -23,10 +23,6 @@ namespace client { virtual ~Actor() = default; - using Super::GetId; - using Super::GetTypeId; - using Super::GetDisplayId; - using Super::GetWorld; geom::Location GetLocation() const; @@ -48,8 +44,6 @@ namespace client { protected: - using Super::GetActorDescription; - auto GetClientImplementation() const { return GetWorld().parent; } diff --git a/LibCarla/source/carla/client/detail/ActorState.h b/LibCarla/source/carla/client/detail/ActorState.h index abdad249e..684d43347 100644 --- a/LibCarla/source/carla/client/detail/ActorState.h +++ b/LibCarla/source/carla/client/detail/ActorState.h @@ -29,14 +29,16 @@ namespace detail { std::string GetDisplayId() const; - const rpc::Actor &GetActorDescription() const { - return _description; - } - World GetWorld() const { return _parent; } + protected: + + const rpc::Actor &GetActorDescription() const { + return _description; + } + private: ActorState(rpc::Actor description, World parent) diff --git a/PythonAPI/source/libcarla/Actor.cpp b/PythonAPI/source/libcarla/Actor.cpp index 4f10c032c..2a50908f1 100644 --- a/PythonAPI/source/libcarla/Actor.cpp +++ b/PythonAPI/source/libcarla/Actor.cpp @@ -27,10 +27,11 @@ void export_actor() { namespace cr = carla::rpc; class_>("Actor", no_init) - .add_property("id", &cc::Actor::GetId) - .add_property("type_id", +[](const cc::Actor &self) -> std::string { return self.GetTypeId(); }) - .add_property("is_alive", &cc::Actor::IsAlive) - .def("get_world", &cc::Actor::GetWorld) + // work-around, force return copy to resolve Actor instead of ActorState. + .add_property("id", CALL_RETURNING_COPY(cc::Actor, GetId)) + .add_property("type_id", CALL_RETURNING_COPY(cc::Actor, GetTypeId)) + .add_property("is_alive", CALL_RETURNING_COPY(cc::Actor, IsAlive)) + .def("get_world", CALL_RETURNING_COPY(cc::Actor, GetWorld)) .def("get_location", CONST_CALL_WITHOUT_GIL(cc::Actor, GetLocation)) .def("get_transform", CONST_CALL_WITHOUT_GIL(cc::Actor, GetTransform)) .def("set_location", &cc::Actor::SetLocation, (arg("location")))