_DumpClient.py
Go to the documentation of this file.
1 # SPDX-License-Identifier: Apache-2.0
2 # Copyright (C) 2021 ifm electronic, gmbh
3 
4 """
5 Mimics the `ifm3d dump` command but communicates through the ROS graph
6 """
7 
8 import json
9 import rospy
10 import sys
11 from ifm3d_ros_msgs.srv import Dump
12 
13 SRV_TIMEOUT = 2.0 # seconds
14 SRV_NAME = "/ifm3d_ros_examples/camera/Dump"
15 
16 class DumpClient(object):
17 
18  def __init__(self):
19  rospy.init_node('ifm3d_dump_client')
20 
21  def run(self):
22  rospy.wait_for_service(SRV_NAME, timeout=SRV_TIMEOUT)
23  proxy = rospy.ServiceProxy(SRV_NAME, Dump)
24  resp = proxy()
25  if resp.status == 0:
26  print(json.dumps(json.loads(resp.config),
27  sort_keys=True, indent=4, separators=(',', ': ')))
28  else:
29  sys.stderr.write("Dump failed with error: %s - %s\n" %
30  (str(resp.status),
31  "Check the `ifm3d' logs for more detail"))
32 
33  return resp.status


ifm3d_ros_msgs
Author(s): CSR ifm sytron
autogenerated on Tue Feb 21 2023 03:13:24