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

Fix for tf display not loading frame config #946

Merged
merged 1 commit into from
Dec 10, 2015
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
31 changes: 31 additions & 0 deletions src/rviz/default_plugin/tf_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,36 @@ TFDisplay::~TFDisplay()

void TFDisplay::onInitialize()
{
frame_config_enabled_state_.clear();

root_node_ = scene_node_->createChildSceneNode();

names_node_ = root_node_->createChildSceneNode();
arrows_node_ = root_node_->createChildSceneNode();
axes_node_ = root_node_->createChildSceneNode();
}

void TFDisplay::load(const Config& config)
{
Display::load(config);

// Load the enabled state for all frames specified in the config, and store
// the values in a map so that the enabled state can be properly set once
// the frame is created
Config c = config.mapGetChild("Frames");
for( Config::MapIterator iter = c.mapIterator(); iter.isValid(); iter.advance() )
{
QString key = iter.currentKey();
if( key != "All Enabled" )
{
const Config& child = iter.currentChild();
bool enabled = child.mapGetChild("Value").getValue().toBool();

frame_config_enabled_state_[key.toStdString()] = enabled;
}
}
}

void TFDisplay::clear()
{
// Clear the tree.
Expand All @@ -237,6 +260,7 @@ void TFDisplay::clear()
}

frames_.clear();
frame_config_enabled_state_.clear();

update_timer_ = 0.0f;

Expand Down Expand Up @@ -452,6 +476,13 @@ FrameInfo* TFDisplay::createFrame(const std::string& frame)
info->enabled_property_ );
info->rel_orientation_property_->setReadOnly( true );

// If the current frame was specified as disabled in the config file
// then its enabled state must be updated accordingly
if( frame_config_enabled_state_.count(frame) > 0 && !frame_config_enabled_state_[frame] )
{
info->enabled_property_->setBool(false);
}

updateFrame( info );

return info;
Expand Down
4 changes: 4 additions & 0 deletions src/rviz/default_plugin/tf_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Q_OBJECT
protected:
// Overrides from Display
virtual void onInitialize();
virtual void load(const Config& config);
virtual void fixedFrameChanged();
virtual void reset();

Expand Down Expand Up @@ -104,6 +105,9 @@ private Q_SLOTS:
typedef std::map<std::string, FrameInfo*> M_FrameInfo;
M_FrameInfo frames_;

typedef std::map<std::string, bool> M_EnabledState;
M_EnabledState frame_config_enabled_state_;

float update_timer_;

BoolProperty* show_names_property_;
Expand Down