From aabba87804eee8bb6ccafb6d034dfc769e837be5 Mon Sep 17 00:00:00 2001 From: Rajat Singhal Date: Thu, 13 Aug 2020 12:02:54 +0530 Subject: [PATCH] Add backwards-compatibility layer for simSetCameraPose Earlier was called simSetCameraOrientation --- AirLib/include/api/RpcLibClientBase.hpp | 2 ++ AirLib/src/api/RpcLibClientBase.cpp | 7 +++++++ PythonClient/airsim/client.py | 17 +++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/AirLib/include/api/RpcLibClientBase.hpp b/AirLib/include/api/RpcLibClientBase.hpp index 7f98072743..e9f1e0169f 100644 --- a/AirLib/include/api/RpcLibClientBase.hpp +++ b/AirLib/include/api/RpcLibClientBase.hpp @@ -103,6 +103,8 @@ class RpcLibClientBase { CameraInfo simGetCameraInfo(const std::string& camera_name, const std::string& vehicle_name = "") const; void simSetCameraPose(const std::string& camera_name, const Pose& pose, const std::string& vehicle_name = ""); void simSetCameraFov(const std::string& camera_name, float fov_degrees, const std::string& vehicle_name = ""); + // This is a backwards-compatibility wrapper over simSetCameraPose, and can be removed in future major releases + void simSetCameraOrientation(const std::string& camera_name, const Quaternionr& orientation, const std::string& vehicle_name = ""); msr::airlib::Kinematics::State simGetGroundTruthKinematics(const std::string& vehicle_name = "") const; msr::airlib::Environment::State simGetGroundTruthEnvironment(const std::string& vehicle_name = "") const; diff --git a/AirLib/src/api/RpcLibClientBase.cpp b/AirLib/src/api/RpcLibClientBase.cpp index be9c01fe80..970288895a 100644 --- a/AirLib/src/api/RpcLibClientBase.cpp +++ b/AirLib/src/api/RpcLibClientBase.cpp @@ -386,6 +386,13 @@ void RpcLibClientBase::simSetCameraPose(const std::string& camera_name, const Po pimpl_->client.call("simSetCameraPose", camera_name, RpcLibAdapatorsBase::Pose(pose), vehicle_name); } +void RpcLibClientBase::simSetCameraOrientation(const std::string& camera_name, const Quaternionr& orientation, const std::string& vehicle_name) +{ + std::cout << "`simSetCameraOrientation` API has been upgraded to `simSetCameraPose`. Please update your code." << std::endl; + Pose pose{Vector3r::Zero(), orientation}; + RpcLibClientBase::simSetCameraPose(camera_name, pose, vehicle_name); +} + void RpcLibClientBase::simSetCameraFov(const std::string& camera_name, float fov_degrees, const std::string& vehicle_name) { pimpl_->client.call("simSetCameraFov", camera_name, fov_degrees, vehicle_name); diff --git a/PythonClient/airsim/client.py b/PythonClient/airsim/client.py index a6553093bd..0da50b0d1b 100644 --- a/PythonClient/airsim/client.py +++ b/PythonClient/airsim/client.py @@ -480,6 +480,23 @@ def simSetCameraPose(self, camera_name, pose, vehicle_name = ''): # TODO: below str() conversion is only needed for legacy reason and should be removed in future self.client.call('simSetCameraPose', str(camera_name), pose, vehicle_name) + def simSetCameraOrientation(self, camera_name, orientation, vehicle_name = ''): + """ + .. note:: + + This API has been upgraded to `simSetCameraPose` + + - Control the Orientation of a selected camera + + Args: + camera_name (str): Name of the camera to be controlled + orientation (Quaternionr): Quaternion representing the desired orientation of the camera + vehicle_name (str, optional): Name of vehicle which the camera corresponds to + """ + logging.warning("`simSetCameraOrientation` API has been upgraded to `simSetCameraPose`. Please update your code.") + pose = Pose(orientation_val=orientation) + self.simSetCameraPose(camera_name, pose, vehicle_name) + def simSetCameraFov(self, camera_name, fov_degrees, vehicle_name = ''): """ - Control the field of view of a selected camera