Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backwards-compatibility layer for simSetCameraPose #2932

Merged
merged 1 commit into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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