I am using a Roboclaw Motor Controller which I control using software I have taken from Github and modified. I am publishing Twist messages using teleop_twist_joy. This works fine when I have the line rospy.loginfo("") in my cmd_vel callback but when I remove the loginfo I get latencies and generally weird behavior. For example the robot will stand still for a while before starting to move and it will also keep moving after I release the joypad activation button.
I have a callback on cmd_vel which looks like this:
def cmd_vel_callback(self, twist):
if not self.paused:
self.last_set_speed_time = rospy.get_rostime()
linear_x = twist.linear.x
if linear_x > self.MAX_SPEED: linear_x = self.MAX_SPEED
if linear_x < -self.MAX_SPEED: linear_x = -self.MAX_SPEED
Vr = linear_x + twist.angular.z*self.BASE_WIDTH/2.0 # m/s
Vl = linear_x - twist.angular.z*self.BASE_WIDTH/2.0
Vr_ticks = int(Vr * self.TICKS_PER_METER) # ticks/s
Vl_ticks = int(Vl * self.TICKS_PER_METER)
rospy.loginfo("")
self.roboclaw.SetSpeed(Vl_ticks,Vr_ticks)
Notice the line rospy.loginfo(""), when I comment this things stop working. To make things work I can either uncomment that line again or have a second callback like this:
def cmd_vel_log_callback(self, twist):
rospy.loginfo("")
The code for subscribing that I use is:
rospy.Subscriber('cmd_vel', Twist, self.cmd_vel_callback)
rospy.Subscriber('cmd_vel', Twist, self.cmd_vel_log_callback)
This is of course unsatisfactory and I would like to understand how I can get things working without the extra rospy.loginfo("").
I am using melodic on Ubuntu 18.04.2 LTS.
Originally posted by robotjohan on ROS Answers with karma: 15 on 2019-04-25
Post score: 0