Skip to content

Commit bb9922e

Browse files
authored
Merge pull request #3949 from ppueyor/master
Camera replaced by Cinematographic Camera (CinemAirSim)
2 parents 059997b + 390092d commit bb9922e

File tree

12 files changed

+749
-37
lines changed

12 files changed

+749
-37
lines changed

AirLib/include/api/RpcLibClientBase.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,24 @@ namespace airlib
114114
vector<ImageCaptureBase::ImageResponse> simGetImages(vector<ImageCaptureBase::ImageRequest> request, const std::string& vehicle_name = "", bool external = false);
115115
vector<uint8_t> simGetImage(const std::string& camera_name, ImageCaptureBase::ImageType type, const std::string& vehicle_name = "", bool external = false);
116116

117+
//CinemAirSim
118+
std::vector<std::string> simGetPresetLensSettings(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
119+
std::string simGetLensSettings(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
120+
void simSetPresetLensSettings(const std::string& preset_lens_settings, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
121+
std::vector<std::string> simGetPresetFilmbackSettings(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
122+
void simSetPresetFilmbackSettings(const std::string& preset_filmback_settings, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
123+
std::string simGetFilmbackSettings(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
124+
float simSetFilmbackSettings(const float sensor_width, const float sensor_heigth, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
125+
float simGetFocalLength(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
126+
void simSetFocalLength(float focal_length, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
127+
void simEnableManualFocus(const bool enable, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
128+
float simGetFocusDistance(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
129+
void simSetFocusDistance(float focus_distance, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
130+
float simGetFocusAperture(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
131+
void simSetFocusAperture(const float focus_aperture, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
132+
void simEnableFocusPlane(const bool enable, const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
133+
std::string simGetCurrentFieldOfView(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false);
134+
//end CinemAirSim
117135
bool simTestLineOfSightToPoint(const msr::airlib::GeoPoint& point, const std::string& vehicle_name = "");
118136
bool simTestLineOfSightBetweenPoints(const msr::airlib::GeoPoint& point1, const msr::airlib::GeoPoint& point2);
119137
vector<msr::airlib::GeoPoint> simGetWorldExtents();

AirLib/include/api/WorldSimApiBase.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,25 @@ namespace airlib
104104
const std::string& vehicle_name, bool external) const = 0;
105105
virtual std::vector<uint8_t> getImage(ImageCaptureBase::ImageType image_type, const CameraDetails& camera_details) const = 0;
106106

107+
//CinemAirSim
108+
virtual std::vector<std::string> getPresetLensSettings(const CameraDetails& camera_details) = 0;
109+
virtual std::string getLensSettings(const CameraDetails& camera_details) = 0;
110+
virtual void setPresetLensSettings(std::string, const CameraDetails& camera_details) = 0;
111+
virtual std::vector<std::string> getPresetFilmbackSettings(const CameraDetails& camera_details) = 0;
112+
virtual void setPresetFilmbackSettings(std::string, const CameraDetails& camera_details) = 0;
113+
virtual std::string getFilmbackSettings(const CameraDetails& camera_details) = 0;
114+
virtual float setFilmbackSettings(float width, float height, const CameraDetails& camera_details) = 0;
115+
virtual float getFocalLength(const CameraDetails& camera_details) = 0;
116+
virtual void setFocalLength(float focal_length, const CameraDetails& camera_details) = 0;
117+
virtual void enableManualFocus(bool enable, const CameraDetails& camera_details) = 0;
118+
virtual float getFocusDistance(const CameraDetails& camera_details) = 0;
119+
virtual void setFocusDistance(float focus_distance, const CameraDetails& camera_details) = 0;
120+
virtual float getFocusAperture(const CameraDetails& camera_details) = 0;
121+
virtual void setFocusAperture(float focus_aperture, const CameraDetails& camera_details) = 0;
122+
virtual void enableFocusPlane(bool enable, const CameraDetails& camera_details) = 0;
123+
virtual std::string getCurrentFieldOfView(const CameraDetails& camera_details) = 0;
124+
//end CinemAirSim
125+
107126
virtual void addDetectionFilterMeshName(ImageCaptureBase::ImageType image_type, const std::string& mesh_name, const CameraDetails& camera_details) = 0;
108127
virtual void setDetectionFilterRadius(ImageCaptureBase::ImageType image_type, float radius_cm, const CameraDetails& camera_details) = 0;
109128
virtual void clearDetectionMeshNames(ImageCaptureBase::ImageType image_type, const CameraDetails& camera_details) = 0;

AirLib/src/api/RpcLibClientBase.cpp

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,90 @@ __pragma(warning(disable : 4239))
269269
vector<uint8_t> RpcLibClientBase::simGetImage(const std::string& camera_name, ImageCaptureBase::ImageType type, const std::string& vehicle_name, bool external)
270270
{
271271
vector<uint8_t> result = pimpl_->client.call("simGetImage", camera_name, type, vehicle_name, external).as<vector<uint8_t>>();
272-
if (result.size() == 1) {
273-
// rpclib has a bug with serializing empty vectors, so we return a 1 byte vector instead.
274-
result.clear();
275-
}
276272
return result;
277273
}
278274

275+
//CinemAirSim
276+
std::vector<std::string> RpcLibClientBase::simGetPresetLensSettings(const std::string& camera_name, const std::string& vehicle_name, bool external)
277+
{
278+
return pimpl_->client.call("simGetPresetLensSettings", camera_name, vehicle_name, external).as<vector<std::string>>();
279+
}
280+
281+
std::string RpcLibClientBase::simGetLensSettings(const std::string& camera_name, const std::string& vehicle_name, bool external)
282+
{
283+
return pimpl_->client.call("simGetLensSettings", camera_name, vehicle_name, external).as<std::string>();
284+
}
285+
286+
void RpcLibClientBase::simSetPresetLensSettings(const std::string& preset_lens_settings, const std::string& camera_name, const std::string& vehicle_name, bool external)
287+
{
288+
pimpl_->client.call("simSetPresetLensSettings", preset_lens_settings, camera_name, vehicle_name, external);
289+
}
290+
291+
std::vector<std::string> RpcLibClientBase::simGetPresetFilmbackSettings(const std::string& camera_name, const std::string& vehicle_name, bool external)
292+
{
293+
return pimpl_->client.call("simGetPresetFilmbackSettings", camera_name, vehicle_name, external).as<vector<std::string>>();
294+
}
295+
296+
void RpcLibClientBase::simSetPresetFilmbackSettings(const std::string& preset_filmback_settings, const std::string& camera_name, const std::string& vehicle_name, bool external)
297+
{
298+
pimpl_->client.call("simSetPresetFilmbackSettings", preset_filmback_settings, camera_name, vehicle_name, external);
299+
}
300+
301+
std::string RpcLibClientBase::simGetFilmbackSettings(const std::string& camera_name, const std::string& vehicle_name, bool external)
302+
{
303+
return pimpl_->client.call("simGetFilmbackSettings", camera_name, vehicle_name, external).as<std::string>();
304+
}
305+
306+
float RpcLibClientBase::simSetFilmbackSettings(const float sensor_width, const float sensor_height, const std::string& camera_name, const std::string& vehicle_name, bool external)
307+
{
308+
return pimpl_->client.call("simSetFilmbackSettings", sensor_width, sensor_height, camera_name, vehicle_name, external).as<float>();
309+
}
310+
311+
float RpcLibClientBase::simGetFocalLength(const std::string& camera_name, const std::string& vehicle_name, bool external)
312+
{
313+
return pimpl_->client.call("simGetFocalLength", camera_name, vehicle_name, external).as<float>();
314+
}
315+
316+
void RpcLibClientBase::simSetFocalLength(const float focal_length, const std::string& camera_name, const std::string& vehicle_name, bool external)
317+
{
318+
pimpl_->client.call("simSetFocalLength", focal_length, camera_name, vehicle_name, external);
319+
}
320+
321+
void RpcLibClientBase::simEnableManualFocus(const bool enable, const std::string& camera_name, const std::string& vehicle_name, bool external)
322+
{
323+
pimpl_->client.call("simEnableManualFocus", enable, camera_name, vehicle_name, external);
324+
}
325+
326+
float RpcLibClientBase::simGetFocusDistance(const std::string& camera_name, const std::string& vehicle_name, bool external)
327+
{
328+
return pimpl_->client.call("simGetFocusDistance", camera_name, vehicle_name, external).as<float>();
329+
}
330+
void RpcLibClientBase::simSetFocusDistance(const float focus_distance, const std::string& camera_name, const std::string& vehicle_name, bool external)
331+
{
332+
pimpl_->client.call("simSetFocusDistance", focus_distance, camera_name, vehicle_name, external);
333+
}
334+
335+
float RpcLibClientBase::simGetFocusAperture(const std::string& camera_name, const std::string& vehicle_name, bool external)
336+
{
337+
return pimpl_->client.call("simGetFocusAperture", camera_name, vehicle_name, external).as<float>();
338+
}
339+
340+
void RpcLibClientBase::simSetFocusAperture(const float focus_aperture, const std::string& camera_name, const std::string& vehicle_name, bool external)
341+
{
342+
pimpl_->client.call("simSetFocusAperture", focus_aperture, camera_name, vehicle_name, external);
343+
}
344+
345+
void RpcLibClientBase::simEnableFocusPlane(const bool enable, const std::string& camera_name, const std::string& vehicle_name, bool external)
346+
{
347+
pimpl_->client.call("simEnableFocusPlane", enable, camera_name, vehicle_name, external);
348+
}
349+
350+
std::string RpcLibClientBase::simGetCurrentFieldOfView(const std::string& camera_name, const std::string& vehicle_name, bool external)
351+
{
352+
return pimpl_->client.call("simGetCurrentFieldOfView", camera_name, vehicle_name, external).as<std::string>();
353+
}
354+
//End CinemAirSim
355+
279356
// Minor TODO: consider msgpack magic for GeoPoint, so we can have one arg instead of three
280357
bool RpcLibClientBase::simTestLineOfSightToPoint(const msr::airlib::GeoPoint& point, const std::string& vehicle_name)
281358
{

AirLib/src/api/RpcLibServerBase.cpp

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,73 @@ namespace airlib
153153
return getWorldSimApi()->getImage(type, CameraDetails(camera_name, vehicle_name, external));
154154
});
155155

156+
//CinemAirSim
157+
pimpl_->server.bind("simGetPresetLensSettings", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> vector<string> {
158+
return getWorldSimApi()->getPresetLensSettings(CameraDetails(camera_name, vehicle_name, external));
159+
});
160+
161+
pimpl_->server.bind("simGetLensSettings", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> string {
162+
return getWorldSimApi()->getLensSettings(CameraDetails(camera_name, vehicle_name, external));
163+
});
164+
165+
pimpl_->server.bind("simSetPresetLensSettings", [&](const std::string preset_lens_settings, const std::string& camera_name, const std::string& vehicle_name, bool external) -> void {
166+
getWorldSimApi()->setPresetLensSettings(preset_lens_settings, CameraDetails(camera_name, vehicle_name, external));
167+
});
168+
169+
pimpl_->server.bind("simGetPresetFilmbackSettings", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> vector<string> {
170+
return getWorldSimApi()->getPresetFilmbackSettings(CameraDetails(camera_name, vehicle_name, external));
171+
});
172+
173+
pimpl_->server.bind("simSetPresetFilmbackSettings", [&](const std::string preset_filmback_settings, const std::string& camera_name, const std::string& vehicle_name, bool external) -> void {
174+
getWorldSimApi()->setPresetFilmbackSettings(preset_filmback_settings, CameraDetails(camera_name, vehicle_name, external));
175+
});
176+
177+
pimpl_->server.bind("simGetFilmbackSettings", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> string {
178+
return getWorldSimApi()->getFilmbackSettings(CameraDetails(camera_name, vehicle_name, external));
179+
});
180+
181+
pimpl_->server.bind("simSetFilmbackSettings", [&](const float width, const float heigth, const std::string& camera_name, const std::string& vehicle_name, bool external) -> float {
182+
return getWorldSimApi()->setFilmbackSettings(width, heigth, CameraDetails(camera_name, vehicle_name, external));
183+
;
184+
});
185+
186+
pimpl_->server.bind("simGetFocalLength", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> float {
187+
return getWorldSimApi()->getFocalLength(CameraDetails(camera_name, vehicle_name, external));
188+
});
189+
190+
pimpl_->server.bind("simSetFocalLength", [&](const float focal_lenght, const std::string& camera_name, const std::string& vehicle_name, bool external) -> void {
191+
getWorldSimApi()->setFocalLength(focal_lenght, CameraDetails(camera_name, vehicle_name, external));
192+
});
193+
194+
pimpl_->server.bind("simEnableManualFocus", [&](const bool enable, const std::string& camera_name, const std::string& vehicle_name, bool external) -> void {
195+
getWorldSimApi()->enableManualFocus(enable, CameraDetails(camera_name, vehicle_name, external));
196+
});
197+
198+
pimpl_->server.bind("simGetFocusDistance", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> float {
199+
return getWorldSimApi()->getFocusDistance(CameraDetails(camera_name, vehicle_name, external));
200+
});
201+
202+
pimpl_->server.bind("simSetFocusDistance", [&](const float focus_distance, const std::string& camera_name, const std::string& vehicle_name, bool external) -> void {
203+
getWorldSimApi()->setFocusDistance(focus_distance, CameraDetails(camera_name, vehicle_name, external));
204+
});
205+
206+
pimpl_->server.bind("simGetFocusAperture", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> float {
207+
return getWorldSimApi()->getFocusAperture(CameraDetails(camera_name, vehicle_name, external));
208+
});
209+
210+
pimpl_->server.bind("simSetFocusAperture", [&](const float focus_aperture, const std::string& camera_name, const std::string& vehicle_name, bool external) -> void {
211+
getWorldSimApi()->setFocusAperture(focus_aperture, CameraDetails(camera_name, vehicle_name, external));
212+
});
213+
214+
pimpl_->server.bind("simEnableFocusPlane", [&](const bool enable, const std::string& camera_name, const std::string& vehicle_name, bool external) -> void {
215+
getWorldSimApi()->enableFocusPlane(enable, CameraDetails(camera_name, vehicle_name, external));
216+
});
217+
218+
pimpl_->server.bind("simGetCurrentFieldOfView", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> string {
219+
return getWorldSimApi()->getCurrentFieldOfView(CameraDetails(camera_name, vehicle_name, external));
220+
});
221+
//end CinemAirSim
222+
156223
pimpl_->server.bind("simTestLineOfSightToPoint", [&](const RpcLibAdaptorsBase::GeoPoint& point, const std::string& vehicle_name) -> bool {
157224
return getVehicleSimApi(vehicle_name)->testLineOfSightToPoint(point.to());
158225
});

0 commit comments

Comments
 (0)