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) #3779

Closed
wants to merge 6 commits into from
Closed
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
19 changes: 19 additions & 0 deletions AirLib/include/api/RpcLibClientBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,25 @@ namespace airlib
vector<ImageCaptureBase::ImageResponse> simGetImages(vector<ImageCaptureBase::ImageRequest> request, const std::string& vehicle_name = "");
vector<uint8_t> simGetImage(const std::string& camera_name, ImageCaptureBase::ImageType type, const std::string& vehicle_name = "");

//CinemAirSim
std::vector<std::string> simGetPresetLensSettings(const std::string& vehicle_name = "");
std::string simGetLensSettings(const std::string& vehicle_name = "");
void simSetPresetLensSettings(const std::string& preset_lens_settings = "", const std::string& vehicle_name = "");
std::vector<std::string> simGetPresetFilmbackSettings(const std::string& vehicle_name = "");
void simSetPresetFilmbackSettings(const std::string& preset_filmback_settings = "", const std::string& vehicle_name = "");
std::string simGetFilmbackSettings(const std::string& vehicle_name = "");
float simSetFilmbackSettings(const float sensor_width, const float sensor_heigth, const std::string& vehicle_name = "");
float simGetFocalLength(const std::string& vehicle_name = "");
void simSetFocalLength(float focal_length, const std::string& vehicle_name = "");
void simEnableManualFocus(const bool enable, const std::string& vehicle_name = "");
float simGetFocusDistance(const std::string& vehicle_name = "");
void simSetFocusDistance(float focus_distance, const std::string& vehicle_name = "");
float simGetFocusAperture(const std::string& vehicle_name = "");
void simSetFocusAperture(const float focus_aperture, const std::string& vehicle_name = "");
void simEnableFocusPlane(const bool enable, const std::string& vehicle_name = "");
std::string simGetCurrentFieldOfView(const std::string& vehicle_name = "");
//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/VehicleSimApiBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ namespace airlib
virtual std::vector<ImageCaptureBase::ImageResponse> getImages(const std::vector<ImageCaptureBase::ImageRequest>& request) const = 0;
virtual std::vector<uint8_t> getImage(const std::string& camera_name, ImageCaptureBase::ImageType image_type) const = 0;

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

virtual bool testLineOfSightToPoint(const GeoPoint& point) const = 0;
virtual bool testLineOfSightBetweenPoints(const GeoPoint& point1, const GeoPoint& point2) const = 0;
virtual void getWorldExtents(GeoPoint& min, GeoPoint& max) const = 0;
Expand Down
100 changes: 100 additions & 0 deletions AirLib/src/api/RpcLibClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,106 @@ __pragma(warning(disable : 4239))
return result;
}

//CinemAirSim
std::vector<std::string> RpcLibClientBase::simGetPresetLensSettings(const std::string& vehicle_name)
{
vector<std::string> result = pimpl_->client.call("simGetPresetLensSettings", vehicle_name).as<vector<std::string>>();

if (result.size() == 1) {
// rpclib has a bug with serializing empty vectors, so we return a 1 byte vector instead.
result.clear();
}
return result;
}

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

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

std::vector<std::string> RpcLibClientBase::simGetPresetFilmbackSettings(const std::string& vehicle_name)
{
vector<std::string> result = pimpl_->client.call("simGetPresetFilmbackSettings", vehicle_name).as<vector<std::string>>();

if (result.size() == 1) {
// rpclib has a bug with serializing empty vectors, so we return a 1 byte vector instead.
result.clear();
}
return result;
}

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

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

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

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

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

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

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

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

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

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

std::string RpcLibClientBase::simGetCurrentFieldOfView(const std::string& vehicle_name)
{
std::string result = pimpl_->client.call("simGetCurrentFieldOfView", vehicle_name).as<std::string>();
return result;
}
//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
80 changes: 80 additions & 0 deletions AirLib/src/api/RpcLibServerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,86 @@ namespace airlib
return getVehicleSimApi(vehicle_name)->getImage(camera_name, type);
});

//CinemAirSim
pimpl_->server.bind("simGetPresetLensSettings", [&](const std::string& vehicle_name) -> vector<string> {
auto result = getVehicleSimApi(vehicle_name)->getPresetLensSettings();
if (result.size() == 0) {
// rpclib has a bug with serializing empty vectors, so we return a 1 byte vector instead.
result.push_back("");
}
return result;
});

pimpl_->server.bind("simGetLensSettings", [&](const std::string& vehicle_name) -> string {
auto result = getVehicleSimApi(vehicle_name)->getLensSettings();
return result;
});

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

