Why does turtlebot3_teleop behave differently on Windows and Linux?
I have ROS Noetic installed on a Windows 10 PC and a Linux (Ubuntu 20.04) PC, both with the turtlebot3_teleop
package.
On Windows 10, when I run
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
and echo the /cmd_vel
topic using rostopic echo /cmd_vel
, I see no messages. When I press a key, say w
, to send out a Twist command, I see a single message:
linear:
x: 0.005
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0
On Linux, as soon as I run the roslaunch
command, the message
linear:
x: 0.005
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0
is repeatedly echoed at around 10 Hz. When I press a key, say w
, to send out a Twist command, I see the message
linear:
x: 0.005
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0
also repeated at around 10 Hz.
Why does the node behave differently on the different operating systems?
Hi @rushik, can you please explain what installation did you use for Windows 10? Also are you comparing simulations or working with the actual turtlebot3? Finally can you show the steps for launching teleop for Windows10?
Hi @osilva, I am using the ROS Noetic installation instructions from this ROS Wiki page. I am installing Turtlebot3 packages on my Windows 10 PC using the Windows section of this page on the Robotis e-Manual.
I am neither simulating the robot, nor working with the actual robot. I am simply comparing what the
turtlebot3_teleop_key
node publishes on thecmd_vel
topic.I start the node using
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
. I then listen to what it is publishing usingrostopic echo /cmd_vel
.The only two nodes running are
turtlebot3_teleop_key
and the ROS master. My problem is that on Windows, theturtlebot3_teleop_key
node publishes a single message per key press. On Linux, it repeats the messages at 10Hz. I need the Windows behavior to match the Linux behavior.Thank you @rushik for all these details. I will reproduce this test and see if I can find something and report back. I have both setups as well.
I found the problem, but I am not sure how to fix it. The Windows implementation of the
getKey
function in the python code is this:if os.name == 'nt': if sys.version_info[0] >= 3: return msvcrt.getch().decode() else: return msvcrt.getch()
The problem is thatgetch()
is blocking. So, unless a key is pressed on the keyboard, the execution gets stuck insidegetKey
and the while loop on line 144 only publishes once per keypress.The Linux implementation includes a 0.1 second timeout, the windows implementation does not. I tried
You could try to use
pyautogui
instead.Thanks for your help! I got it to work by changing a few things!