Skip to content

Commit

Permalink
WIP fixed sensor resolution in gazebo
Browse files Browse the repository at this point in the history
Since the zoom should be adjustable at runtime, the zoom factor
will need to be implemented in the image sampling routine,
it cannot be set beforehand in the bebop model.
  • Loading branch information
tomvand committed Jun 6, 2019
1 parent e51a711 commit 5ed817e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
8 changes: 4 additions & 4 deletions conf/simulator/gazebo/models/bebop/bebop.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,15 @@
<update_rate>15.0</update_rate><!-- adjust with MT9F002_TARGET_FPS -->
<camera>
<image>
<width>3746</width><!-- with MT9F002_ZOOM = 1.00, will be scaled by NPS --><!-- Reduced to 3 rad FoV for Gazebo 7 compatibility -->
<height>3288</height>
<width>4608</width><!-- Full sensor resolution -->
<height>3288</height><!-- Full sensor resolution -->
<format>R8G8B8</format>
</image>
<horizontal_fov>3.0</horizontal_fov>
<horizontal_fov>3.7</horizontal_fov>
<lens>
<type>equisolid_angle</type>
<scale_to_hfov>true</scale_to_hfov>
<cutoff_angle>3.0</cutoff_angle>
<cutoff_angle>1.8</cutoff_angle>
<env_texture_size>2048</env_texture_size><!-- with MT9F002_ZOOM = 1.00, will be scaled by NPS -->
</lens>
<clip>
Expand Down
10 changes: 0 additions & 10 deletions sw/simulator/nps/nps_fdm_gazebo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,6 @@ static void init_gazebo(void)
sdf::ElementPtr link = vehicle_sdf->Root()->GetFirstElement()->GetElement("link");
while (link) {
if (link->Get<string>("name") == "front_camera" && link->GetElement("sensor")->Get<string>("name") == "mt9f002") {
// In this section we only change the sensor resolution to emulate the
// ZOOM factor without having to implement/link an image scaling algorithm.
// The image cropping is performed in read_image.
// Rendering the entire sensor is more computationally expensive but
// ensures that the camera distortions remain correct.
int w = link->GetElement("sensor")->GetElement("camera")->GetElement("image")->GetElement("width")->Get<int>();
int h = link->GetElement("sensor")->GetElement("camera")->GetElement("image")->GetElement("height")->Get<int>();
link->GetElement("sensor")->GetElement("camera")->GetElement("image")->GetElement("width")->Set((int)(w * MT9F002_ZOOM));
link->GetElement("sensor")->GetElement("camera")->GetElement("image")->GetElement("height")->Set((int)(h * MT9F002_ZOOM));

if (MT9F002_TARGET_FPS){
int fps = Min(MT9F002_TARGET_FPS, link->GetElement("sensor")->GetElement("update_rate")->Get<int>());
link->GetElement("sensor")->GetElement("update_rate")->Set(fps);
Expand Down

0 comments on commit 5ed817e

Please sign in to comment.