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

Don't show map if transform is missing #52

Closed
wants to merge 1 commit 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
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