Callback function not updating values (Rospy)
I have a program used to read in command velocities from two sources (teleop/navigation), blend them, and then publish the blended velocity to the Turtlebot. While debugging, I noticed that the code never reaches the callback functions and thus, does not update any of the values I need to read in. I have the following:
class BSCFun:
def __init__(self):
# Init Node
rospy.init_node('BSCFun', anonymous=True, log_level=rospy.DEBUG);
self.pub = rospy.Publisher('/mobile_base/commands/velocity', Twist, queue_size=100);
# ROS Subscribers
self.odomSub = rospy.Subscriber('/odom', Odometry, self.odomCallback);
self.goalSub = rospy.Subscriber('/move_base/current_goal', PoseStamped, self.goalCallback)
self.velSub = rospy.Subscriber('/cmd_vel_mux/input/navi', Twist, self.optCmdCallback)
self.teleSub = rospy.Subscriber('/cmd_vel_mux/input/teleop', Twist, self.userCmdCallback);
self.rate = rospy.Rate(5);
# Main Loop
while not rospy.is_shutdown():
self.BSCFun1();
def BSCFun1(self):
# do stuff and get a 'newVelocity'
vMsg = Twist();
vMsg.angular.z = newVelocity;
self.pub.publish(vMsg);
self.rate.sleep();
def userCmdCallback(self, msg):
self.xVelUser= msg.linear.x;
self.wzVelUser = msg.angular.z;
def optCmdCallback(self, msg):
self.xVel = msg.linear.x;
self.wzVel = msg.angular.z;
rospy.loginfo("Updating Opt. Cmd.");
and a bunch of other callbacks.
if __name__ == '__main__':
try:
bsc = BSCFun();
except rospy.ROSInterruptException:
pass
I use the data from the callbacks in BSCFun1()
to calculate a newVelocity
and publish accordingly, but the values are not updating and all I get are zeros (the values my variables are initialized in. What seems to be the problem?