本文整理汇总了C++中yarp::os::ConstString类的典型用法代码示例。如果您正苦于以下问题:C++ ConstString类的具体用法?C++ ConstString怎么用?C++ ConstString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConstString类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: recursiveDiff
int recursiveDiff(yarp::os::ConstString srcDirName, yarp::os::ConstString destDirName, std::ostream &output)
{
std::set<std::string> srcFileList;
bool ok = recursiveFileList(srcDirName.c_str(), "", srcFileList);
std::set<std::string> destFileList;
ok=ok && recursiveFileList(destDirName.c_str(), "", destFileList);
if (!ok)
return -1;
size_t nModifiedFiles=0;
for(std::set<std::string>::iterator srcIt=srcFileList.begin(); srcIt !=srcFileList.end(); ++srcIt)
{
std::set<std::string>::iterator destPos=destFileList.find(*srcIt);
if (destPos!=destFileList.end())
{
diff_match_patch<std::string> dmp;
ConstString srcFileName=srcDirName+ PATH_SEPARATOR + (*srcIt);
if (isHidden(srcFileName))
continue;
std::ifstream in(srcFileName.c_str());
std::string srcStr((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
in.close();
in.open((destDirName+ PATH_SEPARATOR +(*destPos)).c_str());
std::string destStr((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
std::string patchString = dmp.patch_toText(dmp.patch_make(srcStr, destStr));
if (patchString!= "")
{
output << "- " << srcDirName + PATH_SEPARATOR + (*srcIt)<<endl;
output << "+ " << destDirName + PATH_SEPARATOR + (*destPos) <<endl;
output << dmp.patch_toText(dmp.patch_make(srcStr, destStr))<<std::endl;
nModifiedFiles++;
}
destFileList.erase(destPos);
}
// else
// {
// output << "Added file " << srcDirName+PATH_SEPARATOR +(*srcIt) <<endl;
// nModifiedFiles++;
// }
}
// for(std::set<std::string>::iterator destIt=destFileList.begin(); destIt !=destFileList.end(); ++destIt)
// {
// ConstString destFileName=destDirName+ PATH_SEPARATOR + (*destIt);
// if(isHidden(destFileName))
// continue;
//
// output << "Removed file " << destFileName <<endl;
// nModifiedFiles++;
//
// }
return nModifiedFiles;//tbm
}
开发者ID:SibghatullahSheikh,项目名称:yarp,代码行数:55,代码来源:yarpcontextutils.cpp
示例2: findFileBase
void findFileBase(Property& config, const char *name,
bool isDir,
Bottle& output, bool justTop) {
ConstString cap =
config.check("capability_directory",Value("app")).asString();
Bottle defCaps =
config.findGroup("default_capability").tail();
// check current directory
if (ConstString(name)==""&&isDir) {
output.addString(getPwd());
if (justTop) return;
}
ConstString str = check(getPwd(),"","",name,isDir);
if (str!="") {
output.addString(str);
if (justTop) return;
}
if (configFilePath!="") {
ConstString str = check(configFilePath.c_str(),"","",name,isDir);
if (str!="") {
output.addString(str);
if (justTop) return;
}
}
// check app dirs
for (int i=0; i<apps.size(); i++) {
str = check(root.c_str(),cap,apps.get(i).asString().c_str(),
name,isDir);
if (str!="") {
output.addString(str);
if (justTop) return;
}
}
// check ROOT/app/default/
for (int i=0; i<defCaps.size(); i++) {
str = check(root.c_str(),cap,defCaps.get(i).asString().c_str(),
name,isDir);
if (str!="") {
output.addString(str);
if (justTop) return;
}
}
if (justTop) {
if (!quiet) {
fprintf(RTARGET,"||| did not find %s\n", name);
}
}
}
开发者ID:johnty,项目名称:libYARP_OS,代码行数:54,代码来源:ResourceFinder.cpp
示例3: recursiveMerge
int recursiveMerge(yarp::os::ConstString srcDirName, yarp::os::ConstString destDirName, yarp::os::ConstString commonParentName, std::ostream &output)
{
std::set<std::string> srcFileList;
bool ok = recursiveFileList(srcDirName.c_str(), "", srcFileList);
std::set<std::string> destFileList;
ok=ok && recursiveFileList(destDirName.c_str(), "", destFileList);
std::set<std::string> hiddenFilesList;
ok=ok && recursiveFileList(commonParentName.c_str(), "", hiddenFilesList);
if (!ok)
return -1;
for(std::set<std::string>::iterator srcIt=srcFileList.begin(); srcIt !=srcFileList.end(); ++srcIt)
{
ConstString srcFileName=srcDirName+ PATH_SEPARATOR + (*srcIt);
if (isHidden(srcFileName))
continue;
std::set<std::string>::iterator destPos=destFileList.find(*srcIt);
if (destPos!=destFileList.end())
{
ConstString destFileName=destDirName+ PATH_SEPARATOR + (*destPos);
std::set<std::string>::iterator hiddenDestPos=hiddenFilesList.find(*srcIt);
if (hiddenDestPos!=hiddenFilesList.end())
{
ConstString hiddenFileName=commonParentName+ PATH_SEPARATOR + (*hiddenDestPos);
fileMerge(srcFileName, destFileName, hiddenFileName);
}
else
{
printf("Could not merge automatically, use mergetool\n");
}
destFileList.erase(destPos);
}
// else
// {
// std::set<std::string>::iterator hiddenDestPos=hiddenFilesList.find(*srcIt);
// if (hiddenDestPos==hiddenFilesList.end())
// {
// output << "File " << srcDirName+PATH_SEPARATOR +(*srcIt) << " has been added to the original context" << endl;
// }
// }
}
// for(std::set<std::string>::iterator destIt=destFileList.begin(); destIt !=destFileList.end(); ++destIt)
// {
// std::set<std::string>::iterator hiddenDestPos=hiddenFilesList.find(*destIt);
// if (hiddenDestPos==hiddenFilesList.end())
// output << "File " << destDirName+PATH_SEPARATOR +(*destIt) << " does not belong to the original context" << endl;
// }
return (ok? 0: 1);//tbm
}
开发者ID:SibghatullahSheikh,项目名称:yarp,代码行数:53,代码来源:yarpcontextutils.cpp
示例4: yError
bool yarp::dev::LocationsServer::save_locations(yarp::os::ConstString locations_file)
{
std::ofstream file;
file.open (locations_file.c_str());
if(!file.is_open())
{
yError() << "sorry unable to open" << locations_file << "locations file";
return false;
}
std::string s;
Map2DLocation l;
s = " ";
std::map<std::string, Map2DLocation>::iterator it;
for (it = m_locations.begin(); it != m_locations.end(); it++)
{
l = it->second;
file << it->first + s + l.map_id + s << l.x << s << l.y << s << l.theta << "\n";
}
file.close();
return true;
}
开发者ID:apaikan,项目名称:yarp,代码行数:25,代码来源:LocationsServer.cpp
示例5: iss
bool yarp::dev::LocationsServer::load_locations(yarp::os::ConstString locations_file)
{
std::ifstream file;
file.open (locations_file.c_str());
if(!file.is_open())
{
yError() << "sorry unable to open" << locations_file << "locations file";
return false;
}
std::string buffer, name, mapId, xpos, ypos, theta;
Map2DLocation location;
while(!file.eof())
{
std::getline(file, buffer);
std::istringstream iss(buffer);
iss >> name >> mapId >> xpos >> ypos >> theta;
location.map_id = mapId;
location.x = std::atof(xpos.c_str());
location.y = std::atof(ypos.c_str());
location.theta = std::atof(theta.c_str());
m_locations[name] = location;
}
yDebug() << "there are now" << m_locations.size() << "locations";
file.close();
return true;
}
开发者ID:apaikan,项目名称:yarp,代码行数:32,代码来源:LocationsServer.cpp
示例6: verifyMode
void OpenLoopConsistency::verifyMode(int desired_control_mode, yarp::dev::InteractionModeEnum desired_interaction_mode, yarp::os::ConstString title)
{
int cmode;
yarp::dev::InteractionModeEnum imode;
int timeout = 0;
while (1)
{
int ok=0;
for (int i=0; i<n_cmd_joints; i++)
{
icmd->getControlMode (jointsList[i],&cmode);
iimd->getInteractionMode(jointsList[i],&imode);
if (cmode==desired_control_mode && imode==desired_interaction_mode) ok++;
}
if (ok==n_cmd_joints) break;
if (timeout>100)
{
char sbuf[500];
sprintf(sbuf,"Test (%s) failed: current mode is (%d,%d), it should be (%d,%d)",title.c_str(), desired_control_mode,desired_interaction_mode,cmode,imode);
RTF_ASSERT_ERROR(sbuf);
}
yarp::os::Time::delay(0.2);
timeout++;
}
char sbuf[500];
sprintf(sbuf,"Test (%s) passed: current mode is (%d,%d)",title.c_str(), desired_control_mode,desired_interaction_mode);
RTF_TEST_REPORT(sbuf);
}
开发者ID:Karma-Revolutions,项目名称:icub-tests,代码行数:29,代码来源:OpenloopConsistency.cpp
示例7: checkRequiredParamIsVectorOfString
// \todo TODO bug ?
bool checkRequiredParamIsVectorOfString(yarp::os::Searchable& config,
const yarp::os::ConstString& paramName,
std::vector<std::string> & output_vector)
{
bool correct = !(config.findGroup(paramName).isNull());
if( correct )
correct = true;
{
Bottle ids = config.findGroup(paramName).tail();
std::cout << "ids : " << ids.toString() << std::endl;
std::cout << "ids : " << config.find(paramName).toString() << std::endl;
output_vector.resize(ids.size());
for(int i = 0; i < ids.size(); i++ )
{
output_vector[i] = ids.get(i).asString().c_str();
}
}
if( !correct )
{
yError("CanBusInertialMTB: problem loading parameter %s as vector of string",paramName.c_str());
}
return correct;
}
开发者ID:Karma-Revolutions,项目名称:icub-main,代码行数:26,代码来源:CanBusInertialMTB.cpp
示例8: quoteFree
static yarp::os::ConstString quoteFree(const yarp::os::ConstString &src) {
yarp::os::ConstString result = "";
for (unsigned int i=0; i<src.length(); i++) {
char ch = src[i];
if (ch=='"') {
result += """;
} else {
result += ch;
}
}
return result;
}
开发者ID:giuliavezzani,项目名称:yarp,代码行数:12,代码来源:HttpCarrier.cpp
示例9: fileMerge
int fileMerge(yarp::os::ConstString srcFileName, yarp::os::ConstString destFileName, yarp::os::ConstString commonParentName)
{
diff_match_patch<std::string> dmp;
std::ifstream in(srcFileName.c_str());
std::string srcStr((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
in.close();
in.open(destFileName.c_str());
std::string destStr((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
in.close();
in.open(commonParentName.c_str());
std::string hiddenDestStr((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
in.close();
diff_match_patch<string>::Patches patches = dmp.patch_make(hiddenDestStr, destStr);
std::pair<std::string, std::vector<bool> > mergeResults = dmp.patch_apply(patches, srcStr);
std::ofstream out(destFileName.c_str());
out << mergeResults.first;
out.close();
//update hidden file from installed one
out.open(commonParentName.c_str());
out << srcStr;
out.close();
return 0;
}
开发者ID:SibghatullahSheikh,项目名称:yarp,代码行数:23,代码来源:yarpcontextutils.cpp
示例10: checkRequiredParamIsInt
bool checkRequiredParamIsInt(yarp::os::Searchable& config,
const yarp::os::ConstString& paramName)
{
bool correct = config.check(paramName);
if( correct )
{
correct = config.find(paramName).isInt();
}
if( !correct )
{
yError("CanBusInertialMTB: problem loading parameter %s as int",paramName.c_str());
}
return correct;
}
开发者ID:Karma-Revolutions,项目名称:icub-main,代码行数:16,代码来源:CanBusInertialMTB.cpp
示例11: checkRequiredParamIsVectorOfInt
bool checkRequiredParamIsVectorOfInt(yarp::os::Searchable& config,
const yarp::os::ConstString& paramName,
std::vector<int> & output_vector)
{
bool correct = !(config.findGroup(paramName).isNull());
if( correct )
{
Bottle ids = config.findGroup(paramName).tail();
output_vector.resize(ids.size());
for(int i = 0; i < ids.size(); i++ )
{
output_vector[i] = ids.get(i).asInt();
}
}
if( !correct )
{
yError("CanBusInertialMTB: problem loading parameter %s as vector of int",paramName.c_str());
}
return correct;
}
开发者ID:Karma-Revolutions,项目名称:icub-main,代码行数:22,代码来源:CanBusInertialMTB.cpp
示例12: fileCopy
bool fileCopy(yarp::os::ConstString srcFileName, yarp::os::ConstString destFileName, bool force, bool verbose)
{
char buf[BUFSIZ];
size_t size;
FILE* source = fopen(srcFileName.c_str(), "rb");
if (source == NULL)
{
if (verbose)
printf("Could not open source file %s\n", srcFileName.c_str());
return false;
}
if (!yarp::os::stat(destFileName.c_str()))
{
if (force)
{
fileRemove(destFileName);
}
else
{
if (verbose)
printf("File already exists : %s\n",destFileName.c_str());
fclose(source);
return false;
}
}
FILE* dest = fopen(destFileName.c_str(), "wb");
if(dest ==NULL)
{
if (verbose)
printf("Could not open target file %s\n",destFileName.c_str());
fclose(source);
return false;
}
// clean and more secure
// feof(FILE* stream) returns non-zero if the end of file indicator for stream is set
while ((size = fread(buf, 1, BUFSIZ, source)))
{
fwrite(buf, 1, size, dest);
}
fclose(source);
fclose(dest);
return true;
}
开发者ID:SibghatullahSheikh,项目名称:yarp,代码行数:45,代码来源:yarpcontextutils.cpp
示例13: query
Contact NameServiceOnTriples::query(const yarp::os::ConstString& portName,
NameTripleState& act,
const yarp::os::ConstString& prefix,
bool nested) {
if (!nested) lock();
Triple t;
t.setNameValue("port",portName.c_str());
int result = act.mem.find(t, YARP_NULLPTR);
TripleContext context;
context.setRid(result);
if (result!=-1) {
ConstString host = "";
if (ConstString(prefix)!="") {
printf("LOOKING AT IPS FOR %s\n", prefix.c_str());
t.setNameValue("ips","*");
list<Triple> lst = act.mem.query(t,&context);
for (list<Triple>::iterator it=lst.begin();it!=lst.end();it++) {
printf("LOOKING AT IPS %s\n", it->value.c_str());
if (it->value.find(prefix)==0) {
host = it->value;
break;
}
}
}
if (host=="") {
t.setNameValue("host","*");
list<Triple> lst = act.mem.query(t,&context);
if (lst.size()>0) {
host = lst.begin()->value.c_str();
}
}
if (host=="") {
host = "localhost";
}
t.setNameValue("socket","*");
list<Triple> lst = act.mem.query(t,&context);
int sock = 10000;
if (lst.size()>0) {
sock = atoi(lst.begin()->value.c_str());
}
t.setNameValue("carrier","*");
ConstString carrier = "tcp";
lst = act.mem.query(t,&context);
if (lst.size()>0) {
carrier = lst.begin()->value.c_str();
}
t.setNameValue("type","*");
ConstString typ = "*";
lst = act.mem.query(t,&context);
if (lst.size()>0) {
typ = lst.begin()->value.c_str();
}
if (!nested) unlock();
Contact result = Contact(portName, carrier, host, sock);
if (typ!="" && typ!="*") {
NestedContact nc;
nc.fromString(result.getName());
nc.setTypeName(typ);
result.setNestedContact(nc);
}
return result;
}
if (!nested) unlock();
if (delegate && !nested) {
return delegate->queryName(portName);
}
return Contact();
}
开发者ID:apaikan,项目名称:yarp,代码行数:68,代码来源:NameServiceOnTriples.cpp
示例14: verifyOutputDiff
void OpenLoopConsistency::verifyOutputDiff(double verify_val, yarp::os::ConstString title)
{
double value;
char sbuf[500];
if (cmd_mode==single_joint)
{
for (int i=0; i<n_cmd_joints; i++)
{
iopl->getOutput(jointsList[i],&value);
if (value!=verify_val)
{
sprintf(sbuf,"Test (%s) passed j%d, current output is (%f!=%f)",title.c_str(),i,value,verify_val);
RTF_TEST_REPORT(sbuf);
}
else
{
sprintf(sbuf,"Test (%s) failed: current output is (%f), it should be (%f)",title.c_str(), value, verify_val);
RTF_ASSERT_ERROR(sbuf);
}
}
}
else if (cmd_mode==some_joints)
{
//same of single_joint, since multiple joint is not currently supported
for (int i=0; i<n_cmd_joints; i++)
{
iopl->getOutput(jointsList[i],&value);
if (value!=verify_val)
{
sprintf(sbuf,"Test (%s) passed j%d current output is (%f!=%f)",title.c_str(), i,value,verify_val);
RTF_TEST_REPORT(sbuf);
}
else
{
sprintf(sbuf,"Test (%s) failed: current output is (%f), it should be (%f)",title.c_str(), value, verify_val);
RTF_ASSERT_ERROR(sbuf);
}
}
}
else if (cmd_mode==all_joints)
{
int ok=0;
iopl->getOutputs(cmd_tot);
for (int i=0; i<n_part_joints; i++)
{
if (verify_val!=cmd_tot[i]) ok++;
}
if (ok==n_part_joints)
{
sprintf(sbuf,"Test (%s) passed current output is (%f!=%f)",title.c_str(),value,verify_val);
RTF_TEST_REPORT(sbuf);
}
else
{
sprintf(sbuf,"Test (%s) failed: only %d joints (of %d) are ok",title.c_str(),ok,n_part_joints);
RTF_ASSERT_ERROR(sbuf);
}
}
else
{
RTF_ASSERT_ERROR("Invalid cmd_mode");
}
yarp::os::Time::delay(0.010);
}
开发者ID:Karma-Revolutions,项目名称:icub-tests,代码行数:64,代码来源:OpenloopConsistency.cpp
示例15: setRemoteVariable
bool GazeboYarpControlBoardDriver::setRemoteVariable(yarp::os::ConstString key, const yarp::os::Bottle& val)
{
std::string s1 = val.toString();
yarp::os::Bottle* bval = val.get(0).asList();
if (bval == 0)
{
yWarning("setRemoteVariable(): Protocol error %s", s1.c_str());
return false;
}
std::string s2 = bval->toString();
if (key == "hardwareDamping")
{
for (size_t i = 0; i < m_numberOfJoints; i++)
{
double value = bval->get(i).asDouble();
m_jointPointers[i]->SetDamping(0,value);
}
return true;
}
if (key == "hardwareFriction")
{
for (size_t i = 0; i < m_numberOfJoints; i++)
{
double value = bval->get(i).asDouble();
m_jointPointers[i]->SetParam("friction",0,value);
}
return true;
}
if (key == "hardwareEffortLimit")
{
for (size_t i = 0; i < m_numberOfJoints; i++)
{
double value = bval->get(i).asDouble();
m_jointPointers[i]->SetEffortLimit(0,value);
}
return true;
}
if (key == "hardwareVelocityLimit")
{
for (size_t i = 0; i < m_numberOfJoints; i++)
{
double value = bval->get(i).asDouble();
m_jointPointers[i]->SetVelocityLimit(0,value);
}
return true;
}
if (key == "hardwareHiStop")
{
for (size_t i = 0; i < m_numberOfJoints; i++)
{
double value = bval->get(i).asDouble();
m_jointPointers[i]->SetUpperLimit(0,convertUserToGazebo(i,value));
}
return true;
}
if (key == "hardwareLowStop")
{
for (size_t i = 0; i < m_numberOfJoints; i++)
{
double value = bval->get(i).asDouble();
m_jointPointers[i]->SetLowerLimit(0,convertUserToGazebo(i,value));
}
return true;
}
if (key == "yarp_jntMaxVel")
{
for (size_t i = 0; i < m_numberOfJoints; i++)
{
double value = bval->get(i).asDouble();
setVelLimits(i,0,value);
}
return true;
}
if (key == "yarp_jntMaxPos")
{
for (size_t i = 0; i < m_numberOfJoints; i++)
{
double value = bval->get(i).asDouble();
double t_max=0, t_min=0;
getLimits(i,&t_min,&t_max);
setLimits(i,t_min,value);
}
return true;
}
if (key == "yarp_jntMinPos")
{
for (size_t i = 0; i < m_numberOfJoints; i++)
{
double value = bval->get(i).asDouble();
double t_max=0, t_min=0;
getLimits(i,&t_min,&t_max);
setLimits(i,value,t_max);
}
return true;
}
if (key == "yarp_kPWM")
{
for (size_t i = 0; i < m_numberOfJoints; i++)
//.........这里部分代码省略.........
开发者ID:nunoguedelha,项目名称:gazebo-yarp-plugins,代码行数:101,代码来源:ControlBoardDriverRemoteVariables.cpp
示例16: writeBinary
bool WireWriter::writeBinary(const yarp::os::ConstString& tag) {
writer.appendInt(BOTTLE_TAG_BLOB);
writer.appendInt((int)tag.length());
writer.appendBlock(tag.c_str(),tag.length());
return !writer.isError();
}
开发者ID:apaikan,项目名称:yarp,代码行数:6,代码来源:WireWriter.cpp
示例17: getRemoteVariable
bool GazeboYarpControlBoardDriver::getRemoteVariable(yarp::os::ConstString key, yarp::os::Bottle& val)
{
val.clear();
if (key == "hardwareDamping")
{
yarp::os::Bottle& r = val.addList(); for (size_t i = 0; i< m_numberOfJoints; i++) { double tmp = m_jointPointers[i]->GetDamping(0); r.addDouble(tmp); }
return true;
}
if (key == "hardwareFriction")
{
yarp::os::Bottle& r = val.addList(); for (size_t i = 0; i< m_numberOfJoints; i++) { double tmp = m_jointPointers[i]->GetParam(std::string("friction"),0); r.addDouble(tmp); }
return true;
}
if (key == "hardwareHiStop")
{
yarp::os::Bottle& r = val.addList();
for (size_t i = 0; i< m_numberOfJoints; i++)
{
#if GAZEBO_MAJOR_VERSION >= 8
double upperLimit = m_jointPointers[i]->UpperLimit(0);
#else
double upperLimit = m_jointPointers[i]->GetUpperLimit(0).Radian();
#endif
double tmp = convertGazeboToUser(i, upperLimit);
r.addDouble(tmp);
}
return true;
}
if (key == "hardwareLowStop")
{
yarp::os::Bottle& r = val.addList();
for (size_t i = 0; i< m_numberOfJoints; i++) {
#if GAZEBO_MAJOR_VERSION >= 8
double lowerLimit = m_jointPointers[i]->LowerLimit(0);
#else
double lowerLimit = m_jointPointers[i]->GetLowerLimit(0).Radian();
#endif
double tmp = convertGazeboToUser(i, lowerLimit);
r.addDouble(tmp);
}
return true;
}
if (key == "hardwareEffortLimit")
{
yarp::os::Bottle& r = val.addList(); for (size_t i = 0; i< m_numberOfJoints; i++) { double tmp = m_jointPointers[i]->GetEffortLimit(0); r.addDouble(tmp); }
return true;
}
if (key == "hardwareVelocityLimit")
{
yarp::os::Bottle& r = val.addList(); for (size_t i = 0; i< m_numberOfJoints; i++) { double tmp = m_jointPointers[i]->GetVelocityLimit(0); r.addDouble(tmp); }
return true;
}
if (key == "yarp_jntMaxVel")
{
yarp::os::Bottle& r = val.addList(); for (size_t i = 0; i< m_numberOfJoints; i++) { double tmp_min,tmp_max; getVelLimits(i,&tmp_min,&tmp_max); r.addDouble(tmp_max); }
return true;
}
if (key == "yarp_jntMaxPos")
{
yarp::os::Bottle& r = val.addList(); for (size_t i = 0; i< m_numberOfJoints; i++) { double tmp_min,tmp_max; getLimits(i,&tmp_min,&tmp_max); r.addDouble(tmp_max); }
return true;
}
if (key == "yarp_kPWM")
{
yarp::os::Bottle& r = val.addList(); for (size_t i = 0; i< m_numberOfJoints; i++) { r.addDouble(m_kPWM[i]); }
return true;
}
if (key == "yarp_jntMinPos")
{
yarp::os::Bottle& r = val.addList(); for (size_t i = 0; i< m_numberOfJoints; i++) { double tmp_min,tmp_max; getLimits(i,&tmp_min,&tmp_max); r.addDouble(tmp_min); }
return true;
}
if (key == "SHORTCUT_all_pos_kp")
{
yarp::os::Bottle& r = val.addList(); for (size_t i = 0; i< m_numberOfJoints; i++) { yarp::dev::Pid tmp_pid; getPid(VOCAB_PIDTYPE_POSITION, i,&tmp_pid); r.addDouble(tmp_pid.kp); }
return true;
}
if (key == "SHORTCUT_all_pos_kd")
{
yarp::os::Bottle& r = val.addList(); for (size_t i = 0; i< m_numberOfJoints; i++) { yarp::dev::Pid tmp_pid; getPid(VOCAB_PIDTYPE_POSITION, i,&tmp_pid); r.addDouble(tmp_pid.kd); }
return true;
}
if (key == "SHORTCUT_all_pos_ki")
{
yarp::os::Bottle& r = val.addList(); for (size_t i = 0; i< m_numberOfJoints; i++) { yarp::dev::Pid tmp_pid; getPid(VOCAB_PIDTYPE_POSITION, i,&tmp_pid); r.addDouble(tmp_pid.ki); }
return true;
}
if (key == "VelocityTimeout")
{
yarp::os::Bottle& r = val.addList(); for (size_t i = 0; i< m_numberOfJoints; i++) { r.addDouble(m_velocity_watchdog[i]->getDuration()); }
return true;
}
yWarning("getRemoteVariable(): Unknown variable %s", key.c_str());
return false;
}
开发者ID:nunoguedelha,项目名称:gazebo-yarp-plugins,代码行数:95,代码来源:ControlBoardDriverRemoteVariables.cpp
示例18: configureFromPolicy
bool configureFromPolicy(Property& config, const char *policyName) {
this->policyName = policyName;
if (verbose) {
fprintf(RTARGET,"||| policy set to %s\n", policyName);
}
String rootVar = policyName;
const char *result =
yarp::os::getenv(rootVar.c_str());
bool needEnv = false;
#ifdef YARP2_WINDOWS
needEnv = true;
#endif
if (result==NULL) {
root = "";
} else {
root = result;
}
root = config.check(policyName,Value(root)).asString().c_str();
if (root == "") {
if (verbose||needEnv) {
fprintf(RTARGET,"||| environment variable %s not set\n",
rootVar.c_str());
}
if (needEnv) {
return false;
}
} else {
if (verbose) {
fprintf(RTARGET,"||| %s: %s\n",
rootVar.c_str(),root.c_str());
}
}
String checked = "";
String userConfig = expandUserFileName(ConstString(policyName) + ".ini").c_str();
String rootConfig = String(root.c_str()) + "/" + policyName + ".ini";
String altConfig = String("/etc/yarp/policies/") + policyName + ".ini";
#ifndef YARP_NO_DEPRECATED
String deprecatedConfig = String("/etc/") + policyName + ".ini"; // FIXME Deprecated
#endif // YARP_NO_DEPRECATED
bool ok = false;
if (!ok) {
if (root!="") {
if (verbose) {
fprintf(RTARGET,"||| loading policy from %s\n",
rootConfig.c_str());
}
checked += " " + rootConfig;
ok = config.fromConfigFile(rootConfig.c_str(),false);
}
}
if (!needEnv) {
if (!ok) {
if (verbose) {
fprintf(RTARGET,"||| loading policy from %s\n",
userConfig.c_str());
}
checked += " " + userConfig;
ok = config.fromConfigFile(userConfig.c_str(),false);
}
if (!ok) {
if (verbose) {
fprintf(RTARGET,"||| loading policy from %s\n",
altConfig.c_str());
}
checked += " " + altConfig;
ok = config.fromConfigFile(altConfig.c_str(),false);
}
#ifndef YARP_NO_DEPRECATED
if (!ok) {
if (verbose) {
fprintf(RTARGET,"||| loading policy from %s\n",
deprecatedConfig.c_str());
}
checked += " " + deprecatedConfig;
ok = config.fromConfigFile(deprecatedConfig.c_str(),false);
if (ok) {
fprintf(RTARGET, "||| WARNING: Loading policies from /etc/ is deprecated,\n"
"||| you should move them in /etc/yarp/policies/ .\n");
}
}
#endif // YARP_NO_DEPRECATED
if (!ok) {
altConfig = String("/usr/local/etc/") + policyName + ".ini";
if (verbose) {
fprintf(RTARGET,"||| loading policy from %s\n",
altConfig.c_str());
}
checked += " " + altConfig;
ok = config.fromConfigFile(altConfig.c_str(),false);
}
}
/*
// this would violate the spec
if (!ok) {
if (verbose) {
fprintf(RTARGET,"||| in desperation, loading policy from %s\n",
policyName);
}
checked += " ";
checked += policyName;
//.........这里部分代码省略.........
开发者ID:johnty,项目名称:libYARP_OS,代码行数:101,代码来源:ResourceFinder.cpp
示例19: configure
virtual bool configure(ResourceFinder &rf)
{
Time::turboBoost();
//check if the yarp networ is running
if (yarp.checkNetwork()==false)
{
return false;
}
moduleName = rf.check("name", Value(1), "module name (string)").asString();
setName(moduleName.c_str());
period = rf.check("period", Value(5000), "update period (int)").asInt();
string pname = "/" + moduleName + ":o";
monitorOutput.open(pname.c_str());
picBlocks = rf.findFile(rf.check("pic_blocks", Value(1), "module name (string)").asString());
picBackground = rf.findFile(rf.check("pic_background", Value(1), "module name (string)").asString());
picNumbers = rf.findFile(rf.check("pic_numbers", Value(1), "module name (string)").asString());
graphics = new GraphicsManager(picBackground.c_str(),picBlocks.c_str(),picNumbers.c_str());
m_timer = Glib::signal_timeout().connect(sigc::mem_fun(*this, &CtrlModule::on_timeout), period);
on_timeout();
//start GTK loop
gtk_main->run(*graphics);
return true;
}
开发者ID:Tobias-Fischer,项目名称:ikart,代码行数:31,代码来源:main.cpp
注:本文中的yarp::os::ConstString类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论