Esempio n. 1
0
void GetTaskInfoFromXML(BSTR xml, CStringW &app_name, CStringW &param)
{
	CStringW xml_str(xml);

	int pos = xml_str.Find(L"<Command>");
	if (pos == -1) {
		return;
	}

	int info_start = pos + 9;
	pos = xml_str.Find(L"</Command>", info_start);
	if (pos == -1) {
		return;
	}

	int info_length = pos - info_start;
	app_name.SetString(xml_str.GetString() + info_start, info_length);


	pos = xml_str.Find(L"<Arguments>");
	if (pos == -1) {
		return;
	}

	info_start = pos + 11;
	pos = xml_str.Find(L"</Arguments>", info_start);
	if (pos == -1) {
		return;
	}

	info_length = pos - info_start;
	param.SetString(xml_str.GetString() + info_start, info_length);
}
Esempio n. 2
0
osg::ref_ptr<osg::Node> RobotModel::load(QString path){

    loadEmptyScene();

    std::ifstream t( path.toStdString().c_str() );
    std::string xml_str((std::istreambuf_iterator<char>(t)),
	                     std::istreambuf_iterator<char>());
    //Parse urdf
    boost::shared_ptr<urdf::ModelInterface> model = urdf::parseURDF( xml_str );
    rootPrefix = QDir(QFileInfo(path).absoluteDir());
    if (!model)
        return NULL;

    // Create map of mimic joints
    std::map<std::string, boost::shared_ptr<urdf::Joint> >::const_iterator it;
    for( it = model->joints_.begin(); it!=model->joints_.end(); ++it ) {
        boost::shared_ptr<urdf::Joint> joint = it->second;

        if(joint->type != urdf::Joint::FIXED){
            if(joint->mimic)
            {
                mimic_joints_[ it->first ] = MimicJoint( joint->mimic->joint_name,
                    joint->mimic->multiplier, joint->mimic->offset );
            }
        }
    }

    return makeOsg(model);
}
Esempio n. 3
0
boost::property_tree::ptree
readXml(const char xml[])
{
    boost::property_tree::ptree ptree;
    std::istringstream xml_str(xml);
    boost::property_tree::read_xml(
        xml_str, ptree,
        boost::property_tree::xml_parser::no_comments |
        boost::property_tree::xml_parser::trim_whitespace);
    return ptree;
}
Esempio n. 4
0
ModelInterfaceSharedPtr  parseURDFFile(const std::string &path)
{
    std::ifstream stream( path.c_str() );
    if (!stream)
    {
      CONSOLE_BRIDGE_logError(("File " + path + " does not exist").c_str());
      return ModelInterfaceSharedPtr();
    }

    std::string xml_str((std::istreambuf_iterator<char>(stream)),
	                     std::istreambuf_iterator<char>());
    return urdf::parseURDF( xml_str );
}
Esempio n. 5
0
boost::shared_ptr<ModelInterface>  parseURDFFile(const std::string &path)
{
    std::ifstream stream( path.c_str() );
    if (!stream)
    {
      logError(("File " + path + " does not exist").c_str());
      return boost::shared_ptr<ModelInterface>();
    }

    std::string xml_str((std::istreambuf_iterator<char>(stream)),
	                     std::istreambuf_iterator<char>());
    return urdf::parseURDF( xml_str );
}
Esempio n. 6
0
bool XmlHelper::LoadXmlFile()
{
    doc_.clear();
    QFile file(file_name_);
    if (!file.open(QIODevice::ReadWrite))
    {
        file.close();
        return false;
    }

    QTextStream out(&file);
    QString xml_str(out.readAll());
    if (!doc_.setContent(xml_str))
    {
        file.close();
        return false;
    }
    file.close();

    return true;
}
bool NoiseCovariancePlottingGadget::loadNoiseCovariance()
{
    std::ifstream infile;
    infile.open(full_name_stored_noise_dependency_.c_str(), std::ios::in | std::ios::binary);

    if (infile.good())
    {
        //Read the XML header of the noise scan
        uint32_t xml_length;
        infile.read(reinterpret_cast<char*>(&xml_length), 4);
        std::string xml_str(xml_length, '\0');
        infile.read(const_cast<char*>(xml_str.c_str()), xml_length);
        ISMRMRD::deserialize(xml_str.c_str(), noise_ismrmrd_header_);

        infile.read(reinterpret_cast<char*>(&noise_dwell_time_us_), sizeof(float));

        size_t len;
        infile.read(reinterpret_cast<char*>(&len), sizeof(size_t));

        char* buf = new char[len];
        if (buf == NULL) return false;

        infile.read(buf, len);

        if (!noise_covariance_matrixf_.deserialize(buf, len))
        {
            delete[] buf;
            return false;
        }

        delete[] buf;
        infile.close();
    }
    else
    {
        return false;
    }

    return true;
}