test_slash_fiction.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import unittest
3 
4 import rospy
5 
6 from sensor_msgs.msg import JointState
7 
8 
9 class ValuesTestCase(unittest.TestCase):
11  rospy.init_node('test_joint_state_values', anonymous=True)
12  self.joint_state = None
13  rospy.Subscriber('/joint_states', JointState, self.callback_state)
14  while not self.joint_state:
15  rospy.sleep(0.1)
16 
17  # The Joint State Publisher should read the zeros parameter set in the launch file
18  # and as a result set BOTH joints' zero position to be 0.42 instead of 0.3
19 
20  # This first test checks basic functionality of the parameter
21  self.assertEqual(0.42, self.joint_state.position[0])
22 
23  # The second test checks the use case where the joint name has a slash in it
24  self.assertEqual(0.42, self.joint_state.position[1])
25 
26  def callback_state(self, state):
27  self.joint_state = state
28 
29 
30 if __name__ == '__main__':
31  import rostest
32  rostest.rosrun('joint_state_publisher', 'test_joint_states', ValuesTestCase)
test_slash_fiction.ValuesTestCase.callback_state
def callback_state(self, state)
Definition: test_slash_fiction.py:26
test_slash_fiction.ValuesTestCase.test_joint_state_values
def test_joint_state_values(self)
Definition: test_slash_fiction.py:10
test_slash_fiction.ValuesTestCase.joint_state
joint_state
Definition: test_slash_fiction.py:12
test_slash_fiction.ValuesTestCase
Definition: test_slash_fiction.py:9


joint_state_publisher
Author(s): David V. Lu!! , Jackie Kay
autogenerated on Sat Apr 12 2025 02:38:33