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

Revision history [back]

Normally encoder data is published using the geometry_msgs::Twist type or the nav_msgs::Odometry type.

In your Python node you would use

from geometry_msgs.msg import Twist
...
sub_encoders = rospy.Subscriber("encoders", Twist, encoder_callback)

or

from nav_msgs.msg import Odometry
...
sub_encoders = rospy.Subscriber("encoders", Odometry, encoder_callback)

Elsewhere in your code you would create your callback function.

def encoder_callback(msg):
    # Do something with encoder data. Only use one of the lines below.
    linear_velocity = msg.linear.x # Twist
    linear_velocity = msg.twist.twist.linear.x # Odometry