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?
Originally posted by rushik on ROS Answers with karma: 31 on 2022-01-14
Post score: 1
Original comments
Comment by osilva on 2022-01-14:
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?
Comment by rushik on 2022-01-15:
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 the cmd_vel
topic.
I start the node using roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
. I then listen to what it is publishing using rostopic echo /cmd_vel
.
The only two nodes running are turtlebot3_teleop_key
and the ROS master. My problem is that on Windows, the turtlebot3_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.
Comment by osilva on 2022-01-15:
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.
Comment by rushik on 2022-01-15:
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 that getch()
is blocking. So, unless a key is pressed on the keyboard, the execution gets stuck inside getKey
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
Comment by osilva on 2022-01-16:
You could try to use pyautogui
instead.
Comment by rushik on 2022-01-16:
Thanks for your help! I got it to work by changing a few things!