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

Adding option to transform map based on header timestamp #1066

Merged
merged 3 commits into from
Apr 29, 2017
Merged
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
15 changes: 14 additions & 1 deletion src/rviz/default_plugin/map_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ MapDisplay::MapDisplay()
"Prefer UDP topic transport",
this,
SLOT( updateTopic() ));

transform_timestamp_property_ = new BoolProperty( "Use Timestamp", false,
"Use map header timestamp when transforming",
this,
SLOT( transformMap() ));
}

MapDisplay::~MapDisplay()
Expand Down Expand Up @@ -702,9 +707,17 @@ void MapDisplay::transformMap()
return;
}

ros::Time transform_time;

if (transform_timestamp_property_->getBool())
{
transform_time = current_map_.header.stamp;
}

Ogre::Vector3 position;
Ogre::Quaternion orientation;
if (!context_->getFrameManager()->transform(frame_, ros::Time(), current_map_.info.origin, position, orientation))
if (!context_->getFrameManager()->transform(frame_, transform_time, current_map_.info.origin, position, orientation) &&
!context_->getFrameManager()->transform(frame_, ros::Time(0), current_map_.info.origin, position, orientation))
{
ROS_DEBUG( "Error transforming map '%s' from frame '%s' to frame '%s'",
qPrintable( getName() ), frame_.c_str(), qPrintable( fixed_frame_ ));
Expand Down
4 changes: 2 additions & 2 deletions src/rviz/default_plugin/map_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ protected Q_SLOTS:
void updatePalette();
/** @brief Show current_map_ in the scene. */
void showMap();
void transformMap();

protected:
// overrides from Display
Expand All @@ -114,8 +115,6 @@ protected Q_SLOTS:

void clear();

void transformMap();

Ogre::ManualObject* manual_object_;
Ogre::TexturePtr texture_;
std::vector<Ogre::TexturePtr> palette_textures_;
Expand Down Expand Up @@ -144,6 +143,7 @@ protected Q_SLOTS:
EnumProperty* color_scheme_property_;

BoolProperty* unreliable_property_;
BoolProperty* transform_timestamp_property_;
};

} // namespace rviz
Expand Down