Skip to content

Commit

Permalink
Add backwards-compatibility layer for simSetCameraPose
Browse files Browse the repository at this point in the history
Earlier was called simSetCameraOrientation
  • Loading branch information
rajat2004 committed Aug 19, 2020
1 parent bd8ee6b commit aabba87
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions AirLib/include/api/RpcLibClientBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions AirLib/src/api/RpcLibClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 17 additions & 0 deletions PythonClient/airsim/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aabba87

Please sign in to comment.