I am running ROS Kinetic, on a Turtlebot3 Burger with a Raspberry Pi3.
The goal here is to remotely control the Turtlebot from another Raspberry Pi. The remote controller Pi sends movement information over a socket connection.
I have delay problems when publishing into /cmd_vel (60 seconds delay) and again delay of 60 seconds from when the Twist message is echoed in the topic /cmd_vel to when the Turtlebot starts moving. I cannot locate why this 2 x 60 seconds delay occurs. I think that I might be pushing the raspberry pi too much.
If I do the following steps: The Turtlebot3 is the ROS MASTER. 1. From remote SSH into the Raspberry Pi --> roslaunch turtlebot3_bringup turtlebot3_robot.launch 2. From remote SSH into the Raspberry Pi -- >roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
Everything works fine no delays.
When I do: The Turtlebot3 is the ROS MASTER. 1. From remote SSH into the Raspberry Pi --> roslaunch turtlebot3_bringup turtlebot3_robot.launch 2. From remote SSH into the Raspberry Pi -- >python post_office.py //python script posted below. 3. From remote SSH into the Raspberry Pi -- >rostopic echo /cmd_vel
The messages get into /cmd_vel with a 60 seconds delay. The Turtlebot3 starts moving after 120 seconds delay.
When I do: The REMOTE PC is the ROS MASTER. 1. roscore on remote pc 2. From remote SSH into the Raspberry Pi --> roslaunch turtlebot3_bringup turtlebot3_robot.launch 3. From remote SSH into the Raspberry Pi -- >python post_office.py //python script posted below. 4. Remote pc -- >rostopic echo /cmd_vel
The messages get into /cmd_vel with a 0 seconds delay. The Turtlebot3 starts moving after 35 seconds delay.
env | grep ROS gives the following when Turtlebot3 is ROS MASTER: ROS_ETC_DIR=/opt/ros/kinetic/etc/ros ROS_ROOT=/opt/ros/kinetic/share/ros ROS_MASTER_URI=http://192.168.1.39:11311 ROS_PACKAGE_PATH=/home/pi/catkin_ws/src:/opt/ros/kinetic/share ROSLISP_PACKAGE_DIRECTORIES=/home/pi/catkin_ws/devel/share/common-lisp ROS_HOSTNAME=192.168.1.39 ROS_DISTRO=kinetic
Here is the post_office.py running on the Turtlebot3.
import socket import json import rospy from geometry_msgs.msg import Twist import thread import time HOST = '' PORT = 50007 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST, PORT)) s.listen(1) conn, addr = s.accept() print ('Connected by', addr) twist = Twist() lin = 0.0 ang = 0.0 pub = rospy.Publisher('/cmd_vel', Twist, queue_size=5) #queqe size can be adjusted maybe def publish_cmd_vel(): while not rospy.is_shutdown(): #checking the rospy.is_shutdown() flag and then doing work. You have to check is_shutdown() to check if your program should exit (e.g. if there is a Ctrl-C or otherwise). twist.linear.x = lin; twist.linear.y = 0; twist.linear.z = 0 #liniar has to be .x value to change twist.angular.x = 0; twist.angular.y = 0; twist.angular.z = ang #angular has to be .z value to change try: pub.publish(twist) except: print('unable to publish') def recv_from_controller(): while True: global lin, ang move_bytes = conn.recv(1024) #receive information as bytes move_info = json.loads(move_bytes) #decode into a dictionary lin = move_info['lin'] ang = move_info['ang'] print(type(lin), lin, type(ang), ang) thread.start_new_thread( recv_from_controller, ()) rospy.init_node('post_office', anonymous = False) while True: publish_cmd_vel()
Any ideas to why I get these delays?