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

Camera replaced by Cinematographic Camera (CinemAirSim) #3949

Merged
merged 12 commits into from
Dec 21, 2021
18 changes: 18 additions & 0 deletions AirLib/include/api/RpcLibClientBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,24 @@ namespace airlib
vector<ImageCaptureBase::ImageResponse> simGetImages(vector<ImageCaptureBase::ImageRequest> request, const std::string& vehicle_name = "", bool external = false);
vector<uint8_t> simGetImage(const std::string& camera_name, ImageCaptureBase::ImageType type, const std::string& vehicle_name = "", bool external = false);

//CinemAirSim
std::vector<std::string> simGetPresetLensSettings(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
std::string simGetLensSettings(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
void simSetPresetLensSettings(const std::string& preset_lens_settings, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
std::vector<std::string> simGetPresetFilmbackSettings(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
void simSetPresetFilmbackSettings(const std::string& preset_filmback_settings, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
std::string simGetFilmbackSettings(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
float simSetFilmbackSettings(const float sensor_width, const float sensor_heigth, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
float simGetFocalLength(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
void simSetFocalLength(float focal_length, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
void simEnableManualFocus(const bool enable, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
float simGetFocusDistance(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
void simSetFocusDistance(float focus_distance, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
float simGetFocusAperture(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
void simSetFocusAperture(const float focus_aperture, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
void simEnableFocusPlane(const bool enable, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
std::string simGetCurrentFieldOfView(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
//end CinemAirSim
bool simTestLineOfSightToPoint(const msr::airlib::GeoPoint& point, const std::string& vehicle_name = "");
bool simTestLineOfSightBetweenPoints(const msr::airlib::GeoPoint& point1, const msr::airlib::GeoPoint& point2);
vector<msr::airlib::GeoPoint> simGetWorldExtents();
Expand Down
19 changes: 19 additions & 0 deletions AirLib/include/api/WorldSimApiBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,25 @@ namespace airlib
const std::string& vehicle_name, bool external) const = 0;
virtual std::vector<uint8_t> getImage(ImageCaptureBase::ImageType image_type, const CameraDetails& camera_details) const = 0;

//CinemAirSim
virtual std::vector<std::string> getPresetLensSettings(const CameraDetails& camera_details) = 0;
virtual std::string getLensSettings(const CameraDetails& camera_details) = 0;
virtual void setPresetLensSettings(std::string, const CameraDetails& camera_details) = 0;
virtual std::vector<std::string> getPresetFilmbackSettings(const CameraDetails& camera_details) = 0;
virtual void setPresetFilmbackSettings(std::string, const CameraDetails& camera_details) = 0;
virtual std::string getFilmbackSettings(const CameraDetails& camera_details) = 0;
virtual float setFilmbackSettings(float width, float height, const CameraDetails& camera_details) = 0;
virtual float getFocalLength(const CameraDetails& camera_details) = 0;
virtual void setFocalLength(float focal_length, const CameraDetails& camera_details) = 0;
virtual void enableManualFocus(bool enable, const CameraDetails& camera_details) = 0;
virtual float getFocusDistance(const CameraDetails& camera_details) = 0;
virtual void setFocusDistance(float focus_distance, const CameraDetails& camera_details) = 0;
virtual float getFocusAperture(const CameraDetails& camera_details) = 0;
virtual void setFocusAperture(float focus_aperture, const CameraDetails& camera_details) = 0;
virtual void enableFocusPlane(bool enable, const CameraDetails& camera_details) = 0;
virtual std::string getCurrentFieldOfView(const CameraDetails& camera_details) = 0;
//end CinemAirSim

virtual void addDetectionFilterMeshName(ImageCaptureBase::ImageType image_type, const std::string& mesh_name, const CameraDetails& camera_details) = 0;
virtual void setDetectionFilterRadius(ImageCaptureBase::ImageType image_type, float radius_cm, const CameraDetails& camera_details) = 0;
virtual void clearDetectionMeshNames(ImageCaptureBase::ImageType image_type, const CameraDetails& camera_details) = 0;
Expand Down
85 changes: 81 additions & 4 deletions AirLib/src/api/RpcLibClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,90 @@ __pragma(warning(disable : 4239))
vector<uint8_t> RpcLibClientBase::simGetImage(const std::string& camera_name, ImageCaptureBase::ImageType type, const std::string& vehicle_name, bool external)
{
vector<uint8_t> result = pimpl_->client.call("simGetImage", camera_name, type, vehicle_name, external).as<vector<uint8_t>>();
if (result.size() == 1) {
// rpclib has a bug with serializing empty vectors, so we return a 1 byte vector instead.
result.clear();
}
return result;
}

//CinemAirSim
std::vector<std::string> RpcLibClientBase::simGetPresetLensSettings(const std::string& camera_name, const std::string& vehicle_name, bool external)
{
return pimpl_->client.call("simGetPresetLensSettings", camera_name, vehicle_name, external).as<vector<std::string>>();
}

std::string RpcLibClientBase::simGetLensSettings(const std::string& camera_name, const std::string& vehicle_name, bool external)
{
return pimpl_->client.call("simGetLensSettings", camera_name, vehicle_name, external).as<std::string>();
}

void RpcLibClientBase::simSetPresetLensSettings(const std::string& preset_lens_settings, const std::string& camera_name, const std::string& vehicle_name, bool external)
{
pimpl_->client.call("simSetPresetLensSettings", preset_lens_settings, camera_name, vehicle_name, external);
}

std::vector<std::string> RpcLibClientBase::simGetPresetFilmbackSettings(const std::string& camera_name, const std::string& vehicle_name, bool external)
{
return pimpl_->client.call("simGetPresetFilmbackSettings", camera_name, vehicle_name, external).as<vector<std::string>>();
}

void RpcLibClientBase::simSetPresetFilmbackSettings(const std::string& preset_filmback_settings, const std::string& camera_name, const std::string& vehicle_name, bool external)
{
pimpl_->client.call("simSetPresetFilmbackSettings", preset_filmback_settings, camera_name, vehicle_name, external);
}

std::string RpcLibClientBase::simGetFilmbackSettings(const std::string& camera_name, const std::string& vehicle_name, bool external)
{
return pimpl_->client.call("simGetFilmbackSettings", camera_name, vehicle_name, external).as<std::string>();
}

float RpcLibClientBase::simSetFilmbackSettings(const float sensor_width, const float sensor_height, const std::string& camera_name, const std::string& vehicle_name, bool external)
{
return pimpl_->client.call("simSetFilmbackSettings", sensor_width, sensor_height, camera_name, vehicle_name, external).as<float>();
}

float RpcLibClientBase::simGetFocalLength(const std::string& camera_name, const std::string& vehicle_name, bool external)
{
return pimpl_->client.call("simGetFocalLength", camera_name, vehicle_name, external).as<float>();
}

void RpcLibClientBase::simSetFocalLength(const float focal_length, const std::string& camera_name, const std::string& vehicle_name, bool external)
{
pimpl_->client.call("simSetFocalLength", focal_length, camera_name, vehicle_name, external);
}

void RpcLibClientBase::simEnableManualFocus(const bool enable, const std::string& camera_name, const std::string& vehicle_name, bool external)
{
pimpl_->client.call("simEnableManualFocus", enable, camera_name, vehicle_name, external);
}

float RpcLibClientBase::simGetFocusDistance(const std::string& camera_name, const std::string& vehicle_name, bool external)
{
return pimpl_->client.call("simGetFocusDistance", camera_name, vehicle_name, external).as<float>();
}
void RpcLibClientBase::simSetFocusDistance(const float focus_distance, const std::string& camera_name, const std::string& vehicle_name, bool external)
{
pimpl_->client.call("simSetFocusDistance", focus_distance, camera_name, vehicle_name, external);
}

float RpcLibClientBase::simGetFocusAperture(const std::string& camera_name, const std::string& vehicle_name, bool external)
{
return pimpl_->client.call("simGetFocusAperture", camera_name, vehicle_name, external).as<float>();
}

void RpcLibClientBase::simSetFocusAperture(const float focus_aperture, const std::string& camera_name, const std::string& vehicle_name, bool external)
{
pimpl_->client.call("simSetFocusAperture", focus_aperture, camera_name, vehicle_name, external);
}

void RpcLibClientBase::simEnableFocusPlane(const bool enable, const std::string& camera_name, const std::string& vehicle_name, bool external)
{
pimpl_->client.call("simEnableFocusPlane", enable, camera_name, vehicle_name, external);
}

std::string RpcLibClientBase::simGetCurrentFieldOfView(const std::string& camera_name, const std::string& vehicle_name, bool external)
{
return pimpl_->client.call("simGetCurrentFieldOfView", camera_name, vehicle_name, external).as<std::string>();
}
//End CinemAirSim

// Minor TODO: consider msgpack magic for GeoPoint, so we can have one arg instead of three
bool RpcLibClientBase::simTestLineOfSightToPoint(const msr::airlib::GeoPoint& point, const std::string& vehicle_name)
{
Expand Down
67 changes: 67 additions & 0 deletions AirLib/src/api/RpcLibServerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,73 @@ namespace airlib
return getWorldSimApi()->getImage(type, CameraDetails(camera_name, vehicle_name, external));
});

//CinemAirSim
pimpl_->server.bind("simGetPresetLensSettings", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> vector<string> {
return getWorldSimApi()->getPresetLensSettings(CameraDetails(camera_name, vehicle_name, external));
});

pimpl_->server.bind("simGetLensSettings", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> string {
return getWorldSimApi()->getLensSettings(CameraDetails(camera_name, vehicle_name, external));
});

pimpl_->server.bind("simSetPresetLensSettings", [&](const std::string preset_lens_settings, const std::string& camera_name, const std::string& vehicle_name, bool external) -> void {
getWorldSimApi()->setPresetLensSettings(preset_lens_settings, CameraDetails(camera_name, vehicle_name, external));
});

pimpl_->server.bind("simGetPresetFilmbackSettings", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> vector<string> {
return getWorldSimApi()->getPresetFilmbackSettings(CameraDetails(camera_name, vehicle_name, external));
});

pimpl_->server.bind("simSetPresetFilmbackSettings", [&](const std::string preset_filmback_settings, const std::string& camera_name, const std::string& vehicle_name, bool external) -> void {
getWorldSimApi()->setPresetFilmbackSettings(preset_filmback_settings, CameraDetails(camera_name, vehicle_name, external));
});

pimpl_->server.bind("simGetFilmbackSettings", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> string {
return getWorldSimApi()->getFilmbackSettings(CameraDetails(camera_name, vehicle_name, external));
});

pimpl_->server.bind("simSetFilmbackSettings", [&](const float width, const float heigth, const std::string& camera_name, const std::string& vehicle_name, bool external) -> float {
return getWorldSimApi()->setFilmbackSettings(width, heigth, CameraDetails(camera_name, vehicle_name, external));
;
});

pimpl_->server.bind("simGetFocalLength", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> float {
return getWorldSimApi()->getFocalLength(CameraDetails(camera_name, vehicle_name, external));
});

pimpl_->server.bind("simSetFocalLength", [&](const float focal_lenght, const std::string& camera_name, const std::string& vehicle_name, bool external) -> void {
getWorldSimApi()->setFocalLength(focal_lenght, CameraDetails(camera_name, vehicle_name, external));
});

pimpl_->server.bind("simEnableManualFocus", [&](const bool enable, const std::string& camera_name, const std::string& vehicle_name, bool external) -> void {
getWorldSimApi()->enableManualFocus(enable, CameraDetails(camera_name, vehicle_name, external));
});

pimpl_->server.bind("simGetFocusDistance", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> float {
return getWorldSimApi()->getFocusDistance(CameraDetails(camera_name, vehicle_name, external));
});

pimpl_->server.bind("simSetFocusDistance", [&](const float focus_distance, const std::string& camera_name, const std::string& vehicle_name, bool external) -> void {
getWorldSimApi()->setFocusDistance(focus_distance, CameraDetails(camera_name, vehicle_name, external));
});

pimpl_->server.bind("simGetFocusAperture", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> float {
return getWorldSimApi()->getFocusAperture(CameraDetails(camera_name, vehicle_name, external));
});

pimpl_->server.bind("simSetFocusAperture", [&](const float focus_aperture, const std::string& camera_name, const std::string& vehicle_name, bool external) -> void {
getWorldSimApi()->setFocusAperture(focus_aperture, CameraDetails(camera_name, vehicle_name, external));
});

pimpl_->server.bind("simEnableFocusPlane", [&](const bool enable, const std::string& camera_name, const std::string& vehicle_name, bool external) -> void {
getWorldSimApi()->enableFocusPlane(enable, CameraDetails(camera_name, vehicle_name, external));
});

pimpl_->server.bind("simGetCurrentFieldOfView", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> string {
return getWorldSimApi()->getCurrentFieldOfView(CameraDetails(camera_name, vehicle_name, external));
});
//end CinemAirSim

pimpl_->server.bind("simTestLineOfSightToPoint", [&](const RpcLibAdaptorsBase::GeoPoint& point, const std::string& vehicle_name) -> bool {
return getVehicleSimApi(vehicle_name)->testLineOfSightToPoint(point.to());
});
Expand Down
Loading