motor_parameter_test.cc
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 #include <ros/ros.h>
4 
5 TEST(MotorParameterTests, getParamOrDefaultTest) {
7  ASSERT_EQ(5, getParamOrDefault(nh, "getParamOrDefaultTest", 5));
8  int foo;
9  ASSERT_TRUE(nh.getParam("getParamOrDefaultTest", foo));
10  ASSERT_EQ(5, foo);
11 
12  ASSERT_EQ(5, getParamOrDefault(nh, "getParamOrDefaultTest", 10));
13 }
14 
15 TEST(MotorParameterTests, NodeParamTest) {
16  ros::NodeHandle nh;
17  NodeParams np(nh);
18  ASSERT_DOUBLE_EQ(10.0, np.controller_loop_rate);
19  nh.setParam("ubiquity_motor/controller_loop_rate", 50.0);
20  np = NodeParams(nh);
21  ASSERT_DOUBLE_EQ(50.0, np.controller_loop_rate);
22 }
23 
24 TEST(MotorParameterTests, CommsParamsTest) {
25  ros::NodeHandle nh;
26  CommsParams cp(nh);
27  ASSERT_EQ("/dev/ttyS0", cp.serial_port);
28  nh.setParam("ubiquity_motor/serial_port", "/dev/foo");
29  cp = CommsParams(nh);
30  ASSERT_EQ("/dev/foo", cp.serial_port);
31 }
32 
33 int main(int argc, char **argv) {
34  testing::InitGoogleTest(&argc, argv);
35  ros::init(argc, argv, "param_test");
36  return RUN_ALL_TESTS();
37 }
ros::NodeHandle::setParam
void setParam(const std::string &key, bool b) const
TEST
TEST(MotorParameterTests, getParamOrDefaultTest)
Definition: motor_parameter_test.cc:5
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
ros::NodeHandle::getParam
bool getParam(const std::string &key, bool &b) const
ros.h
NodeParams::controller_loop_rate
double controller_loop_rate
Definition: motor_parameters.h:194
getParamOrDefault
T getParamOrDefault(ros::NodeHandle nh, std::string parameter_name, T default_val)
Definition: motor_parameters.h:48
motor_parameters.h
main
int main(int argc, char **argv)
Definition: motor_parameter_test.cc:33
CommsParams
Definition: motor_parameters.h:175
CommsParams::serial_port
std::string serial_port
Definition: motor_parameters.h:176
NodeParams
Definition: motor_parameters.h:193
ros::NodeHandle


ubiquity_motor
Author(s):
autogenerated on Thu Nov 16 2023 03:30:55