Cannot subscribe to own topics (in rostest)
I'm still writing integration test and I'm stuct at asimple exmaple where I want my testcase to publish a message and also subscrib to the same topic
class AdvancedTestSuite(unittest.TestCase):
def test_joint_states(self):
rospy.init_node('test_vehicle_controller', anonymous=True)
joint_state = JointState()
joint_state.name = ['lift_actor', 'wheel_main_rotation', 'wheel_main_steer']
joint_state.velocity = (0.02069770811665661, 0.0014280281623658617, 1.1028179833702783e-05)
joint_state.position = (0.9990335843981955, -0.12971652493225605, -0.0031193465124985664)
joint_state.effort = (37.26698108917237, 0.0, 0.0)
rospy.Subscriber('/my_ns/joint_states', JointState, self.callback_state)
pubA = rospy.Publisher('/my_ns/joint_states', JointState, queue_size=10)
pubA.publish(joint_state)
def callback_state(self, state):
rospy.loginfo("received " + repr(state))
if __name__ == '__main__':
import rostest
rostest.rosrun(PKG, 'test_joint_states', AdvancedTestSuite)
but nothing happens the callback is called. I can not even debug what wrong. Any Ideas ?
And just a note:
rostest
is not subscribing to anything.rostest
is just the test driver here in this case. Your code is subscribing.Suggestion: change the question title to reflect this better.
Thank you for your comment. This shows again that I dont fully understand internal ROS concepts (yet).
No problem. We're all posting here to learn.