From 994110047e7e5c314484a109f493fa23d22143eb Mon Sep 17 00:00:00 2001 From: nsubiron Date: Sun, 21 Oct 2018 23:29:12 +0200 Subject: [PATCH] Fix set actor transform broken for attached actors --- PythonAPI/manual_control.py | 9 +++++---- .../Carla/Source/Carla/Server/TheNewCarlaServer.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/PythonAPI/manual_control.py b/PythonAPI/manual_control.py index 74222a3c3..6b59f0dfa 100755 --- a/PythonAPI/manual_control.py +++ b/PythonAPI/manual_control.py @@ -342,8 +342,8 @@ class CameraManager(object): self._recording = False self._camera_transforms = [ carla.Transform(carla.Location(x=1.6, z=1.7)), - carla.Transform(carla.Location(x=-4.5, z=2.8), carla.Rotation(pitch=-15))] - self._current_transform = self._camera_transforms[0] + carla.Transform(carla.Location(x=-5.5, z=2.8), carla.Rotation(pitch=-15))] + self._transform_index = 0 self._sensors = [ ['sensor.camera.rgb', cc.None, 'Camera RGB'], ['sensor.camera.depth', cc.None, 'Camera Depth (Raw)'], @@ -363,7 +363,8 @@ class CameraManager(object): self.set_sensor(0) def toggle_camera(self): - self._hud.error('not implemented') + self._transform_index = (self._transform_index + 1) % len(self._camera_transforms) + self.sensor.set_transform(self._camera_transforms[self._transform_index]) def set_sensor(self, index): index = index % len(self._sensors) @@ -375,7 +376,7 @@ class CameraManager(object): self._surface = None self.sensor = self._parent.get_world().spawn_actor( self._sensors[index][-1], - self._current_transform, + self._camera_transforms[self._transform_index], attach_to=self._parent) # We need to pass the lambda a weak reference to self to avoid # circular reference. diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/TheNewCarlaServer.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/TheNewCarlaServer.cpp index 40bc9c0a0..08e6e4892 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/TheNewCarlaServer.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/TheNewCarlaServer.cpp @@ -283,7 +283,7 @@ void FTheNewCarlaServer::FPimpl::BindActions() Server.BindSync("set_actor_location", [this]( cr::Actor Actor, - cr::Location Location) -> bool { + cr::Location Location) { RequireEpisode(); auto ActorView = Episode->GetActorRegistry().Find(Actor.id); if (!ActorView.IsValid() || ActorView.GetActor()->IsPendingKill()) { @@ -292,7 +292,7 @@ void FTheNewCarlaServer::FPimpl::BindActions() // This function only works with teleport physics, to reset speeds we need // another method. /// @todo print error instead of returning false. - return ActorView.GetActor()->SetActorLocation( + ActorView.GetActor()->SetActorRelativeLocation( Location, false, nullptr, @@ -301,7 +301,7 @@ void FTheNewCarlaServer::FPimpl::BindActions() Server.BindSync("set_actor_transform", [this]( cr::Actor Actor, - cr::Transform Transform) -> bool { + cr::Transform Transform) { RequireEpisode(); auto ActorView = Episode->GetActorRegistry().Find(Actor.id); if (!ActorView.IsValid() || ActorView.GetActor()->IsPendingKill()) { @@ -309,7 +309,7 @@ void FTheNewCarlaServer::FPimpl::BindActions() } // This function only works with teleport physics, to reset speeds we need // another method. - return ActorView.GetActor()->SetActorTransform( + ActorView.GetActor()->SetActorRelativeTransform( Transform, false, nullptr,