コード例 #1
0
ファイル: flag_tool_3d.cpp プロジェクト: mario-gianni/ros
// 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() );
    }
}
コード例 #2
0
  // 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());
    }
  }