How does "rosrun teleop_twist_keyboard teleop_twist_keyboard.py" work?

First of all, I had no trouble running the command
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
and flying the drone around.

However, afrerwards I tried to check out the teleop_twist_keyboard.py file.
I used the commands
roscd teleop_twist_keyboard
find .

The absolute path of the package was /opt/ros/kinetic/share/teleop_twist_keyboard
I didn’t find the teleop_twist_keyboard.py anywhere in the package.

Instead the find command result was:
.
./package.xml
./cmake
./cmake/teleop_twist_keyboardConfig-version.cmake
./cmake/teleop_twist_keyboardConfig.cmake

Running the command:
find / -name teleop_twist_keyboard.py
I found out that the file exists in the location /opt/ros/kinetic/lib/teleop_twist_keyboard/teleop_twist_keyboard.py

So, I am wondering how the rosrun command works.
What I had in mind was that rosrun would run an executable with the specified name inside the specified package. (as we did in previous units with script executables)

P.S. This is my first post, so hello to the community. I am really excited about the course. The content is excellent. Thank you.

Hi @NikosSoulounias,

Welcome to the community and thanks for your compliments!

roscd is obviously picking the first package, while rosrun is picking the second because it couldn’t find anything in the first, and the second one is also the package and has the python file we are looking for.

1 Like