_ConfigClient.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 (mostly) the `ifm3d config` command but communicates through the ROS
18 graph
19 """
20 
21 import json
22 import rospy
23 import sys
24 from ifm3d.srv import Config
25 
26 SRV_TIMEOUT = 2.0 # seconds
27 SRV_NAME = "/ifm3d/camera/Config"
28 
29 class ConfigClient(object):
30 
31  def __init__(self):
32  rospy.init_node('ifm3d_config_client')
33 
34  def run(self):
35  j = json.load(sys.stdin)
36  rospy.wait_for_service(SRV_NAME, timeout=SRV_TIMEOUT)
37  proxy = rospy.ServiceProxy(SRV_NAME, Config)
38  resp = proxy(json.dumps(j))
39  if resp.status != 0:
40  print("Error: %s - %s" % (str(resp.status), resp.msg))
41 
42  return resp.status


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