Skip to content

Commit

Permalink
Rename client to service_client
Browse files Browse the repository at this point in the history
  • Loading branch information
IsabelParedes committed Aug 2, 2022
1 parent ece0f87 commit 2801b07
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/source/user_ros_essentials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ the following:
from rospy_tutorials.srv import AddTwoInts
rospy.init_node('service_node')
jupyros.client('service_name', AddTwoInts)
jupyros.service_client('service_name', AddTwoInts)
The generated widget will change depending on the message type being passed.

Expand Down
12 changes: 8 additions & 4 deletions jupyros/ros1/ros_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def step_clk(arg):
return vbox


def client(srv_name, srv_type):
def service_client(srv_name, srv_type):
"""
Create a form widget for message type srv_type.
This function analyzes the fields of srv_type and creates
Expand All @@ -327,7 +327,11 @@ def client(srv_name, srv_type):
@return jupyter widget for display
"""
rospy.wait_for_service(srv_name, timeout=5)
try:
rospy.wait_for_service(srv_name, timeout=5)
except rospy.ROSException:
rospy.logerr(f"Service {srv_name} is unavailable.")
return

widget_list = []
widget_dict = {}
Expand All @@ -343,7 +347,7 @@ def call_srv(arg):
service = rospy.ServiceProxy(srv_name, srv_type)
return service(msg_to_send)
except rospy.ServiceException as e:
print("Service call failed: %s" % e)
rospy.logerr(f"Service call failed: {e}")

call_btn.on_click(call_srv)

Expand Down Expand Up @@ -373,7 +377,7 @@ def action_client(action_name, action_msg, goal_msg, callbacks=None):

# Create actions client and connect to server
a_client = actionlib.SimpleActionClient(action_name, action_msg)
rospy.loginfo(f'[{action_name.upper()}]: Waiting for action server.')
rospy.loginfo(f'[{action_name.upper()}] Waiting for action server.')
server_ok = a_client.wait_for_server(timeout=rospy.Duration(5.0))
if server_ok:
rospy.loginfo(f'[{action_name.upper()}] Connection to server successful.')
Expand Down
2 changes: 1 addition & 1 deletion notebooks/ROS_Services_Clients.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"metadata": {},
"outputs": [],
"source": [
"jupyros.client('add_two_ints', AddTwoInts)"
"jupyros.service_client('add_two_ints', AddTwoInts)"
]
}
],
Expand Down

0 comments on commit 2801b07

Please sign in to comment.