9 #include <geometry_msgs/typekit/Vector3.h> 16 #include <gtest/gtest.h> 24 std::set<base::PropertyBase *> right_seen;
30 right_seen.insert(right_prop);
37 right_bag = right_prop;
39 if (!(left_bag == right_bag))
return false;
49 if (right_seen.size() != right.
size())
return false;
65 tc->addProperty(
"string", props.string_);
66 tc->addProperty(
"double", props.double_);
67 tc->addProperty(
"float", props.float_);
68 tc->addProperty(
"int", props.int_);
69 tc->addProperty(
"uint", props.uint_);
70 tc->addProperty(
"char", props.char_);
71 tc->addProperty(
"uchar", props.uchar_);
72 tc->addProperty(
"bool", props.bool_);
75 tc->addProperty(
"vstring", props.v_string_);
76 tc->addProperty(
"vdouble", props.v_double_);
77 tc->addProperty(
"vfloat", props.v_float_);
78 tc->addProperty(
"vint", props.v_int_);
79 tc->addProperty(
"vuint", props.v_uint_);
80 tc->addProperty(
"vchar", props.v_char_);
81 tc->addProperty(
"vuchar", props.v_uchar_);
82 tc->addProperty(
"vbool", props.v_bool_);
84 tc->addProperty(
"eigenvectordouble", props.eigenvector_double_);
85 tc->addProperty(
"eigenvectorfloat", props.eigenvector_float_);
88 tc->addProperty(
"bag", props.bag_);
89 tc->addProperty(
"vector3", props.vector3_);
95 ASSERT_TRUE(tc->loadService(
"rosparam"));
96 ASSERT_TRUE((rosparam = tc->getProvider<
ROSParam>(
"rosparam")).get());
97 ASSERT_TRUE((service = tc->provides()->getService(
"rosparam")).
get());
149 v_string_.push_back(string_);
150 v_double_.push_back(double_);
151 v_float_.push_back(float_);
152 v_int_.push_back(int_);
153 v_uint_.push_back(uint_);
154 v_char_.push_back(char_);
155 v_uchar_.push_back(uchar_);
156 v_bool_.push_back(bool_);
158 eigenvector_double_ = Eigen::Vector3d(5.0, 6.0, 7.0);
159 eigenvector_float_ = Eigen::Vector3f(8.0
f, 9.0
f, 10.0
f);
190 eigenvector_double_.setZero(0);
191 eigenvector_float_.setZero(0);
197 vector3_= geometry_msgs::Vector3();
207 if (!only_ros_types) {
210 data.
uint_ =
static_cast<unsigned int>(temp);
212 data.
char_ =
static_cast<char>(temp);
214 data.
uchar_ =
static_cast<unsigned char>(temp);
222 if (!only_ros_types) {
223 std::vector<int> vtemp;
225 data.
v_uint_.assign(vtemp.begin(), vtemp.end());
227 data.
v_char_.assign(vtemp.begin(), vtemp.end());
229 data.
v_uchar_.assign(vtemp.begin(), vtemp.end());
233 std::vector<double> v_temp_double;
234 EXPECT_TRUE(
ros::param::get(prefix +
"eigenvectordouble", v_temp_double));
235 data.
eigenvector_double_ = Eigen::Map<Eigen::VectorXd>(v_temp_double.data(), v_temp_double.size());
236 std::vector<float> v_temp_float;
237 EXPECT_TRUE(
ros::param::get(prefix +
"eigenvectorfloat", v_temp_float));
238 data.
eigenvector_float_ = Eigen::Map<Eigen::VectorXf>(v_temp_float.data(), v_temp_float.size());
240 if (!only_ros_types) {
246 switch(it->second.getType()) {
280 std::vector<int> vtemp;
295 (void) bag_xmlrpc.
begin();
297 if (bag_string.
ready()) bag_xmlrpc[
"string"] = bag_string.
rvalue();
299 if (bag_string.
ready()) bag_xmlrpc[
"int"] = bag_int.
rvalue();
309 prop_it != tc->properties()->end(); ++prop_it)
323 EXPECT_EQ(expected.
string_, actual.
string_) <<
"string values do not match in " << test_name;
324 EXPECT_EQ(expected.
double_, actual.
double_) <<
"double values do not match in " << test_name;
325 EXPECT_EQ(expected.
float_, actual.
float_) <<
"float values do not match in " << test_name;
326 EXPECT_EQ(expected.
int_, actual.
int_) <<
"int values do not match in " << test_name;
327 if (!only_ros_types) {
328 EXPECT_EQ(expected.
uint_, actual.
uint_) <<
"unsigned int values do not match in " << test_name;
329 EXPECT_EQ(expected.
char_, actual.
char_) <<
"char values do not match in " << test_name;
330 EXPECT_EQ(expected.
uchar_, actual.
uchar_) <<
"unsigned char values do not match in " << test_name;
332 EXPECT_EQ(expected.
bool_, actual.
bool_) <<
"bool values do not match in " << test_name;
333 EXPECT_EQ(expected.
v_string_, actual.
v_string_) <<
"string vectors do not match in " << test_name;
334 EXPECT_EQ(expected.
v_double_, actual.
v_double_) <<
"double vectors do not match in " << test_name;
335 EXPECT_EQ(expected.
v_float_, actual.
v_float_) <<
"float vectors do not match in " << test_name;
336 EXPECT_EQ(expected.
v_int_, actual.
v_int_) <<
"int vectors does do match in " << test_name;
337 if (!only_ros_types) {
338 EXPECT_EQ(expected.
v_uint_, actual.
v_uint_) <<
"unsigned int vectors do not match in " << test_name;
339 EXPECT_EQ(expected.
v_char_, actual.
v_char_) <<
"char vectors do not match in " << test_name;
340 EXPECT_EQ(expected.
v_uchar_, actual.
v_uchar_) <<
"unsigned char vectors do not match in " << test_name;
342 EXPECT_EQ(expected.
v_bool_, actual.
v_bool_) <<
"bool vectors do not match in " << test_name;
346 if (!only_ros_types) {
347 EXPECT_EQ(expected.
bag_, actual.
bag_) <<
"PropertyBag contents do not match in " << test_name;
348 EXPECT_EQ(expected.
vector3_.x, actual.
vector3_.x) <<
"geometry_msgs/Vector3 values do not match in " << test_name;
349 EXPECT_EQ(expected.
vector3_.y, actual.
vector3_.y) <<
"geometry_msgs/Vector3 values do not match in " << test_name;
350 EXPECT_EQ(expected.
vector3_.z, actual.
vector3_.z) <<
"geometry_msgs/Vector3 values do not match in " << test_name;
376 EXPECT_TRUE(rosparam->setAllRelative());
377 getParameters(
"", params);
378 compareValues(props, params,
"setAllRelative()");
388 EXPECT_TRUE(rosparam->setAllPrivate());
389 getParameters(
"~", params);
390 compareValues(props, params,
"setAllPrivate()");
394 EXPECT_TRUE(rosparam->setAllComponentRelative());
395 getParameters(tc->getName() +
"/", params);
396 compareValues(props, params,
"setAllComponentRelative()");
400 EXPECT_TRUE(rosparam->setAllComponentAbsolute());
401 getParameters(
"/" + tc->getName() +
"/", params);
402 compareValues(props, params,
"setAllComponentAbsolute()");
406 EXPECT_TRUE(rosparam->setAllComponentPrivate());
407 getParameters(
"~" + tc->getName() +
"/", params);
408 compareValues(props, params,
"setAllComponentPrivate()");
418 setParameters(
"", params);
420 EXPECT_TRUE(rosparam->getAllRelative());
421 compareValues(params, props,
"getAllRelative()");
424 setParameters(
"/", params);
426 EXPECT_TRUE(rosparam->getAllAbsolute());
427 compareValues(params, props,
"getAllAbsolute()");
430 setParameters(
"~", params);
432 EXPECT_TRUE(rosparam->getAllPrivate());
433 compareValues(params, props,
"getAllPrivate()");
436 setParameters(
"" + tc->getName() +
"/", params);
438 EXPECT_TRUE(rosparam->getAllComponentRelative());
439 compareValues(params, props,
"getAllComponentRelative()");
442 setParameters(
"/" + tc->getName() +
"/", params);
444 EXPECT_TRUE(rosparam->getAllComponentAbsolute());
445 compareValues(params, props,
"getAllComponentAbsolute()");
448 setParameters(
"~" + tc->getName() +
"/", params);
450 EXPECT_TRUE(rosparam->getAllComponentPrivate());
451 compareValues(params, props,
"getAllComponentPrivate()");
461 prop_it != tc->properties()->end(); ++prop_it) {
462 EXPECT_TRUE(rosparam->setRelative((*prop_it)->getName()));
464 getParameters(
"", params);
465 compareValues(props, params,
"setRelative()");
479 prop_it != tc->properties()->end(); ++prop_it) {
480 EXPECT_TRUE(rosparam->setPrivate((*prop_it)->getName()));
482 getParameters(
"~", params);
483 compareValues(props, params,
"setPrivate()");
488 prop_it != tc->properties()->end(); ++prop_it) {
489 EXPECT_TRUE(rosparam->setComponentRelative((*prop_it)->getName()));
491 getParameters(tc->getName() +
"/", params);
492 compareValues(props, params,
"setComponentRelative()");
497 prop_it != tc->properties()->end(); ++prop_it) {
498 EXPECT_TRUE(rosparam->setComponentAbsolute((*prop_it)->getName()));
500 getParameters(
"/" + tc->getName() +
"/", params);
501 compareValues(props, params,
"setComponentAbsolute()");
506 prop_it != tc->properties()->end(); ++prop_it) {
507 EXPECT_TRUE(rosparam->setComponentPrivate((*prop_it)->getName()));
509 getParameters(
"~" + tc->getName() +
"/", params);
510 compareValues(props, params,
"setComponentPrivate()");
520 setParameters(
"", params);
523 prop_it != tc->properties()->end(); ++prop_it) {
524 EXPECT_TRUE(rosparam->getRelative((*prop_it)->getName()));
526 compareValues(params, props,
"getRelative()");
529 setParameters(
"/", params);
532 prop_it != tc->properties()->end(); ++prop_it) {
533 EXPECT_TRUE(rosparam->getAbsolute((*prop_it)->getName()));
535 compareValues(params, props,
"getAbsolute()");
538 setParameters(
"~", params);
541 prop_it != tc->properties()->end(); ++prop_it) {
542 EXPECT_TRUE(rosparam->getPrivate((*prop_it)->getName()));
544 compareValues(params, props,
"getPrivate()");
547 setParameters(
"" + tc->getName() +
"/", params);
550 prop_it != tc->properties()->end(); ++prop_it) {
551 EXPECT_TRUE(rosparam->getComponentRelative((*prop_it)->getName()));
553 compareValues(params, props,
"getComponentRelative()");
556 setParameters(
"/" + tc->getName() +
"/", params);
559 prop_it != tc->properties()->end(); ++prop_it) {
560 EXPECT_TRUE(rosparam->getComponentAbsolute((*prop_it)->getName()));
562 compareValues(params, props,
"getComponentAbsolute()");
565 setParameters(
"~" + tc->getName() +
"/", params);
568 prop_it != tc->properties()->end(); ++prop_it) {
569 EXPECT_TRUE(rosparam->getComponentPrivate((*prop_it)->getName()));
571 compareValues(params, props,
"getComponentPrivate()");
580 rosparam->setStringComponentPrivate(
"string", props.string_);
581 rosparam->setDoubleComponentPrivate(
"double", props.double_);
582 rosparam->setFloatComponentPrivate(
"float", props.float_);
583 rosparam->setIntComponentPrivate(
"int", props.int_);
584 rosparam->setBoolComponentPrivate(
"bool", props.bool_);
585 rosparam->setVectorOfStringComponentPrivate(
"vstring", props.v_string_);
586 rosparam->setVectorOfDoubleComponentPrivate(
"vdouble", props.v_double_);
587 rosparam->setVectorOfFloatComponentPrivate(
"vfloat", props.v_float_);
588 rosparam->setVectorOfIntComponentPrivate(
"vint", props.v_int_);
589 rosparam->setVectorOfBoolComponentPrivate(
"vbool", props.v_bool_);
590 rosparam->setEigenVectorXdComponentPrivate(
"eigenvectordouble", props.eigenvector_double_);
591 rosparam->setEigenVectorXfComponentPrivate(
"eigenvectorfloat", props.eigenvector_float_);
592 getParameters(
"~" + tc->getName() +
"/", params,
true);
593 compareValues(props, params,
"set[Type]ComponentPrivate()",
true);
600 setParameters(
"~" + tc->getName() +
"/", params);
604 EXPECT_TRUE(rosparam->getStringComponentPrivate(
"string", props.string_));
605 EXPECT_TRUE(rosparam->getDoubleComponentPrivate(
"double", props.double_));
606 EXPECT_TRUE(rosparam->getFloatComponentPrivate(
"float", props.float_));
607 EXPECT_TRUE(rosparam->getIntComponentPrivate(
"int", props.int_));
608 EXPECT_TRUE(rosparam->getBoolComponentPrivate(
"bool", props.bool_));
609 EXPECT_TRUE(rosparam->getVectorOfStringComponentPrivate(
"vstring", props.v_string_));
610 EXPECT_TRUE(rosparam->getVectorOfDoubleComponentPrivate(
"vdouble", props.v_double_));
611 EXPECT_TRUE(rosparam->getVectorOfFloatComponentPrivate(
"vfloat", props.v_float_));
612 EXPECT_TRUE(rosparam->getVectorOfIntComponentPrivate(
"vint", props.v_int_));
613 EXPECT_TRUE(rosparam->getVectorOfBoolComponentPrivate(
"vbool", props.v_bool_));
614 EXPECT_TRUE(rosparam->getEigenVectorXdComponentPrivate(
"eigenvectordouble", props.eigenvector_double_));
615 EXPECT_TRUE(rosparam->getEigenVectorXfComponentPrivate(
"eigenvectorfloat", props.eigenvector_float_));
616 compareValues(params, props,
"get[Type]ComponentPrivate()",
true);
619 int main(
int argc,
char** argv) {
620 testing::InitGoogleTest(&argc, argv);
624 remappings[
"__ns"] =
"rtt_rosparam_namespace";
634 return RUN_ALL_TESTS();
ValueStruct::iterator iterator
int __os_init(int argc, char **argv)
Eigen::VectorXd eigenvector_double_
boost::shared_ptr< Service > service
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
std::vector< unsigned char > v_uchar_
const_reference_t rvalue() const
Type const & getType() const
static boost::shared_ptr< ComponentLoader > Instance()
geometry_msgs::Vector3 vector3_
std::map< std::string, std::string > M_string
bool ownProperty(base::PropertyBase *p)
std::vector< char > v_char_
ROSCPP_DECL void set(const std::string &key, const XmlRpc::XmlRpcValue &v)
int main(int argc, char **argv)
void getParameters(const std::string &prefix, Values &data, bool only_ros_types=false)
Eigen::VectorXf eigenvector_float_
std::vector< unsigned int > v_uint_
ROSCPP_DECL bool get(const std::string &key, std::string &s)
void mayLogStdOut(bool tf)
std::vector< bool > v_bool_
virtual std::string getType() const =0
std::vector< float > v_float_
Properties::const_iterator const_iterator
TEST_F(ParamTest, Constants)
static bool operator==(const ConnPolicy &, const ConnPolicy &)
void compareValues(const Values &expected, const Values &actual, const std::string &test_name, bool only_ros_types=false)
std::vector< double > v_double_
ROSCPP_DECL bool del(const std::string &key)
base::PropertyBase * getProperty(const std::string &name) const
boost::shared_ptr< ROSParam > rosparam
const std::string & getName() const
void setParameters(const std::string &prefix, const Values &data)
std::vector< std::string > v_string_
std::vector< int > v_int_
void setStdStream(std::ostream &stdos)