ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Quick summary:

  • Every time a message is published on the keys topic, the keys_cb callback is triggered, and the argument msg contains that latest message
  • Based on the data in the latest keys message, the keys_cb updates the value of the global variable g_last_twist.
  • The while loop you referenced runs at a rate of 10Hz and continually publishes the value of g_last_twist
  • The callback keys_cb is also passed a reference to the twist_pub publisher via the callback_args keyword argument in the constructor for a rospy.Subscriber. The callback also publishes the latest value of g_last_twist using its reference to the twist_pub-- presumably so you don't need to wait until the next iteration of the main while loop to get the value published.