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

Revision history [back]

click to hide/show revision 1
initial version

This is a Python problem, not a ROS one.

def scaleWheel():
    [..]

    lscaled_pub = rospy.Publisher("lwheel_scaled", Int16, queue_size=10)
    rscaled_pub = rospy.Publisher("rwheel_scaled", Int16, queue_size=10) 

    [..]

def lwheelCallback(msg):
    lscaled_pub.publish( msg.data * -1 * scale)

def rwheelCallback(msg):
    rscaled_pub.publish( msg.data * -1 * scale)

The cause here is the fact that lscaled_pub and rscaled_pub are variables local to scaleWheel.

You cannot refer to them in other methods as those variables are not defined in a scope that contains both scaleWheel and lscaled_pub and rscaled_pub.