Skip to content

Commit

Permalink
Adding option to transform map based on header timestamp (#1066)
Browse files Browse the repository at this point in the history
* Adding option to transform map based on header timestamp

* Adding map_display.h to PR

* Adding second attempt to transform if the attempt with the correct time stamp fails
  • Loading branch information
ayrton04 authored and wjwwood committed Apr 29, 2017
1 parent 54a1e95 commit 3cb7b0d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
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

0 comments on commit 3cb7b0d

Please sign in to comment.