_DumpClient.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2018 ifm electronic, gmbh
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distribted on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 """
17 Mimics the `ifm3d dump` command but communicates through the ROS graph
18 """
19 
20 import json
21 import rospy
22 import sys
23 from ifm3d.srv import Dump
24 
25 SRV_TIMEOUT = 2.0 # seconds
26 SRV_NAME = "/ifm3d/camera/Dump"
27 
28 class DumpClient(object):
29 
30  def __init__(self):
31  rospy.init_node('ifm3d_dump_client')
32 
33  def run(self):
34  rospy.wait_for_service(SRV_NAME, timeout=SRV_TIMEOUT)
35  proxy = rospy.ServiceProxy(SRV_NAME, Dump)
36  resp = proxy()
37  if resp.status == 0:
38  print(json.dumps(json.loads(resp.config),
39  sort_keys=True, indent=4, separators=(',', ': ')))
40  else:
41  sys.stderr.write("Dump failed with error: %s - %s\n" %
42  (str(resp.status),
43  "Check the `ifm3d' logs for more detail"))
44 
45  return resp.status


ifm3d
Author(s): Tom Panzarella
autogenerated on Thu Feb 4 2021 03:23:54