Skip to content

Commit

Permalink
Don't show map if transform is missing
Browse files Browse the repository at this point in the history
It's confusing when the map is shown but the transform is missing. This
leads to the map being on a wrong place.

Fixes #51
  • Loading branch information
AndreSchroeder-TomTom committed May 3, 2019
1 parent 4988723 commit 09084e3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog for package rviz_satellite

Forthcoming
-----------
* Don't show map if transform is missing
* Fix demo.launch

1.2.0 (2019-03-07)
Expand Down
2 changes: 1 addition & 1 deletion launch/demo.launch
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<node pkg="rostopic" type="rostopic" name="fake_gps_fix" args="pub /gps/fix sensor_msgs/NavSatFix --latch --file=$(find rviz_satellite)/launch/demo.gps" />

<!-- Start rviz with a pre-configured AerialMap instance. It will use the fake GPS fix from above. -->
<node pkg="rviz" type="rviz" name="rviz" args="-d $(find rviz_satellite)/launch/demo.rviz"/>
<node pkg="rviz" type="rviz" name="rviz" args="-d $(find rviz_satellite)/launch/demo.rviz" output="screen" />

<!-- Static fake TF transform -->
<node pkg="tf2_ros" type="static_transform_publisher" name="static_tf_fake" args="0 0 0 0 0 0 map base_link" />
Expand Down
14 changes: 13 additions & 1 deletion src/aerialmap_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ void AerialMapDisplay::navFixCallback(sensor_msgs::NavSatFixConstPtr const& msg)

// re-load imagery
received_msg_ = true;
loadImagery();
transformAerialMap();
loadImagery();
}

void AerialMapDisplay::loadImagery()
Expand All @@ -310,6 +310,11 @@ void AerialMapDisplay::loadImagery()
return;
}

if (!hasWorkingTransform_)
{
return;
}

if (tile_url_.empty())
{
setStatus(StatusProperty::Error, "Message", "Tile URL is not set");
Expand Down Expand Up @@ -507,6 +512,8 @@ void AerialMapDisplay::transformAerialMap()
{
context_->getFrameManager()->setFixedFrame(lastFixedFrame_);
setStatus(StatusProperty::Error, "Transform", QString::fromStdString(errMsg));
hasWorkingTransform_ = false;
clear();
return;
}

Expand All @@ -529,6 +536,8 @@ void AerialMapDisplay::transformAerialMap()
"Could not transform from [" + QString::fromStdString(frame) + "] to Fixed Frame [" + fixed_frame_ +
"] for an unknown reason");
}
hasWorkingTransform_ = false;
clear();
return;
}

Expand All @@ -537,9 +546,12 @@ void AerialMapDisplay::transformAerialMap()
// This can occur if an invalid TF is published.
// Show an error and don't apply anything, so OGRE does not throw an assertion.
setStatus(StatusProperty::Error, "Transform", "Received invalid transform");
hasWorkingTransform_ = false;
clear();
return;
}

hasWorkingTransform_ = true;
setStatus(StatusProperty::Ok, "Transform", "Transform OK");

// apply transform and add offset from origin
Expand Down
2 changes: 2 additions & 0 deletions src/aerialmap_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ protected Q_SLOTS:
boost::optional<TileId> lastTileId_;
std::string lastFixedFrame_;

bool hasWorkingTransform_ = false;

/**
* Calculate the tile width/ height in meter
*/
Expand Down

0 comments on commit 09084e3

Please sign in to comment.