ROS Python Package - cannot import name main

asked 2018-08-05 23:59:23 -0500

hillripper21 gravatar image

updated 2018-08-06 12:04:35 -0500

jayess gravatar image

I've tried everything possible I've seen on the forum with no luck. I have a simple package that will not run properly. ROS Kinetic on Ubuntu 16.04

The format is as follows: src/stitcher which contains a folder nodes with an executable named driver:

#!/usr/bin/env python

print "importing main from Python package stitcher in driver"
from stitcher import main
print "imported main from Python package stitcher in driver"

if __name__ == '__main__':
    print "executing main() in driver"
    main()

Then in /src/stitcher I have my __init__.py and stitch.py which has the main function

__init__.py just has: from stitch import main

And stitch.py has all my logic with a main function at the end (I won't post all the logic before the main):

def main():
    print " executing main() in stitch.py"
    img1 = cv2.imread('/home/tibi/catkin_ws/src/stitcher/testImages/pan2.jpeg')
    img2 = cv2.imread('/home/tibi/catkin_ws/src/stitcher/testImages/pan1.jpeg')

    img1 = equalize_histogram_color(img1)
    img2 = equalize_histogram_color(img2)

    M =  get_sift_homography(img1, img2)

    result_image = get_stitched_image(img2, img1, M)

    cv2.imshow ('Result', result_image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

if __name__ == '__main__':
    main()

I followed the structure outlined here: http://www.artificialhumancompanions.... to the letter essentially, I cloned his code and it works fine which I don't get. My setup.py, CMake and package.xml are also identical. I went through file by file to make sure all the imports and stuff were the same. I've made sure i dont have the duplicate python packages in usr/local already.

Any help would be appreciated, sorry about weird formatting not sure how to fix but all the stuff in main is indented regularly. All the bold stuff should have __ around them

edit retag flag offensive close merge delete

Comments

I've tried everything possible I've seen on the forum with no luck

What have you tried? What were the results? Can you please update your question with the full error?

jayess gravatar image jayess  ( 2018-08-06 12:02:19 -0500 )edit