Skip to content

Commit bca2944

Browse files
author
ppueyor
committed
Fixed naming conventions and minor bugs requested in the PR
1 parent cdcb916 commit bca2944

File tree

6 files changed

+35
-64
lines changed

6 files changed

+35
-64
lines changed

AirLib/include/api/RpcLibClientBase.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,18 @@ namespace airlib
114114
//CinemAirSim
115115
std::vector<std::string> simGetPresetLensSettings(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
116116
std::string simGetLensSettings(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
117-
void simSetPresetLensSettings(const std::string& preset_lens_settings = "", const std::string& camera_name = "", const std::string& vehicle_name = "", bool external = false);
117+
void simSetPresetLensSettings(const std::string& preset_lens_settings, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
118118
std::vector<std::string> simGetPresetFilmbackSettings(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
119-
void simSetPresetFilmbackSettings(const std::string& preset_filmback_settings = "", const std::string& camera_name = "", const std::string& vehicle_name = "", bool external = false);
119+
void simSetPresetFilmbackSettings(const std::string& preset_filmback_settings, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
120120
std::string simGetFilmbackSettings(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
121121
float simSetFilmbackSettings(const float sensor_width, const float sensor_heigth, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
122122
float simGetFocalLength(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
123-
void simSetFocalLength(float focal_length, const std::string& camera_name = "", const std::string& vehicle_name = "", bool external = false);
123+
void simSetFocalLength(float focal_length, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
124124
void simEnableManualFocus(const bool enable, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
125125
float simGetFocusDistance(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
126-
void simSetFocusDistance(float focus_distance, const std::string& camera_name = "", const std::string& vehicle_name = "", bool external = false);
126+
void simSetFocusDistance(float focus_distance, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
127127
float simGetFocusAperture(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
128-
void simSetFocusAperture(const float focus_aperture, const std::string& camera_name = "", const std::string& vehicle_name = "", bool external = false);
128+
void simSetFocusAperture(const float focus_aperture, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
129129
void simEnableFocusPlane(const bool enable, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
130130
std::string simGetCurrentFieldOfView(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
131131
//end CinemAirSim

AirLib/src/api/RpcLibClientBase.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -264,22 +264,13 @@ __pragma(warning(disable : 4239))
264264
vector<uint8_t> RpcLibClientBase::simGetImage(const std::string& camera_name, ImageCaptureBase::ImageType type, const std::string& vehicle_name, bool external)
265265
{
266266
vector<uint8_t> result = pimpl_->client.call("simGetImage", camera_name, type, vehicle_name, external).as<vector<uint8_t>>();
267-
if (result.size() == 1) {
268-
// rpclib has a bug with serializing empty vectors, so we return a 1 byte vector instead.
269-
result.clear();
270-
}
271267
return result;
272268
}
273269

274270
//CinemAirSim
275271
std::vector<std::string> RpcLibClientBase::simGetPresetLensSettings(const std::string& camera_name, const std::string& vehicle_name, bool external)
276272
{
277273
vector<std::string> result = pimpl_->client.call("simGetPresetLensSettings", camera_name, vehicle_name, external).as<vector<std::string>>();
278-
279-
if (result.size() == 1) {
280-
// rpclib has a bug with serializing empty vectors, so we return a 1 byte vector instead.
281-
result.clear();
282-
}
283274
return result;
284275
}
285276

@@ -297,11 +288,6 @@ __pragma(warning(disable : 4239))
297288
std::vector<std::string> RpcLibClientBase::simGetPresetFilmbackSettings(const std::string& camera_name, const std::string& vehicle_name, bool external)
298289
{
299290
vector<std::string> result = pimpl_->client.call("simGetPresetFilmbackSettings", camera_name, vehicle_name, external).as<vector<std::string>>();
300-
301-
if (result.size() == 1) {
302-
// rpclib has a bug with serializing empty vectors, so we return a 1 byte vector instead.
303-
result.clear();
304-
}
305291
return result;
306292
}
307293

AirLib/src/api/RpcLibServerBase.cpp

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -155,44 +155,32 @@ namespace airlib
155155

156156
//CinemAirSim
157157
pimpl_->server.bind("simGetPresetLensSettings", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> vector<string> {
158-
auto result = getWorldSimApi()->getPresetLensSettings(CameraDetails(camera_name, vehicle_name, external));
159-
if (result.size() == 0) {
160-
// rpclib has a bug with serializing empty vectors, so we return a 1 byte vector instead.
161-
result.push_back("");
162-
}
163-
return result;
158+
return getWorldSimApi()->getPresetLensSettings(CameraDetails(camera_name, vehicle_name, external));
164159
});
165160

166161
pimpl_->server.bind("simGetLensSettings", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> string {
167-
auto result = getWorldSimApi()->getLensSettings(CameraDetails(camera_name, vehicle_name, external));
168-
return result;
162+
return getWorldSimApi()->getLensSettings(CameraDetails(camera_name, vehicle_name, external));
169163
});
170164

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

175169
pimpl_->server.bind("simGetPresetFilmbackSettings", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> vector<string> {
176-
auto result = getWorldSimApi()->getPresetFilmbackSettings(CameraDetails(camera_name, vehicle_name, external));
177-
if (result.size() == 0) {
178-
// rpclib has a bug with serializing empty vectors, so we return a 1 byte vector instead.
179-
result.push_back("");
180-
}
181-
return result;
170+
return getWorldSimApi()->getPresetFilmbackSettings(CameraDetails(camera_name, vehicle_name, external));
182171
});
183172

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

188177
pimpl_->server.bind("simGetFilmbackSettings", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> string {
189-
auto result = getWorldSimApi()->getFilmbackSettings(CameraDetails(camera_name, vehicle_name, external));
190-
return result;
178+
return getWorldSimApi()->getFilmbackSettings(CameraDetails(camera_name, vehicle_name, external));
191179
});
192180

193181
pimpl_->server.bind("simSetFilmbackSettings", [&](const float width, const float heigth, const std::string& camera_name, const std::string& vehicle_name, bool external) -> float {
194-
auto result = getWorldSimApi()->setFilmbackSettings(width, heigth, CameraDetails(camera_name, vehicle_name, external));
195-
return result;
182+
return getWorldSimApi()->setFilmbackSettings(width, heigth, CameraDetails(camera_name, vehicle_name, external));
183+
;
196184
});
197185

198186
pimpl_->server.bind("simGetFocalLength", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> float {
@@ -228,8 +216,7 @@ namespace airlib
228216
});
229217

230218
pimpl_->server.bind("simGetCurrentFieldOfView", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> string {
231-
auto result = getWorldSimApi()->getCurrentFieldOfView(CameraDetails(camera_name, vehicle_name, external));
232-
return result;
219+
return getWorldSimApi()->getCurrentFieldOfView(CameraDetails(camera_name, vehicle_name, external));
233220
});
234221
//end CinemAirSim
235222

PythonClient/airsim/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, ip = "", port = 41451, timeout_value = 3600):
1616
ip = "127.0.0.1"
1717
self.client = msgpackrpc.Client(msgpackrpc.Address(ip, port), timeout = timeout_value, pack_encoding = 'utf-8', unpack_encoding = 'utf-8')
1818

19-
#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Common vehicle APIs -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
19+
#----------------------------------- Common vehicle APIs ---------------------------------------------
2020
def reset(self):
2121
"""
2222
Reset the vehicle to its original starting state
@@ -1041,7 +1041,7 @@ def getSettingsString(self):
10411041
"""
10421042
return self.client.call('getSettingsString')
10431043

1044-
#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Multirotor APIs -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
1044+
#----------------------------------- Multirotor APIs ---------------------------------------------
10451045
class MultirotorClient(VehicleClient, object):
10461046
def __init__(self, ip = "", port = 41451, timeout_value = 3600):
10471047
super(MultirotorClient, self).__init__(ip, port, timeout_value)
@@ -1501,7 +1501,7 @@ def getRotorStates(self, vehicle_name = ''):
15011501
return RotorStates.from_msgpack(self.client.call('getRotorStates', vehicle_name))
15021502
getRotorStates.__annotations__ = {'return': RotorStates}
15031503

1504-
#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Car APIs -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
1504+
#----------------------------------- Car APIs ---------------------------------------------
15051505
class CarClient(VehicleClient, object):
15061506
def __init__(self, ip = "", port = 41451, timeout_value = 3600):
15071507
super(CarClient, self).__init__(ip, port, timeout_value)

Unreal/Plugins/AirSim/Source/PIPCamera.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,13 @@ void APIPCamera::setupCameraFromSettings(const APIPCamera::CameraSetting& camera
373373
}
374374
setDistortionMaterial(image_type, captures_[image_type], captures_[image_type]->PostProcessSettings);
375375
setNoiseMaterial(image_type, captures_[image_type], captures_[image_type]->PostProcessSettings, noise_setting);
376-
CopyCameraSettingsToSceneCapture(camera_, captures_[image_type]); //CinemAirSim
376+
copyCameraSettingsToSceneCapture(camera_, captures_[image_type]); //CinemAirSim
377377
}
378378
else { //camera component
379379
updateCameraSetting(camera_, capture_setting, ned_transform);
380380
setDistortionMaterial(image_type, camera_, camera_->PostProcessSettings);
381381
setNoiseMaterial(image_type, camera_, camera_->PostProcessSettings, noise_setting);
382-
CopyCameraSettingsToAllSceneCapture(camera_); //CinemAirSim
382+
copyCameraSettingsToAllSceneCapture(camera_); //CinemAirSim
383383
}
384384
}
385385
}
@@ -607,7 +607,6 @@ std::vector<std::string> APIPCamera::getPresetLensSettings()
607607

608608
ss << "Name: " << name << ";\n\t MinFocalLength: " << preset.LensSettings.MinFocalLength << "; \t MaxFocalLength: " << preset.LensSettings.MaxFocalLength;
609609
ss << "\n\t Min FStop: " << preset.LensSettings.MinFStop << "; \t Max Fstop: " << preset.LensSettings.MaxFStop;
610-
//ss << "\n\t Diaphragm Blade Count: " << preset.LensSettings.DiaphragmBladeCount;
611610
std::string final_string(ss.str());
612611
vector.push_back(final_string);
613612
}
@@ -641,7 +640,7 @@ void APIPCamera::setPresetLensSettings(std::string preset_string)
641640
{
642641
FString preset(preset_string.c_str());
643642
camera_->SetLensPresetByName(preset);
644-
CopyCameraSettingsToAllSceneCapture(camera_);
643+
copyCameraSettingsToAllSceneCapture(camera_);
645644
}
646645

647646
std::vector<std::string> APIPCamera::getPresetFilmbackSettings()
@@ -664,7 +663,7 @@ void APIPCamera::setPresetFilmbackSettings(std::string preset_string)
664663
{
665664
FString preset(preset_string.c_str());
666665
camera_->SetFilmbackPresetByName(preset);
667-
CopyCameraSettingsToAllSceneCapture(camera_);
666+
copyCameraSettingsToAllSceneCapture(camera_);
668667
}
669668

670669
std::string APIPCamera::getFilmbackSettings()
@@ -686,7 +685,7 @@ float APIPCamera::setFilmbackSettings(float sensor_width, float sensor_height)
686685
camera_->Filmback.SensorWidth = sensor_width;
687686
camera_->Filmback.SensorHeight = sensor_height;
688687

689-
CopyCameraSettingsToAllSceneCapture(camera_);
688+
copyCameraSettingsToAllSceneCapture(camera_);
690689

691690
return camera_->Filmback.SensorAspectRatio;
692691
}
@@ -699,7 +698,7 @@ float APIPCamera::getFocalLength()
699698
void APIPCamera::setFocalLength(float focal_length)
700699
{
701700
camera_->CurrentFocalLength = focal_length;
702-
CopyCameraSettingsToAllSceneCapture(camera_);
701+
copyCameraSettingsToAllSceneCapture(camera_);
703702
}
704703

705704
void APIPCamera::enableManualFocus(bool enable)
@@ -710,7 +709,7 @@ void APIPCamera::enableManualFocus(bool enable)
710709
else {
711710
camera_->FocusSettings.FocusMethod = ECameraFocusMethod::Disable;
712711
}
713-
CopyCameraSettingsToAllSceneCapture(camera_);
712+
copyCameraSettingsToAllSceneCapture(camera_);
714713
}
715714

716715
float APIPCamera::getFocusDistance()
@@ -721,7 +720,7 @@ float APIPCamera::getFocusDistance()
721720
void APIPCamera::setFocusDistance(float focus_distance)
722721
{
723722
camera_->FocusSettings.ManualFocusDistance = focus_distance;
724-
CopyCameraSettingsToAllSceneCapture(camera_);
723+
copyCameraSettingsToAllSceneCapture(camera_);
725724
}
726725

727726
float APIPCamera::getFocusAperture()
@@ -732,7 +731,7 @@ float APIPCamera::getFocusAperture()
732731
void APIPCamera::setFocusAperture(float focus_aperture)
733732
{
734733
camera_->CurrentAperture = focus_aperture;
735-
CopyCameraSettingsToAllSceneCapture(camera_);
734+
copyCameraSettingsToAllSceneCapture(camera_);
736735
}
737736

738737
void APIPCamera::enableFocusPlane(bool enable)
@@ -747,26 +746,25 @@ std::string APIPCamera::getCurrentFieldOfView()
747746
return ss.str();
748747
}
749748

750-
void APIPCamera::CopyCameraSettingsToAllSceneCapture(UCameraComponent* camera)
749+
void APIPCamera::copyCameraSettingsToAllSceneCapture(UCameraComponent* camera)
751750
{
752751
int image_count = static_cast<int>(Utils::toNumeric(ImageType::Count));
753-
for (int image_type = image_count - 1; image_type >= 0; image_type--) {
754-
if (image_type >= 0) { //scene capture components
755-
CopyCameraSettingsToSceneCapture(camera_, captures_[image_type]);
756-
}
752+
for (image_type >= 0) {
753+
//scene capture components
754+
copyCameraSettingsToSceneCapture(camera_, captures_[image_type]);
757755
}
758756
}
759757

760-
void APIPCamera::CopyCameraSettingsToSceneCapture(UCameraComponent* src, USceneCaptureComponent2D* dst)
758+
void APIPCamera::copyCameraSettingsToSceneCapture(UCameraComponent* src, USceneCaptureComponent2D* dst)
761759
{
762760
if (src && dst) {
763761
dst->SetWorldLocationAndRotation(src->GetComponentLocation(), src->GetComponentRotation());
764762
dst->FOVAngle = src->FieldOfView;
765763

766-
FMinimalViewInfo CameraViewInfo;
767-
src->GetCameraView(/*DeltaTime =*/0.0f, CameraViewInfo);
764+
FMinimalViewInfo camera_view_info;
765+
src->GetCameraView(/*DeltaTime =*/0.0f, camera_view_info);
768766

769-
const FPostProcessSettings& SrcPPSettings = CameraViewInfo.PostProcessSettings;
767+
const FPostProcessSettings& SrcPPSettings = camera_view_info.PostProcessSettings;
770768
FPostProcessSettings& DstPPSettings = dst->PostProcessSettings;
771769

772770
FWeightedBlendables DstWeightedBlendables = DstPPSettings.WeightedBlendables;

Unreal/Plugins/AirSim/Source/PIPCamera.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class AIRSIM_API APIPCamera : public ACineCameraActor //CinemAirSim
5050
void setPresetFilmbackSettings(std::string preset_string);
5151
std::string getLensSettings();
5252
std::string getFilmbackSettings();
53-
float setFilmbackSettings(float sensor_width, float sensot_height);
53+
float setFilmbackSettings(float sensor_width, float sensor_height);
5454
float getFocalLength();
5555
void setFocalLength(float focal_length);
5656
void enableManualFocus(bool enable);
@@ -61,8 +61,8 @@ class AIRSIM_API APIPCamera : public ACineCameraActor //CinemAirSim
6161
void enableFocusPlane(bool enable);
6262
std::string getCurrentFieldOfView();
6363

64-
void CopyCameraSettingsToAllSceneCapture(UCameraComponent* camera);
65-
void CopyCameraSettingsToSceneCapture(UCameraComponent* src, USceneCaptureComponent2D* dst);
64+
void copyCameraSettingsToAllSceneCapture(UCameraComponent* camera);
65+
void copyCameraSettingsToSceneCapture(UCameraComponent* src, USceneCaptureComponent2D* dst);
6666
//end CinemAirSim methods
6767

6868
void setCameraTypeEnabled(ImageType type, bool enabled);

0 commit comments

Comments
 (0)