-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from ihuicatl/main
Add ROS service/client widget
- Loading branch information
Showing
2 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "3b12ee9d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%load_ext autoreload\n", | ||
"%autoreload 2\n", | ||
"\n", | ||
"import rospy\n", | ||
"from rospy_tutorials.srv import AddTwoInts, AddTwoIntsResponse\n", | ||
"import jupyros\n", | ||
"from turtlesim.srv import Spawn" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e2d89970", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"rospy.init_node(\"adder\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "8725d5f8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def handle_add_two_ints(req):\n", | ||
" print(\"Returning [%s + %s = %s]\"%(req.a, req.b, (req.a + req.b)))\n", | ||
" return AddTwoIntsResponse(req.a + req.b)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f218a9a6", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%%thread_cell\n", | ||
"\n", | ||
"srv = rospy.Service('add_two_ints', AddTwoInts, handle_add_two_ints)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "cc3df77b", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"jupyros.client('add_two_ints', AddTwoInts)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0b94e2ad", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# !rosrun turtlesim turtlesim_node" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "539a6cac", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"jupyros.client('spawn', Spawn)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |