triggerService.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import sys
00003 
00004 import rospy
00005 from std_srvs.srv import Trigger, TriggerResponse
00006 
00007 confirm_msg = "trigger received"
00008 
00009 
00010 def handle_msg(rq):
00011     print("Trigger Node got request")
00012     return TriggerResponse(success=True, message=confirm_msg)
00013 
00014 
00015 def trigger_server():
00016     args = rospy.myargv(argv=sys.argv)
00017     node_name = args[1] if len(args) > 1 else 'trigger_node'
00018 
00019     rospy.init_node(node_name)
00020     rospy.set_param('/test/confirm_param', confirm_msg)
00021     srv = rospy.Service('/test/trgsrv', Trigger, handle_msg)
00022     rospy.spin()
00023     if rospy.has_param('/test/confirm_param'):
00024         rospy.delete_param('/test/confirm_param')
00025 
00026 
00027 if __name__ == '__main__':
00028     trigger_server()


pyros_test
Author(s): AlexV
autogenerated on Sat Jun 8 2019 20:51:06