5 from geometry_msgs.msg
import Twist, TwistStamped
7 PKG =
'rr_control_input_manager' 12 super(TestTwistCommand, self).
__init__(*args, **kwargs)
20 test_method_name = self._testMethodName
21 subscribers = {
'test_manager_unstamped': (
'/test/outputA', Twist),
22 'test_manager_stamped': (
'/test/outputF', TwistStamped),
23 'test_latency_management_zero': (
'/test/outputG', Twist),
24 'test_latency_management_one': (
'/test/outputH', Twist),
25 'test_latency_management_less_than_zero': (
'/test/outputC', Twist)
27 publishers = {
'test_manager_unstamped': (
'/test/inputA', TwistStamped),
28 'test_manager_stamped': (
'/test/inputF', TwistStamped),
29 'test_latency_management_zero': (
'/test/inputG', TwistStamped),
30 'test_latency_management_one': (
'/test/inputH', TwistStamped),
31 'test_latency_management_less_than_zero': (
'/test/inputC', TwistStamped)
34 if test_method_name
in subscribers.keys():
35 self.
sub = rospy.Subscriber(subscribers[test_method_name][0],
36 subscribers[test_method_name][1],
39 if test_method_name
in publishers.keys():
40 self.
pub = rospy.Publisher(publishers[test_method_name][0],
41 publishers[test_method_name][1],
74 msg.header.stamp = time
75 msg.header.frame_id = frame_id
76 msg.twist.linear.x = x
77 msg.twist.linear.y = y
78 msg.twist.linear.z = z
79 msg.twist.angular.x = ax
80 msg.twist.angular.y = ay
81 msg.twist.angular.z = az
86 """Tests TwistStamped equality, disregarding header.seq. `seq` can be overwritten 87 when published and is a deprecated feature, so it left out of the equality check..""" 88 result = msg1.header.stamp == msg2.header.stamp \
89 and msg1.header.frame_id == msg2.header.frame_id \
90 and msg1.twist == msg2.twist
95 topics = [item[0]
for item
in rospy.get_published_topics()]
96 self.assertIn(
'/test/outputA', topics)
97 self.assertIn(
'/test/outputB', topics)
98 self.assertIn(
'/test/outputC', topics)
99 self.assertIn(
'/test/outputF', topics)
100 self.assertIn(
'/test/outputG', topics)
103 topics = [item[0]
for item
in rospy.get_published_topics()]
104 self.assertNotIn(
'/test/inputD', topics)
105 self.assertNotIn(
'/test/outputD', topics)
108 topics = [item[0]
for item
in rospy.get_published_topics()]
109 self.assertNotIn(
'/test/inputE', topics)
110 self.assertNotIn(
'/test/outputE', topics)
114 rate = rospy.Rate(100)
117 self.pub.publish(msg)
119 for timeout
in range(1000):
124 self.assertEqual(msg.twist, self.
msg)
127 TEST =
'test_manager_stamped' 128 rate = rospy.Rate(100)
131 self.pub.publish(msg)
133 for timeout
in range(1000):
141 rate = rospy.Rate(100)
147 self.pub.publish(msg)
149 for timeout
in range(1000):
154 self.assertEqual(msg.twist, self.
msg)
157 rate = rospy.Rate(100)
163 self.pub.publish(msg)
165 for timeout
in range(1000):
170 self.assertEqual(
None, self.
msg)
173 rate = rospy.Rate(100)
179 self.pub.publish(msg)
181 for timeout
in range(1000):
186 self.assertEqual(msg.twist, self.
msg)
189 rospy.init_node(
'test_control_input_manager_functional_test')
190 rosunit.unitrun(PKG,
'test_control_input_manager_functional', TestTwistCommand)
def test_latency_management_one(self)
def twist_stamped_eq(self, msg1, msg2)
def test_creates_proper_topics(self)
def test_bad_stamped(self)
def test_latency_management_zero(self)
def generate_twist(self, x=0, y=0, z=0, rx=0, ry=0, rz=0)
def test_manager_stamped(self)
def test_latency_management_less_than_zero(self)
def test_manager_unstamped(self)
def __init__(self, args, kwargs)
def test_bad_timeout(self)
def generate_twist_stamped(self, time, seq=0, frame_id='', x=0, y=0, z=0, ax=0, ay=0, az=0)