Fix set actor transform broken for attached actors

This commit is contained in:
nsubiron 2018-10-21 23:29:12 +02:00
parent d5392c7408
commit 994110047e
2 changed files with 9 additions and 8 deletions

View File

@ -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.

View File

@ -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,