There is a problem of'Couldn't find executable named teleop_twist_keyboard.py'. Having examed the package,the package was installed correctly.I have tried to edit the CMakeLists.txt file,but the file is read only.
1 Answer
- Source you environment
source /opt/ros/melodic/setup.bash
- Try running without .py
rosrun teleop_twist_keyboard teleop_twist_keyboard
It should work most probably else try running this:
rospack list | grep teleop_twist_keyboard
if you don't see anything its probably not installed properly.
UPDATE:
The issue is with this command sudo ln -s /usr/bin/python3 /usr/bin/python
, it creates a symlink between python and python3. But ROS melodic requires python2 not python 3. so you need to remove the symlink then install python 2 and create a symlink with python 2 and then run it again. I'll write the commands you need to follow.
sudo rm /usr/bin/python
to remove the symlink from python to python 3sudo apt install python2.7
check your/usr/bin/
directory if python2 present skip to next step.sudo ln -s /usr/bin/python2 /usr/bin/python
creates symlink with python2source /opt/ros/melodic/setup.bash
source your ros env.rosrun teleop_twist_keyboard teleop_twist_keyboard.py
EXTRA:
user:~$ rosrun teleop_twist_keyboard teleop_twist_keyboard.py
Waiting for subscriber to connect to /cmd_vel
^CGot shutdown request before subscribers connected
user:~$ sudo ln -s /usr/bin/python3 /usr/bin/python
ln: failed to create symbolic link '/usr/bin/python': File exists
user:~$ sudo rm /usr/bin/python
user:~$ sudo ln -s /usr/bin/python3 /usr/bin/python
user:~$ rosrun teleop_twist_keyboard teleop_twist_keyboard.py
[rosrun] Couldn't find executable named teleop_twist_keyboard.py below /opt/ros/melodic/share/teleop_
twist_keyboard
user:~$ rospack list | grep teleop_twist_keyboard
teleop_twist_keyboard /opt/ros/melodic/share/teleop_twist_keyboard
user:~$ sudo rm /usr/bin/python
user:~$ sudo ln -s /usr/bin/python2 /usr/bin/python
user:~$ rosrun teleop_twist_keyboard teleop_twist_keyboard.py
Waiting for subscriber to connect to /cmd_vel
Waiting for subscriber to connect to /cmd_vel
-
$\begingroup$ Thank you for your answers! I followed the 2 steps you suggest. Unfortunately,I failed.Then I run the pack list order,it showed that "teleop_twist_keyboard /opt/ros/melodic/share/teleop_twist_keyboard".I cannot make head of it $\endgroup$– yz xCommented Feb 26 at 2:13
-
$\begingroup$ I have updated the answer try it. It should work now. $\endgroup$– nitishCommented Feb 26 at 5:37
-
$\begingroup$ Thank you for all your assistance!I really learned a lot! $\endgroup$– yz xCommented Feb 26 at 12:24