I am working on exercise 2.2 and to complete the exercise I have done the following:
-
created a package using the command catkin_create_pkg print_odometery rospy within catkin_ws/src
-
made new directory called launch and created a file called odometery.launch with the appropriate elements and
-
within the src folder of the package created a file called print_odometery.py with the following code:
#! /usr/bin/env/ python
import rospy
from nav_msgs.msg import Odometery
def callback(msg):
print msg.data
rospy.init_node(‘print_odometery’)
sub = rospy.Subscriber(’/odom’, Odometery, callback)
rospy.spin()
-
I next executed the command roscd and then cd …/ to get to the directory catkin_ws and ran the command catkin_make --only-pkg-with-deps print_odometery and the build was successful.
When I attempt to do a roslaunch print_odometery odometery.launch an error is thrown:
unable to launch [/home/user/catkin_ws/src/print_odometery/src/print_odometery.py __name:=print_odometery __log:=/home/user/.ros/log/2a35627e-62a3-11ea-8229-021d58f227a9/print_odometery-1.log]: Not a directory
I did make sure the file print_odometery was executable with the command chmod +x /path/to/python_file however, the same error continues. I was able to obtain a print out of the log that provided a more detailed description of the error and can provide it if needed. My question is How do I resolve the error and what is causing the error?
Hi @meddy672,
Thanks for contacting us and welcome to the Community!
It seems that something is wrong with your launch file. Check if you can run your package with:
rosrun print_odometery print_odometery.py
If not, then something is wrong the with launch file.
That said, something else is wrong with your package - you misspelled “odometry” as “odometery”. While this does not matter as far as file and folder names are concerned, this line in your python file will not work, because there’s no message called Odometery
.
from nav_msgs.msg import Odometery # will not work
It needs to be
from nav_msgs.msg import Odometry
Please check these points and let us know.
I think one issue is due to the fact that I named my python file the same as my package. This seems to cause issues when using python. Another issues is that it seems to have a problem with the name of the node that is to launch my python file. It continues to refer to it as a directory as in the print out above unable to launch … Not a directory. This name is referring to the name used in rospy.init_node
Make sure you double and triplecheck the names. To make sure, copy the filename and paste it into the launch file. Happened to me countless times, that a little typo screwed things up. Just like odometry and odometery. On a glance they look the same, but they are not.
I believe I have found the issue. The reason for the error is due to the fact that I wasn’t running the roslaunch –launchfile within the catkin_ws/devel directory. When I run the roslaunch command within this directory the program works. Is this where all roslaunch commands are ran?
Hi @meddy672,
No, roslaunch should work from any directory if you have setup and compiled your package correctly.
Can you share the contents of your launch file?
I am having the same error
unable to launch [/home/user/catkin_ws/src/exercise_2_2/src/odometry.py __name:=robot_node __log:=/home/user/.ros/log/68ffa530-6aca-11ea-a162-1650978c4d7f/robot_node-1.log]: Not a directory
The traceback for the exception was written to the log file
launch file
I used the same similar code listed above
it seems to be some mistake with the node, but the problem may arise due to me changing the name of the package at one point.
name of the package is defined in the MakeLists.txt and package.xml. If you change a package name, you have to change it there and recompile. Changing the folder name does not change the package name.
I changed the names in the makelist.txt and the package.xml, also recompiled.
I still get the error were:
Not a directory
The traceback for the exception was written to the log file
error:
unable to launch [/home/user/catkin_ws/src/exercise_2_2/src/odometry.py __name:=robot_node __log:=/home/user/.ros/log/94bc8ad2-6ae6-11ea-8923-0a38337c7343/robot_node-1.log]: Not a directory
The traceback for the exception was written to the log file
You made the script executable?
Do you mean the python file? if so yes it is executable.
And you sourced the setup.bash after compiling?
Hi @mccannm,
Since you are just starting to learn ROS, we do not recommend things like changing package name or copy/pasting packages and you can easily run into troubles like this. It’s better and faster to just create a new package from scratch and copy in the sources files you need.
So in this case I will recommend that you back up the source files, delete the current package and then create a new one, carefully following the examples given.