本文整理汇总了C++中xmlrpc::XmlRpcValue类的典型用法代码示例。如果您正苦于以下问题:C++ XmlRpcValue类的具体用法?C++ XmlRpcValue怎么用?C++ XmlRpcValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XmlRpcValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkAndSetFeature
void checkAndSetFeature(CamData& cd, string param_name, dc1394feature_t feature)
{
string p = cd.name + string("/") + param_name;
if (has_param(p))
{
XmlRpc::XmlRpcValue val;
get_param(p, val);
if (val.getType() == XmlRpc::XmlRpcValue::TypeString)
if (val == string("auto"))
cd.cam->setFeatureMode(feature, DC1394_FEATURE_MODE_AUTO);
else
cd.cam->setFeatureMode(feature, DC1394_FEATURE_MODE_MANUAL);
if (val.getType() == XmlRpc::XmlRpcValue::TypeInt)
{
cd.cam->setFeatureMode(feature, DC1394_FEATURE_MODE_MANUAL);
cd.cam->setFeature(feature, (int)(val));
}
if (val.getType() == XmlRpc::XmlRpcValue::TypeDouble)
{
cd.cam->setFeatureMode(feature, DC1394_FEATURE_MODE_MANUAL);
cd.cam->setFeatureAbsolute(feature, (double)(val));
}
}
}
示例2: checkAndSetWhitebalance
void checkAndSetWhitebalance(CamData& cd, string param_name, dc1394feature_t feature)
{
string p = cd.name + string("/") + param_name;
string p_b = cd.name + string("/") + param_name + string("_b");
string p_r = cd.name + string("/") + param_name + string("_r");
if (has_param(p_b) && has_param(p_r))
{
XmlRpc::XmlRpcValue val;
XmlRpc::XmlRpcValue val_b;
XmlRpc::XmlRpcValue val_r;
get_param(p, val);
get_param(p_b, val_b);
get_param(p_r, val_r);
if (val.getType() == XmlRpc::XmlRpcValue::TypeString && val == string("auto"))
cd.cam->setFeatureMode(feature, DC1394_FEATURE_MODE_AUTO);
else if (val_b.getType() == XmlRpc::XmlRpcValue::TypeInt && val_r.getType() == XmlRpc::XmlRpcValue::TypeInt)
{
cd.cam->setFeatureMode(feature, DC1394_FEATURE_MODE_MANUAL);
cd.cam->setFeature(feature, (int)(val_b), (int)(val_r));
}
}
}
示例3: set
bool set(std::string key, XmlRpc::XmlRpcValue val)
{
try
{
if (val.getType() == XmlRpc::XmlRpcValue::TypeBoolean){
bool value = static_cast<bool>(val);
return (set(key,value));
}
if (val.getType() == XmlRpc::XmlRpcValue::TypeDouble){
double value = static_cast<double>(val);
return (set(key,value));
}
if (val.getType() == XmlRpc::XmlRpcValue::TypeString){
std::string value = static_cast<std::string>(val);
return (set(key,value));
}
if (val.getType() == XmlRpc::XmlRpcValue::TypeInt){
int value = static_cast<int>(val);
return (set(key,value));
}
}
catch (...)
{
return false;
}
return false;
}
示例4: get
bool get(std::string key, XmlRpc::XmlRpcValue& val)
{
try
{
bool v;
if (get(key,v)){
XmlRpc::XmlRpcValue vb(v);
val = vb;
return (val.valid());
}
double vd;
if (get(key,vd)){
val = vd;
return (val.valid());
}
int vi;
if (get(key,vi)){
val=vi;
return (val.valid());
}
std::string vs;
if (get(key, vs)){
val=vs.c_str();
return (val.valid());
}
}
catch (...)
{
return false;
}
return false;
}
示例5: while
Path::Path() {
ros::NodeHandle nh;
XmlRpc::XmlRpcValue pathCfg;
nh.getParam("/path", pathCfg);
try {
int i = 0;
do {
char pointName[256];
sprintf(pointName, "point%d", i);
if (!pathCfg.hasMember(pointName))
break;
XmlRpc::XmlRpcValue pointCfg = pathCfg[std::string(pointName)];
geometry_msgs::Point p;
if (!(pointCfg.hasMember("x") && pointCfg.hasMember("y")))
continue;
p.x = FLOAT_PARAM(pointCfg["x"]);
p.y = FLOAT_PARAM(pointCfg["y"]);
p.z = 0;
points.push_back(p);
} while ((++i) != 0);
} catch (XmlRpc::XmlRpcException& e) {
ROS_ERROR("Unable to parse path parameter. (%s)", e.getMessage().c_str());
}
}
示例6: execute
void startWorkingCallback::execute (XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result)
{
// if no arguments were received
if (!params.valid())
{
result = ctrl_xmlrpc->startProcessing();
}
else
{
switch(params.size())
{
// start the server in online mode with port and blocksize
case 2:
ctrl_xmlrpc->startEegServer((int) params[0], (int) params[1]);
result = 0;
break;
case 3:
ctrl_xmlrpc->startEegServer((std::string) params[0], (int) params[1], (int) params[2]);
result = 0;
break;
default:
OMG("WARNING! Server got wrong number of arguments!");
break;
}
}
fflush(stdout);
}
示例7: getConfigurationFromParameters
void TeleopCOB::getConfigurationFromParameters()
{
//std::map<std::string,joint_module> joint_modules; //std::vector<std::string> module_names;
if(n_.hasParam("modules"))
{
XmlRpc::XmlRpcValue modules;
ROS_DEBUG("modules found ");
n_.getParam("modules", modules);
if(modules.getType() == XmlRpc::XmlRpcValue::TypeStruct)
{
ROS_DEBUG("modules are of type struct with size %d",(int)modules.size());
for(std::map<std::string,XmlRpc::XmlRpcValue>::iterator p=modules.begin();p!=modules.end();++p)
{
std::string mod_name = p->first;
ROS_DEBUG("module name: %s",mod_name.c_str());
XmlRpc::XmlRpcValue mod_struct = p->second;
if(mod_struct.getType() != XmlRpc::XmlRpcValue::TypeStruct)
ROS_WARN("invalid module, name: %s",mod_name.c_str());
// search for joint_name parameter in current module struct to determine which type of module
// only joint mods or wheel mods supported
// which mens that is no joint names are found, then the module is a wheel module
// TODO replace with build in find, but could not get it to work
if(!assign_joint_module(mod_name, mod_struct))
{
// add wheel module struct
ROS_DEBUG("wheel module found");
assign_base_module(mod_struct);
}
}
}
}
}
示例8: getImpl
bool getImpl(const std::string& key, int& i, bool use_cache)
{
XmlRpc::XmlRpcValue v;
if (!getImpl(key, v, use_cache))
{
return false;
}
if (v.getType() == XmlRpc::XmlRpcValue::TypeDouble)
{
double d = v;
if (fmod(d, 1.0) < 0.5)
{
d = floor(d);
}
else
{
d = ceil(d);
}
i = d;
}
else if (v.getType() != XmlRpc::XmlRpcValue::TypeInt)
{
return false;
}
else
{
i = v;
}
return true;
}
示例9: setParams
bool DepthImageOccupancyMapUpdater::setParams(XmlRpc::XmlRpcValue ¶ms)
{
try
{
sensor_type_ = (std::string) params["sensor_type"];
if (params.hasMember("image_topic"))
image_topic_ = (std::string) params["image_topic"];
if (params.hasMember("queue_size"))
queue_size_ = (int)params["queue_size"];
readXmlParam(params, "near_clipping_plane_distance", &near_clipping_plane_distance_);
readXmlParam(params, "far_clipping_plane_distance", &far_clipping_plane_distance_);
readXmlParam(params, "shadow_threshold", &shadow_threshold_);
readXmlParam(params, "padding_scale", &padding_scale_);
readXmlParam(params, "padding_offset", &padding_offset_);
readXmlParam(params, "skip_vertical_pixels", &skip_vertical_pixels_);
readXmlParam(params, "skip_horizontal_pixels", &skip_horizontal_pixels_);
}
catch (XmlRpc::XmlRpcException &ex)
{
ROS_ERROR("XmlRpc Exception: %s", ex.getMessage().c_str());
return false;
}
return true;
}
示例10: setParams
bool PointCloudMoveitFilter::setParams(XmlRpc::XmlRpcValue ¶ms)
{
try
{
if (!params.hasMember("point_cloud_topic"))
return false;
point_cloud_topic_ = static_cast<const std::string&>(params["point_cloud_topic"]);
readXmlParam(params, "max_range", &max_range_);
readXmlParam(params, "padding_offset", &padding_);
readXmlParam(params, "padding_scale", &scale_);
readXmlParam(params, "point_subsample", &point_subsample_);
if (!params.hasMember("filtered_cloud_topic")) {
ROS_ERROR("filtered_cloud_topic is required");
return false;
}
else {
filtered_cloud_topic_ = static_cast<const std::string&>(params["filtered_cloud_topic"]);
}
if (params.hasMember("filtered_cloud_use_color")) {
use_color_ = (bool)params["filtered_cloud_use_color"];
}
if (params.hasMember("filtered_cloud_keep_organized")) {
keep_organized_ = (bool)params["filtered_cloud_keep_organized"];
}
}
catch (XmlRpc::XmlRpcException& ex)
{
ROS_ERROR("XmlRpc Exception: %s", ex.getMessage().c_str());
return false;
}
return true;
}
示例11: readPoseParam
void FootstepMarker::readPoseParam(ros::NodeHandle& pnh, const std::string param,
tf::Transform& offset) {
XmlRpc::XmlRpcValue v;
geometry_msgs::Pose pose;
if (pnh.hasParam(param)) {
pnh.param(param, v, v);
// check if v is 7 length Array
if (v.getType() == XmlRpc::XmlRpcValue::TypeArray &&
v.size() == 7) {
// safe parameter access by getXMLDoubleValue
pose.position.x = getXMLDoubleValue(v[0]);
pose.position.y = getXMLDoubleValue(v[1]);
pose.position.z = getXMLDoubleValue(v[2]);
pose.orientation.x = getXMLDoubleValue(v[3]);
pose.orientation.y = getXMLDoubleValue(v[4]);
pose.orientation.z = getXMLDoubleValue(v[5]);
pose.orientation.w = getXMLDoubleValue(v[6]);
// converst the message as following: msg -> eigen -> tf
//void poseMsgToEigen(const geometry_msgs::Pose &m, Eigen::Affine3d &e);
Eigen::Affine3d e;
tf::poseMsgToEigen(pose, e); // msg -> eigen
tf::transformEigenToTF(e, offset); // eigen -> tf
}
else {
ROS_ERROR_STREAM(param << " is malformed, which should be 7 length array");
}
}
else {
ROS_WARN_STREAM("there is no parameter on " << param);
}
}
示例12: getNodes
bool getNodes(V_string& nodes)
{
XmlRpc::XmlRpcValue args, result, payload;
args[0] = this_node::getName();
if (!execute("getSystemState", args, result, payload, true))
{
return false;
}
S_string node_set;
for (int i = 0; i < payload.size(); ++i)
{
for (int j = 0; j < payload[i].size(); ++j)
{
XmlRpc::XmlRpcValue val = payload[i][j][1];
for (int k = 0; k < val.size(); ++k)
{
std::string name = payload[i][j][1][k];
node_set.insert(name);
}
}
}
nodes.insert(nodes.end(), node_set.begin(), node_set.end());
return true;
}
示例13: getDoubleArray
bool FTParamsInternal::getDoubleArray(XmlRpc::XmlRpcValue params, const char* name, double *results, unsigned len)
{
if(!params.hasMember(name))
{
ROS_ERROR("Expected ft_param to have '%s' element", name);
return false;
}
XmlRpc::XmlRpcValue values = params[name];
if (values.getType() != XmlRpc::XmlRpcValue::TypeArray)
{
ROS_ERROR("Expected FT param '%s' to be list type", name);
return false;
}
if (values.size() != int(len))
{
ROS_ERROR("Expected FT param '%s' to have %d elements", name, len);
return false;
}
for (unsigned i=0; i<len; ++i)
{
if (values[i].getType() != XmlRpc::XmlRpcValue::TypeDouble)
{
ROS_ERROR("Expected FT param %s[%d] to be floating point type", name, i);
return false;
} else {
results[i] = static_cast<double>(values[i]);
}
}
return true;
}
示例14: generateConfigVector
/*generateConfigVector stores the pinging sensors, to which pinging sensor is a listening
* sensor bound to in a cycle and which sensors are not used at all.
* In the output, the pinging sensors are represented by PINGING_SENSOR, location of
* each listening sensor holds the address of its corresponding pinging sensor
* and the sensors not used at all are represented by SENSOR_NOT_USED.
*/
std::vector <std::vector<int> > generateConfigVector(XmlRpc::XmlRpcValue config_list)
{
std::vector<std::vector<int> > config;
XmlRpc::XmlRpcValue current_cycle;
ROS_ASSERT(config_list.getType() == XmlRpc::XmlRpcValue::TypeArray);
for(int i = 0; i < config_list.size(); i++)
{
ROS_ASSERT(config_list[i].getType() == XmlRpc::XmlRpcValue::TypeStruct);
std::vector<int> cycle_vector; //For holding configuration for each cycle.
cycle_vector.resize(MAX_SENSORS);
for (int j=0; j<MAX_SENSORS; j++)
cycle_vector[j]=SENSOR_NOT_USED;
//better to keep it dynamic
for (int j = 0; j<MAX_SENSORS; j++){
char str_index[3] = {'\0','\0', '\0'}; // for storing int to hex conv.
sprintf(str_index,"%d", j); // Unsure if yamlcpp parser reads hexadecimal values
if(config_list[i].hasMember(str_index))
{
cycle_vector[j]=PINGING_SENSOR; //Set -1 for pinging sensor
current_cycle = (config_list[i]).operator[](str_index);
ROS_ASSERT(current_cycle.getType() == XmlRpc::XmlRpcValue::TypeArray);
ROS_ASSERT(current_cycle.size()>0);
//Assign address of pinging sensor to each listening sensor
for (int k = 0; k<current_cycle.size(); k++){
cycle_vector[static_cast<int>(current_cycle[k])]=((static_cast<int>(current_cycle[k])!=j)?j:PINGING_AND_LISTENING_SENSOR);
}
}
}
config.push_back(cycle_vector);
}
return config;
}
示例15: getProcState
void CRTLXmlrpc::getProcState(XmlRpc::XmlRpcValue& result)
{
result.setSize(3);
result[1] = 0.0;
result[2] = 0.0;
if(eegmanager == NULL) {
result[0] = std::string("IDLE");
return;
}
// update local state variable
if(!eegmanager->isRunning()) started = false;
if(eegmanager->isRunning()) {
result.setSize(eegmanager->bandwidth.size()*2 + 1);
result[0] = std::string("RUNNING");
result.setSize(eegmanager->bandwidth.size());
for(uint32_t i=0; i<eegmanager->bandwidth.size(); i++) {
result[(i*2)+1] = eegmanager->bandwidth[i];
result[(i*2)+2] = eegmanager->fill[i];
}
return;
}
if(eegmanager->current_setup().size() > 0) {
result[0] = std::string("CONFIGURED");
return;
}
result[0] = std::string("IDLE");
return;
}