def setHikZoomAndFocus_Pub(): # init node rospy.init_node('setHikZoomAndFocus_Pub', anonymous=True) pub = rospy.Publisher('setHikZoomAndFocus', hikInfo, queue_size=10) rate = rospy.Rate(0.2) hk = hikInfo() hk.zoom = 0 # min: 0 max: 16381 hk.focus = 49153 # min: 4096 max: 49152 hk.taskID = '123' hk.deviceID = '158' while not rospy.is_shutdown(): try: # send pub.publish(hk) rospy.loginfo('send msg to the topic: %s', 'setHikZoomAndFocus') rate.sleep() except rospy.ROSException as e: rospy.logerr('%s', e)
from dg_msgs.srv import getHikImg from dg_msgs.msg import hikInfo def hi_pic_client(hk, isInfrared): rospy.wait_for_service('hik_pic',10) try: # create a handle to the add_two_ints service hi_pic_handle = rospy.ServiceProxy('hik_pic', getHikImg) rospy.loginfo("Requesting %s",hk) resp1 = hi_pic_handle(hk, isInfrared) return resp1.state rospy.loginfo('return creamra state is: ', resp1.state) except rospy.ServiceException, e: print 'Service call failed: %s'%e if __name__ == '__main__': hk = hikInfo() hk.zoom = 99 hk.focus = 31421 # min:4096 hk.taskID = 'd630a1f488af4aa2a4d5f366a0494fd6' hk.deviceID = '4b43b0aee35624cd95b910189b3dc231' isInfrared = False hi_pic_client(hk,isInfrared)
from dg_msgs.msg import hikInfo def hi_pic_client(hk, isInfrared): rospy.wait_for_service('hik_pic', 10) try: # create a handle to the add_two_ints service hi_pic_handle = rospy.ServiceProxy('hik_pic', getHikImg) rospy.loginfo("Requesting %s", hk) resp1 = hi_pic_handle(hk, isInfrared) return resp1.state rospy.loginfo('return creamra state is: ', resp1.state) except rospy.ServiceException, e: print 'Service call failed: %s' % e if __name__ == '__main__': hk = hikInfo() hk.zoom = 99 hk.focus = 31421 # min:4096 hk.taskID = 'd630a1f488af4aa2a4d5f366a0494fd6' hk.deviceID = '4b43b0aee35624cd95b910189b3dc231' isInfrared = False hi_pic_client(hk, isInfrared)