Rosservice doesn't show up when running server script
I'm getting a really weird error with a script I'm testing.
import logging
import os
import subprocess
import sys
import gphoto2 as gp
import rospy
from std_msgs.msg import Empty
from nav_msgs.msg import Odometry
from dense_scan.srv import capture, captureResponse # TODO: capitalize and add Message
from pdb import set_trace as bp
# import geometry_msgs.msg
# import tf.msg
def capture_img(request):
bp()
return True
if __name__ == '__main__':
rospy.init_node('capture') # make node
rospy.Service('/snap360', capture, capture_img)
rospy.spin()
when I run that script using rosrun, it basically hangs and the service doesn't get registered with ROS. But when I step through the code with pdb, as in rosrun --prefix 'python -m pdb' my_package service.py
it will run fine and shows up when I call rosservice list
. What's going on here?! Also, I removed most of the contents of the script to see where the error's coming from...
Did you put
#!/usr/bin/env python
at the top of your script? Otherwise ROS might not run it with python.