pimpl_->server.bind("simGetPresetFilmbackSettings", [&](const std::string& vehicle_name) -> vector<string> {
auto result = getVehicleSimApi(vehicle_name)->getPresetFilmbackSettings();
if (result.size() == 0) {
// rpclib has a bug with serializing empty vectors, so we return a 1 byte vector instead.
result.push_back("");
}
return result;
});

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

pimpl_->server.bind("simGetFilmbackSettings", [&](const std::string& vehicle_name) -> string {
auto result = getVehicleSimApi(vehicle_name)->getFilmbackSettings();
return result;
});

pimpl_->server.bind("simSetFilmbackSettings", [&](const float width, const float heigth, const std::string& vehicle_name) -> float {
auto result = getVehicleSimApi(vehicle_name)->setFilmbackSettings(width, heigth);
return result;
});

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

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

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

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

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

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

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

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

pimpl_->server.bind("simGetCurrentFieldOfView", [&](const std::string& vehicle_name) -> string {
auto result = getVehicleSimApi(vehicle_name)->getCurrentFieldOfView();
return result;
});
//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
133 changes: 133 additions & 0 deletions Unity/AirLibWrapper/AirsimWrapper/Source/PawnSimApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,139 @@ std::vector<uint8_t> PawnSimApi::getImage(const std::string& camera_name, ImageC
return std::vector<uint8_t>();
}

//CinemAirSim
std::vector<std::string> PawnSimApi::getPresetLensSettings()
{
std::vector<std::string> result;
throw std::invalid_argument(common_utils::Utils::stringf(
"getPresetLensSettings is not supported on unity")
.c_str());
return result;
}

std::string PawnSimApi::getLensSettings()
{
std::string result;
throw std::invalid_argument(common_utils::Utils::stringf(
"getLensSettings is not supported on unity")
.c_str());
return result;
}

void PawnSimApi::setPresetLensSettings(std::string preset)
{
throw std::invalid_argument(common_utils::Utils::stringf(
"setPresetLensSettings is not supported on unity")
.c_str());
}

std::vector<std::string> PawnSimApi::getPresetFilmbackSettings()
{
std::vector<std::string> result;
throw std::invalid_argument(common_utils::Utils::stringf(
"getPresetFilmbackSettings is not supported on unity")
.c_str());
return result;
}

void PawnSimApi::setPresetFilmbackSettings(std::string preset)
{
throw std::invalid_argument(common_utils::Utils::stringf(
"setPresetFilmbackSettings is not supported on unity")
.c_str());
}

std::string PawnSimApi::getFilmbackSettings()
{
std::string result;
throw std::invalid_argument(common_utils::Utils::stringf(
"getFilmbackSettings is not supported on unity")
.c_str());
return result;
}

float PawnSimApi::setFilmbackSettings(float width, float height)
{
float result;
throw std::invalid_argument(common_utils::Utils::stringf(
"setFilmbackSettings is not supported on unity")
.c_str());
return result;
}

float PawnSimApi::getFocalLength()
{
float result;
throw std::invalid_argument(common_utils::Utils::stringf(
"getFocalLength is not supported on unity")
.c_str());
return result;
}

void PawnSimApi::setFocalLength(float focal_length)
{
throw std::invalid_argument(common_utils::Utils::stringf(
"setFocalLength is not supported on unity")
.c_str());
}

void PawnSimApi::enableManualFocus(bool enable)
{
throw std::invalid_argument(common_utils::Utils::stringf(
"enableManualFocus is not supported on unity")
.c_str());
}

float PawnSimApi::getFocusDistance()
{
float result;
throw std::invalid_argument(common_utils::Utils::stringf(
"getFocusDistance is not supported on unity")
.c_str());
return result;
}

void PawnSimApi::setFocusDistance(float focus_distance)
{

throw std::invalid_argument(common_utils::Utils::stringf(
"setFocusDistance is not supported on unity")
.c_str());
}

float PawnSimApi::getFocusAperture()
{
float result;
throw std::invalid_argument(common_utils::Utils::stringf(
"getFocusAperture is not supported on unity")
.c_str());
return result;
}

void PawnSimApi::setFocusAperture(float focus_aperture)
{
throw std::invalid_argument(common_utils::Utils::stringf(
"setFocusAperture is not supported on unity")
.c_str());
}

void PawnSimApi::enableFocusPlane(bool enable)
{
throw std::invalid_argument(common_utils::Utils::stringf(
"enableFocusPlane is not supported on unity")
.c_str());
}

std::string PawnSimApi::getCurrentFieldOfView()
{
std::string result;
throw std::invalid_argument(common_utils::Utils::stringf(
"getCurrentFieldOfView is not supported on unity")
.c_str());
return result;
}
//End CinemAirSim

msr::airlib::RCData PawnSimApi::getRCData() const
{
AirSimRCData rcDataFromUnity = GetRCData(getVehicleName().c_str());
Expand Down
Loading