Skip to content

Instantly share code, notes, and snippets.

@jbohren
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbohren/dc33acf4d3727e83ab7f to your computer and use it in GitHub Desktop.
Save jbohren/dc33acf4d3727e83ab7f to your computer and use it in GitHub Desktop.
interesting rosparam behavior...
#include <ros/ros.h>
/**
> rosparam set /some_abs_param 1337
> rosparam set /test/foo 16
> ./test
struct!
has member foo: 1
foo: 16
abs: 1337
**/
int main(int argc, char** argv) {
ros::init(argc, argv, "test");
ros::NodeHandle nh("~");
XmlRpc::XmlRpcValue v;
nh.getParam("/",v);
if(v.getType() == XmlRpc::XmlRpcValue::TypeStruct) {
std::cout << "struct!" << std::endl;
std::cout << "has member foo: " << v.hasMember("foo") << std::endl;
std::cout << "foo: " << (int)v["foo"] << std::endl;
}
if(nh.getParam("/some_abs_param",v)) {
std::cout << "abs: " << (int)v << std::endl;
} else {
std::cerr << "/some_abs_param not found" << std::endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment