Stuck, help me. How to publish the empty when do the empty services

Hi, i got stuck here.
I want to publish drone to takeoff, i define this : pub_takeoff = rospy.Publisher('/drone/takeoff', Empty, queue_size=1)

when i do the services using rospy.Service('/my_service', Empty, my_callback)

it shows error message, is it because the empty from publisher is different from empty on services ?

from std_srvs.srv import Empty, EmptyResponse

from std_msgs.msg import Empty

Hi Billy,

Yes the name Empty will definitely conflict here. Try this:

from std_srvs.srv import EmptyResponse, Empty as EmptyServiceMsg
from std_msgs.msg import Empty

# then in your service def
 rospy.Service('/my_service', EmptyServiceMsg, my_callback)
1 Like