29 #include <gtest/gtest.h> 38 TEST(CombinedRobotHWTests, combinationOk)
43 bool init_success = robot_hw.
init(nh, nh);
44 ASSERT_TRUE(init_success);
53 ASSERT_TRUE(js_interface != NULL);
54 ASSERT_TRUE(ej_interface != NULL);
55 ASSERT_TRUE(vj_interface != NULL);
56 ASSERT_TRUE(ft_interface != NULL);
57 ASSERT_TRUE(plain_hw_interface != NULL);
60 ASSERT_EQ(NULL, pj_interface);
71 js_handle = js_interface->
getHandle(
"right_arm_joint_1");
72 ej_handle = ej_interface->getHandle(
"right_arm_joint_1");
73 vj_handle = vj_interface->getHandle(
"right_arm_joint_1");
74 ASSERT_FLOAT_EQ(1.0, js_handle.getPosition());
80 ASSERT_FLOAT_EQ(0.2, ft_handle.getForce()[2]);
83 ASSERT_ANY_THROW(ej_interface->getHandle(
"non_existent_joint"));
88 js_handle = js_interface->
getHandle(
"test_joint1");
89 ASSERT_FLOAT_EQ(2.7, js_handle.getPosition());
90 ASSERT_FLOAT_EQ(1.2, ft_handle.getForce()[2]);
92 ej_handle = ej_interface->getHandle(
"test_joint1");
95 ej_handle = ej_interface->getHandle(
"test_joint2");
96 ASSERT_FLOAT_EQ(3.5, ej_handle.getCommand());
99 TEST(CombinedRobotHWTests, switchOk)
104 bool init_success = robot_hw.
init(nh, nh);
105 ASSERT_TRUE(init_success);
109 std::list<hardware_interface::ControllerInfo> start_list;
110 std::list<hardware_interface::ControllerInfo> stop_list;
112 ASSERT_NO_THROW(robot_hw.
doSwitch(start_list, stop_list));
117 std::list<hardware_interface::ControllerInfo> start_list;
118 std::list<hardware_interface::ControllerInfo> stop_list;
120 controller_1.
name =
"ctrl_1";
121 controller_1.
type =
"some_type";
124 iface_res_1.
resources.insert(
"ft_sensor_1");
126 start_list.push_back(controller_1);
128 ASSERT_ANY_THROW(robot_hw.
doSwitch(start_list, stop_list));
133 std::list<hardware_interface::ControllerInfo> start_list;
134 std::list<hardware_interface::ControllerInfo> stop_list;
136 controller_1.
name =
"ctrl_1";
137 controller_1.
type =
"some_type";
140 iface_res_1.
resources.insert(
"test_joint1");
141 iface_res_1.
resources.insert(
"test_joint2");
142 iface_res_1.
resources.insert(
"test_joint3");
143 iface_res_1.
resources.insert(
"test_joint4");
147 iface_res_2.
resources.insert(
"test_joint1");
148 iface_res_2.
resources.insert(
"test_joint4");
150 start_list.push_back(controller_1);
155 iface_res_3.
resources.insert(
"test_joint3");
156 iface_res_3.
resources.insert(
"test_joint5");
158 start_list.push_back(controller_2);
160 ASSERT_NO_THROW(robot_hw.
doSwitch(start_list, stop_list));
166 std::list<hardware_interface::ControllerInfo> start_list;
167 std::list<hardware_interface::ControllerInfo> stop_list;
169 controller_1.
name =
"ctrl_1";
170 controller_1.
type =
"some_type";
173 iface_res_1.
resources.insert(
"test_joint1");
174 iface_res_1.
resources.insert(
"test_joint2");
175 iface_res_1.
resources.insert(
"test_joint3");
176 iface_res_1.
resources.insert(
"test_joint4");
180 iface_res_2.
resources.insert(
"test_joint1");
181 iface_res_2.
resources.insert(
"non_registered_joint1");
183 start_list.push_back(controller_1);
188 iface_res_3.
resources.insert(
"test_joint3");
189 iface_res_3.
resources.insert(
"non_registered_joint2");
191 start_list.push_back(controller_2);
193 ASSERT_NO_THROW(robot_hw.
doSwitch(start_list, stop_list));
198 std::list<hardware_interface::ControllerInfo> start_list;
199 std::list<hardware_interface::ControllerInfo> stop_list;
201 controller_1.
name =
"ctrl_without_my_robot_hw_2_resources_in_one_of_two_ifaces";
202 controller_1.
type =
"some_type";
207 iface_res_1.
resources.insert(
"test_joint1");
208 iface_res_1.
resources.insert(
"test_joint2");
209 iface_res_1.
resources.insert(
"test_joint3");
213 iface_res_2.
resources.insert(
"test_joint1");
214 iface_res_2.
resources.insert(
"test_joint4");
216 start_list.push_back(controller_1);
221 controller_2.
name =
"ctrl_without_my_robot_hw_2_resources";
222 controller_2.
type =
"some_type";
225 iface_res_3.
resources.insert(
"test_joint1");
226 iface_res_3.
resources.insert(
"test_joint2");
228 start_list.push_back(controller_2);
230 ASSERT_NO_THROW(robot_hw.
doSwitch(start_list, stop_list));
234 int main(
int argc,
char** argv)
236 testing::InitGoogleTest(&argc, argv);
237 ros::init(argc, argv,
"CombinedRobotHWTestNode");
239 int ret = RUN_ALL_TESTS();
virtual bool prepareSwitch(const std::list< hardware_interface::ControllerInfo > &start_list, const std::list< hardware_interface::ControllerInfo > &stop_list)
std::set< std::string > resources
double getCommand() const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
virtual bool init(ros::NodeHandle &root_nh, ros::NodeHandle &robot_hw_nh)
int main(int argc, char **argv)
std::vector< InterfaceResources > claimed_resources
virtual void read(const ros::Time &time, const ros::Duration &period)
double getPosition() const
double getVelocity() const
JointStateHandle getHandle(const std::string &name)
virtual void doSwitch(const std::list< hardware_interface::ControllerInfo > &start_list, const std::list< hardware_interface::ControllerInfo > &stop_list)
void setCommand(double command)
TEST(CombinedRobotHWTests, combinationOk)
ROSCPP_DECL void shutdown()
virtual void write(const ros::Time &time, const ros::Duration &period)
std::string hardware_interface