Now I am in the Unit 3: TF Broadcasting and Listening.
In the example 3.2.1, I follow the steps and compile successfully.
Here is the image about script “cam_bot_odom_to_tf_pub.py” after compling with ament_cmake:
Next, I run the script with the command below:
$ ros2 run my_tf_ros2_course_pkg cam_bot_odom_to_tf_pub.py
But get the error below:
Traceback (most recent call last):
File "/opt/ros/galactic/bin/ros2", line 11, in <module>
load_entry_point('ros2cli==0.13.1', 'console_scripts', 'ros2')()
File "/opt/ros/galactic/lib/python3.8/site-packages/ros2cli/cli.py", line 67, in main
rc = extension.main(parser=parser, args=args)
File "/opt/ros/galactic/lib/python3.8/site-packages/ros2run/command/run.py", line 70, in main
return run_executable(path=path, argv=args.argv, prefix=prefix)
File "/opt/ros/galactic/lib/python3.8/site-packages/ros2run/api/__init__.py", line 61, in run_executable
process = subprocess.Popen(cmd)
File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
NotADirectoryError: [Errno 20] Not a directory: '/home/user/ros2_ws/install/my_tf_ros2_course_pkg/lib/my_tf_ros2_course_pkg/cam_bot_odom_to_tf_pub.py'
How can I solve the error? Thanks.
does this issue persist? Could you please post the contents of your
CMakeLists.txt file, I will see if I can reproduce the error to help you.
Yes, now I still have the issue.
Here is the contents of CMakeLists.txt
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
# find dependencies
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
There are a few things to try out.
From your screenshot it seems the script exists in that location. Also verify the script is executable by running this command:
An executable script will be displayed in green color.
Also try using the
ros2 run command without the
.py extension and see if that works, like this:
ros2 run my_tf_ros2_course_pkg cam_bot_odom_to_tf_pub
If non of this works a different approach is to remove the package and start all over again. This is because there might be that a step was missing during the package creation process. Normally creating a package again is not a viable option, but in this particular case since the package only contains one script that is provided to you it might be the fastest way to get it running.
Let me now how it goes,