30 import geometry_msgs.msg
31 import sensor_msgs.msg
37 rospy.init_node(
'test_joy_twist_node', anonymous=
True)
38 self.
pub = rospy.Publisher(
'joy', sensor_msgs.msg.Joy)
39 rospy.Subscriber(
'cmd_vel', geometry_msgs.msg.Twist, callback=self.
callback)
41 while (
not rospy.has_param(
"~publish_joy"))
and (
not rospy.get_param(
"~expect_cmd_vel")):
45 self.
joy_msg = rospy.get_param(
"~publish_joy")
49 pub_joy = sensor_msgs.msg.Joy()
50 pub_joy.axes.extend(self.
joy_msg[
'axes'])
51 pub_joy.buttons.extend(self.
joy_msg[
'buttons'])
53 self.pub.publish(pub_joy)
56 self.assertAlmostEqual(self.received_cmd_vel.linear.x, self.
expect_cmd_vel[
'linear'][
'x'])
57 self.assertAlmostEqual(self.received_cmd_vel.linear.y, self.
expect_cmd_vel[
'linear'][
'y'])
58 self.assertAlmostEqual(self.received_cmd_vel.linear.z, self.
expect_cmd_vel[
'linear'][
'z'])
59 self.assertAlmostEqual(self.received_cmd_vel.angular.x, self.
expect_cmd_vel[
'angular'][
'x'])
60 self.assertAlmostEqual(self.received_cmd_vel.angular.y, self.
expect_cmd_vel[
'angular'][
'y'])
61 self.assertAlmostEqual(self.received_cmd_vel.angular.z, self.
expect_cmd_vel[
'angular'][
'z'])
68 if __name__ ==
'__main__':
69 rostest.rosrun(
'teleop_twist_joy',
'test_joy_twist', TestJoyTwist)