From 64b54572375b7b5a527e15e1e7c61bc726422875 Mon Sep 17 00:00:00 2001 From: MattRoweEAIF <125647690+MattRoweEAIF@users.noreply.github.com> Date: Fri, 9 Feb 2024 16:51:47 +0100 Subject: [PATCH 1/7] updated package naming instructions (#7140) --- Docs/tuto_content_authoring_maps.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Docs/tuto_content_authoring_maps.md b/Docs/tuto_content_authoring_maps.md index 04c4e541a..ffdda4f34 100644 --- a/Docs/tuto_content_authoring_maps.md +++ b/Docs/tuto_content_authoring_maps.md @@ -422,10 +422,10 @@ Drag your desired foliage item into the box labeled `+ Drop Foliage Here`. Set a To export a map as a map package that can be ingested into a standalone CARLA package installation, use the `make package` command as follows: ```sh -make package ARGS="--packages=" +make package ARGS="--packages=" ``` -The `` must point to a json file located in `CARLA_ROOT/Unreal/CarlaUE4/Content/Carla/Config` named *mapPackage.json* which has the following structure: +The `` must point to a json file located in `CARLA_ROOT/Unreal/CarlaUE4/Content/Carla/Config` named *mapName.Package.json* which has the following structure: ```json { From 46aa683d2cbb6903c3fd8f3ede1ed3c2c85b0612 Mon Sep 17 00:00:00 2001 From: Ruben Abad Date: Mon, 12 Feb 2024 12:47:58 +0100 Subject: [PATCH 2/7] Archive all Carla server logs --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 1ba592edd..eeab4d975 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -189,12 +189,14 @@ pipeline sh 'DISPLAY= ./Dist/CarlaUE4.sh -nullrhi -RenderOffScreen --carla-rpc-port=3654 --carla-streaming-port=0 -nosound > CarlaUE4.log &' sh 'make smoke_tests ARGS="--xml --python-version=3.8 --target-wheel-platform=manylinux_2_27_x86_64"' sh 'make run-examples ARGS="localhost 3654"' + sh 'tar -czf CarlaUE_logs.tar.gz Unreal/CarlaUE4/Saved/Logs/' } post { always { archiveArtifacts 'CarlaUE4.log' + archiveArtifacts 'CarlaUE_logs.tar.gz' junit 'Build/test-results/smoke-tests-*.xml' } } From dfe80d11a18d2ea13371619478688ec2223cabe5 Mon Sep 17 00:00:00 2001 From: Ruben Abad Date: Mon, 12 Feb 2024 12:51:56 +0100 Subject: [PATCH 3/7] clean pipeline workspace --- Jenkinsfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index eeab4d975..688e6a8bd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -323,6 +323,13 @@ pipeline } } } + post + { + always + { + deleteDir() + } + } /* stage('windows') { From 2516d4b9f2d9784c7b41ea0734a7f5e2dd8a03b2 Mon Sep 17 00:00:00 2001 From: Ruben Abad Date: Mon, 12 Feb 2024 12:56:19 +0100 Subject: [PATCH 4/7] fix failure on post --- Jenkinsfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 688e6a8bd..5ac125638 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -322,12 +322,12 @@ pipeline } } } - } - post - { - always + post { - deleteDir() + always + { + deleteDir() + } } } /* From 0b13c72d63a7b9754971628cbc57e5136a451ef4 Mon Sep 17 00:00:00 2001 From: Aperiss Date: Fri, 9 Feb 2024 18:53:10 +0100 Subject: [PATCH 5/7] Add actor component getters to the PythonAPI Adds functions: - get_component_world_transform - get_component_relative_transform to the Python API to acces the transform of actor components by name --- LibCarla/source/carla/client/Actor.cpp | 8 ++ LibCarla/source/carla/client/Actor.h | 4 + .../source/carla/client/detail/Client.cpp | 8 ++ LibCarla/source/carla/client/detail/Client.h | 9 ++ .../source/carla/client/detail/Simulator.h | 8 ++ PythonAPI/carla/source/libcarla/Actor.cpp | 2 + .../Carla/Source/Carla/Server/CarlaServer.cpp | 88 +++++++++++++++++++ .../Carla/Server/CarlaServerResponse.cpp | 2 + .../Source/Carla/Server/CarlaServerResponse.h | 1 + 9 files changed, 130 insertions(+) diff --git a/LibCarla/source/carla/client/Actor.cpp b/LibCarla/source/carla/client/Actor.cpp index 36cb0bc41..cfddf041b 100644 --- a/LibCarla/source/carla/client/Actor.cpp +++ b/LibCarla/source/carla/client/Actor.cpp @@ -32,6 +32,14 @@ namespace client { return GetEpisode().Lock()->GetActorAcceleration(*this); } + geom::Transform Actor::GetComponentWorldTransform(const std::string componentName) const { + return GetEpisode().Lock()->GetActorComponentWorldTransform(*this, componentName); + } + + geom::Transform Actor::GetComponentRelativeTransform(const std::string componentName) const { + return GetEpisode().Lock()->GetActorComponentRelativeTransform(*this, componentName); + } + void Actor::SetLocation(const geom::Location &location) { GetEpisode().Lock()->SetActorLocation(*this, location); } diff --git a/LibCarla/source/carla/client/Actor.h b/LibCarla/source/carla/client/Actor.h index 639a7ecb2..79d757468 100644 --- a/LibCarla/source/carla/client/Actor.h +++ b/LibCarla/source/carla/client/Actor.h @@ -60,6 +60,10 @@ namespace client { /// acceleration calculated after the actor's velocity. geom::Vector3D GetAcceleration() const; + geom::Transform GetComponentWorldTransform(const std::string componentName) const; + + geom::Transform GetComponentRelativeTransform(const std::string componentName) const; + /// Teleport the actor to @a location. void SetLocation(const geom::Location &location); diff --git a/LibCarla/source/carla/client/detail/Client.cpp b/LibCarla/source/carla/client/detail/Client.cpp index 16158d538..2cf28c7ef 100644 --- a/LibCarla/source/carla/client/detail/Client.cpp +++ b/LibCarla/source/carla/client/detail/Client.cpp @@ -408,6 +408,14 @@ namespace detail { _pimpl->AsyncCall("add_actor_torque", actor, vector); } + geom::Transform Client::GetActorComponentWorldTransform(rpc::ActorId actor, const std::string componentName) { + return _pimpl->CallAndWait("get_actor_component_world_transform", actor, componentName); + } + + geom::Transform Client::GetActorComponentRelativeTransform(rpc::ActorId actor, const std::string componentName) { + return _pimpl->CallAndWait("get_actor_component_relative_transform", actor, componentName); + } + void Client::SetActorSimulatePhysics(rpc::ActorId actor, const bool enabled) { _pimpl->CallAndWait("set_actor_simulate_physics", actor, enabled); } diff --git a/LibCarla/source/carla/client/detail/Client.h b/LibCarla/source/carla/client/detail/Client.h index e0650ee24..0327adbb6 100644 --- a/LibCarla/source/carla/client/detail/Client.h +++ b/LibCarla/source/carla/client/detail/Client.h @@ -88,6 +88,7 @@ namespace detail { void DestroyTrafficManager(uint16_t port) const; + void SetTimeout(time_duration timeout); time_duration GetTimeout() const; @@ -232,6 +233,14 @@ namespace detail { rpc::ActorId actor, const geom::Vector3D &vector); + geom::Transform GetActorComponentWorldTransform( + rpc::ActorId actor, + const std::string componentName); + + geom::Transform GetActorComponentRelativeTransform( + rpc::ActorId actor, + const std::string componentName); + void SetActorSimulatePhysics( rpc::ActorId actor, bool enabled); diff --git a/LibCarla/source/carla/client/detail/Simulator.h b/LibCarla/source/carla/client/detail/Simulator.h index cf4308f4b..76981d4e3 100644 --- a/LibCarla/source/carla/client/detail/Simulator.h +++ b/LibCarla/source/carla/client/detail/Simulator.h @@ -438,6 +438,14 @@ namespace detail { return GetActorSnapshot(actor).acceleration; } + geom::Transform GetActorComponentWorldTransform(const Actor &actor, const std::string componentName) { + return _client.GetActorComponentWorldTransform(actor.GetId(), componentName); + } + + geom::Transform GetActorComponentRelativeTransform(const Actor &actor, std::string componentName) { + return _client.GetActorComponentRelativeTransform(actor.GetId(), componentName); + } + void SetActorLocation(Actor &actor, const geom::Location &location) { _client.SetActorLocation(actor.GetId(), location); } diff --git a/PythonAPI/carla/source/libcarla/Actor.cpp b/PythonAPI/carla/source/libcarla/Actor.cpp index f0c1b670b..9686bb735 100644 --- a/PythonAPI/carla/source/libcarla/Actor.cpp +++ b/PythonAPI/carla/source/libcarla/Actor.cpp @@ -113,6 +113,8 @@ void export_actor() { .def("get_velocity", &cc::Actor::GetVelocity) .def("get_angular_velocity", &cc::Actor::GetAngularVelocity) .def("get_acceleration", &cc::Actor::GetAcceleration) + .def("get_component_world_transform", &cc::Actor::GetComponentWorldTransform, (arg("component_name"))) + .def("get_component_relative_transform", &cc::Actor::GetComponentRelativeTransform, (arg("component_name"))) .def("set_location", &cc::Actor::SetLocation, (arg("location"))) .def("set_transform", &cc::Actor::SetTransform, (arg("transform"))) .def("set_target_velocity", &cc::Actor::SetTargetVelocity, (arg("velocity"))) diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp index 39e797d50..af6cbc658 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp @@ -1274,6 +1274,94 @@ BIND_SYNC(is_sensor_enabled_for_ros) << [this](carla::streaming::detail::stream_ return R::Success(); }; + BIND_SYNC(get_actor_component_world_transform) << [this]( + cr::ActorId ActorId, + const std::string componentName) -> R + { + REQUIRE_CARLA_EPISODE(); + FCarlaActor* CarlaActor = Episode->FindCarlaActor(ActorId); + if (!CarlaActor) + { + return RespondError( + "get_actor_component_world_transform", + ECarlaServerResponse::ActorNotFound, + " Actor Id: " + FString::FromInt(ActorId)); + } + else + { + TArray Components; + CarlaActor->GetActor()->GetComponents(Components); + + USceneComponent* Component; + for(auto Cmp : Components) + { + if(USceneComponent* SCMP = Cast(Cmp)) + { + if(SCMP->GetName() == componentName.c_str()) + { + Component = SCMP; + break; + } + } + } + + if(!Component) + { + return RespondError( + "get_actor_component_world_transform", + ECarlaServerResponse::ComponentNotFound, + " Component Name: " + FString(componentName.c_str())); + } + + FTransform ComponentWorldTransform = Component->GetComponentTransform(); + return cr::Transform(ComponentWorldTransform); + } + }; + + BIND_SYNC(get_actor_component_relative_transform) << [this]( + cr::ActorId ActorId, + const std::string componentName) -> R + { + REQUIRE_CARLA_EPISODE(); + FCarlaActor* CarlaActor = Episode->FindCarlaActor(ActorId); + if (!CarlaActor) + { + return RespondError( + "get_actor_component_relative_transform", + ECarlaServerResponse::ActorNotFound, + " Actor Id: " + FString::FromInt(ActorId)); + } + else + { + TArray Components; + CarlaActor->GetActor()->GetComponents(Components); + + USceneComponent* Component; + for(auto Cmp : Components) + { + if(USceneComponent* SCMP = Cast(Cmp)) + { + if(SCMP->GetName() == componentName.c_str()) + { + Component = SCMP; + break; + } + } + } + + if(!Component) + { + return RespondError( + "get_actor_component_world_transform", + ECarlaServerResponse::ComponentNotFound, + " Component Name: " + FString(componentName.c_str())); + } + + FTransform ComponentRelativeTransform = Component->GetRelativeTransform(); + return cr::Transform(ComponentRelativeTransform); + } + }; + BIND_SYNC(get_physics_control) << [this]( cr::ActorId ActorId) -> R { diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServerResponse.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServerResponse.cpp index 961fcbb85..2e5901119 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServerResponse.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServerResponse.cpp @@ -14,6 +14,8 @@ FString CarlaGetStringError(ECarlaServerResponse Response) return "Sucess"; case ECarlaServerResponse::ActorNotFound: return "Actor could not be found in the registry"; + case ECarlaServerResponse::ComponentNotFound: + return "Component could not be found in this actor"; case ECarlaServerResponse::ActorTypeMismatch: return "Actor does not match the expected type"; case ECarlaServerResponse::MissingActor: diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServerResponse.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServerResponse.h index f5bf72c8b..70125d04f 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServerResponse.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServerResponse.h @@ -10,6 +10,7 @@ enum class ECarlaServerResponse { Success, ActorNotFound, + ComponentNotFound, ActorTypeMismatch, FunctionNotSupported, NullActor, From 193d9cf7cdef4bbcaa88db65cb27d493d9836a76 Mon Sep 17 00:00:00 2001 From: Aperiss Date: Mon, 12 Feb 2024 09:36:55 +0100 Subject: [PATCH 6/7] Update changelog for get-transform-component changes --- CHANGELOG.md | 3 ++- PythonAPI/examples/get_component_test.py | 34 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 PythonAPI/examples/get_component_test.py diff --git a/CHANGELOG.md b/CHANGELOG.md index a361dd37a..f4672927e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Latest Changes * Prevent from segfault on failing SignalReference identification when loading OpenDrive files - * Added vehicle doors to the recorder + * Added vehicle doors to the recorder + * Added functions to get actor' components transform ## CARLA 0.9.15 diff --git a/PythonAPI/examples/get_component_test.py b/PythonAPI/examples/get_component_test.py new file mode 100644 index 000000000..099fc7b10 --- /dev/null +++ b/PythonAPI/examples/get_component_test.py @@ -0,0 +1,34 @@ +import glob +import os +import sys + +try: + sys.path.append(glob.glob('../carla/dist/carla-*%d.%d-%s.egg' % ( + sys.version_info.major, + sys.version_info.minor, + 'win-amd64' if os.name == 'nt' else 'linux-x86_64'))[0]) +except IndexError: + pass + + +# ============================================================================== +# -- imports ------------------------------------------------------------------- +# ============================================================================== + + +import carla + +client = carla.Client('localhost', 2000) +world = client.get_world() + +location = carla.Location(200.0, 200.0, 200.0) +rotation = carla.Rotation(0.0, 0.0, 0.0) +transform = carla.Transform(location, rotation) + +bp_library = world.get_blueprint_library() +bp_audi = bp_library.find('vehicle.audi.tt') +audi = world.spawn_actor(bp_audi, transform) + +component_transform = audi.get_component_world_transform('front-blinker-r-1') +print(component_transform) + From 02289cbea0e38beae0a93ebe1c1292e814079022 Mon Sep 17 00:00:00 2001 From: Ruben Abad Date: Tue, 13 Feb 2024 14:08:54 +0100 Subject: [PATCH 7/7] fix artifact name --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5ac125638..640c5f945 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -189,14 +189,14 @@ pipeline sh 'DISPLAY= ./Dist/CarlaUE4.sh -nullrhi -RenderOffScreen --carla-rpc-port=3654 --carla-streaming-port=0 -nosound > CarlaUE4.log &' sh 'make smoke_tests ARGS="--xml --python-version=3.8 --target-wheel-platform=manylinux_2_27_x86_64"' sh 'make run-examples ARGS="localhost 3654"' - sh 'tar -czf CarlaUE_logs.tar.gz Unreal/CarlaUE4/Saved/Logs/' + sh 'tar -czf CarlaUE4_logs.tar.gz Unreal/CarlaUE4/Saved/Logs/' } post { always { archiveArtifacts 'CarlaUE4.log' - archiveArtifacts 'CarlaUE_logs.tar.gz' + archiveArtifacts 'CarlaUE4_logs.tar.gz' junit 'Build/test-results/smoke-tests-*.xml' } }