void DataRateCheckerPlugin::load(const rviz::Config& config) { rviz::Panel::load(config); QString topic; int min_frequency; if(config.mapGetString ("Topic", &topic)) { // Extract selected topic name from combo box std::string selected_topic = topic.toStdString(); if (selected_topic != kBlankTopic.toStdString() && selected_topic != "") { UpdateTopicList(); int topic_index = ui_.topic_combo_box_->findText(topic); // If the load topic doesn't exist, load it anyway to wait for the topic to become active if (topic_index == -1) { QStringList dummy_topic_list; dummy_topic_list << topic; ui_.topic_combo_box_->addItems(dummy_topic_list); topic_index = ui_.topic_combo_box_->findText(topic); } ui_.topic_combo_box_->setCurrentIndex(topic_index); topic_sub_ = node_handle_.subscribe(selected_topic, 1, &DataRateCheckerPlugin::MessageCallback, this); timer_ = node_handle_.createWallTimer(ros::WallDuration(1.0), &DataRateCheckerPlugin::TimerCallback, this); } } if(config.mapGetInt ("Min rate", &min_frequency)) { ui_.min_frequency_spin_box_->setValue(min_frequency); } } // DataRateCheckerPlugin::load
// Loading and saving the flags // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // // Tools with a fixed set of Property objects representing adjustable // parameters are typically just created in the tool's constructor and // added to the Property container (getPropertyContainer()). In that // case, the Tool subclass does not need to override load() and save() // because the default behavior is to read all the Properties in the // container from the Config object. // // Here however, we have a list of named flag positions of unknown // length, so we need to implement save() and load() ourselves. // // We first save the class ID to the config object so the // rviz::ToolManager will know what to instantiate when the config // file is read back in. void FlagTool3D::save( rviz::Config config ) const { config.mapSetValue( "Class", getClassId() ); // The top level of this tool's Config is a map, but our flags // should go in a list, since they may or may not have unique keys. // Therefore we make a child of the map (``flags_config``) to store // the list. rviz::Config flags_config = config.mapMakeChild( "Flags" ); // To read the positions and names of the flags, we loop over the // the children of our Property container: rviz::Property* container = getPropertyContainer(); int num_children = container->numChildren(); for( int i = 0; i < num_children; i++ ) { rviz::Property* position_prop = container->childAt( i ); // For each Property, we create a new Config object representing a // single flag and append it to the Config list. rviz::Config flag_config = flags_config.listAppendNew(); // Into the flag's config we store its name: flag_config.mapSetValue( "Name", position_prop->getName() ); // ... and its position. position_prop->save( flag_config ); } }
void CancelAction::save( rviz::Config config ) const { rviz::Panel::save( config ); rviz::Config topic_list_config = config.mapMakeChild( "topics" ); std::vector<topicListLayout>::const_iterator it = topic_list_layouts_.begin(); while( it != topic_list_layouts_.end()){ topic_list_config.listAppendNew().setValue( it->topic_name_->text() ); it ++; } config.mapSetValue( "Topic", output_topic_ ); }
// In a tool's load() function, we don't need to read its class // because that has already been read and used to instantiate the // object before this can have been called. void FlagTool3D::load( const rviz::Config& config ) { // Here we get the "Flags" sub-config from the tool config and loop over its entries: rviz::Config flags_config = config.mapGetChild( "Flags" ); int num_flags = flags_config.listLength(); for( int i = 0; i < num_flags; i++ ) { rviz::Config flag_config = flags_config.listChildAt( i ); // At this point each ``flag_config`` represents a single flag. // // Here we provide a default name in case the name is not in the config file for some reason: QString name = "Flag " + QString::number( i + 1 ); // Then we use the convenience function mapGetString() to read the // name from ``flag_config`` if it is there. (If no "Name" entry // were present it would return false, but we don't care about // that because we have already set a default.) flag_config.mapGetString( "Name", &name ); // Given the name we can create an rviz::VectorProperty to display the position: rviz::VectorProperty* prop = new rviz::VectorProperty( name ); // Then we just tell the property to read its contents from the config, and we've read all the data. prop->load( flag_config ); // We finish each flag by marking it read-only (as discussed // above), adding it to the property container, and finally making // an actual visible flag object in the 3D scene at the correct // position. prop->setReadOnly( true ); getPropertyContainer()->addChild( prop ); makeFlag( prop->getVector() ); } }
void AddWayPoint::save(rviz::Config config) const { /// Allowing the user to save the current configuration of the panel ROS_INFO_STREAM("Saving configuration"); rviz::Panel::save(config); config.mapSetValue("TextEntry", QString::fromStdString(std::string("test_field"))); }
void TransformableMarkerOperatorAction::load( const rviz::Config& config ) { rviz::Panel::load( config ); QString server_name; config.mapGetString( "ServerName", &server_name ); server_name_editor_->setText(server_name); }
void TfVisualCalcPanel::load(const rviz::Config& p_config) { rviz::Panel::load(p_config); QString tfVisualCalcViewString; if (p_config.mapGetString("TfVisualCalcView", &tfVisualCalcViewString)) { m_calcView->fromYAMLString(tfVisualCalcViewString.toStdString()); } }
// Load all configuration data for this panel from the given Config object. void TeleopPanel::load( const rviz::Config& config ) { rviz::Panel::load( config ); QString topic; if( config.mapGetString( "Topic", &topic )) { output_topic_editor_->setText( topic ); updateTopic(); } }
// Load all configuration data for this panel from the given Config object. void CancelAction::load( const rviz::Config& config ) { rviz::Panel::load( config ); rviz::Config topic_list_config = config.mapGetChild( "topics" ); int num_topics = topic_list_config.listLength(); for( int i = 0; i < num_topics; i++ ) { addTopicList(topic_list_config.listChildAt( i ).getValue().toString().toStdString()); } }
void AddWayPoint::load(const rviz::Config& config) { /*! \brief Setting up the configurations for the Panel of the RViz enviroment. */ rviz::Panel::load(config); QString text_entry; ROS_INFO_STREAM("rviz: Initializing the user interaction planning panel"); if (config.mapGetString("TextEntry", &text_entry)) { ROS_INFO_STREAM("Loaded TextEntry with value: " << text_entry.toStdString()); } ROS_INFO_STREAM("rviz Initialization Finished reading config file"); }
// Save all configuration data from this panel to the given // Config object. It is important here that you call save() // on the parent class so the class id and panel name get saved. void TeleopPanel::save( rviz::Config config ) const { rviz::Panel::save( config ); config.mapSetValue( "Topic", output_topic_ ); }
void DataRateCheckerPlugin::save(rviz::Config config) const { rviz::Panel::save(config); config.mapSetValue("Topic", ui_.topic_combo_box_->currentText()); config.mapSetValue("Min rate", ui_.min_frequency_spin_box_->value()); } // DataRateCheckerPlugin::save
void TfVisualCalcPanel::save(rviz::Config p_config) const { rviz::Panel::save(p_config); p_config.mapSetValue("TfVisualCalcView", QString::fromStdString(m_calcView->toYAMLString())); }
void TransformableMarkerOperatorAction::save( rviz::Config config ) const { rviz::Panel::save( config ); config.mapSetValue( "ServerName", server_name_editor_->text().toStdString().c_str() ); }