rospy L2: Service and Client
参考(http://wiki.ros.org/rospy_tutorials/Tutorials/WritingServiceClient)
1环境准备
基础路径同rospy L1: Publisher and Subscriber,软件包为beginner_tutorials
2 服务文件 srv
参考(http://wiki.ros.org/ROS/Tutorials/CreatingMsgAndSrv#Creating_a_srv)
3 service节点
文件: add_two_ints_server.py
#!/usr/bin/env python
from beginner_tutorials.srv import *
import rospy
def handle_add_two_ints(req):
print "Returning [%s + %s = %s]"%(req.a, req.b, (req.a + req.b))
return AddTwoIntsResponse(req.a + req.b)
def add_two_ints_server():
rospy.init_node('add_two_ints_server')
s = rospy.Service('add_
ROS服务端与客户端实战:rospy Service和Client

这篇博客介绍了如何使用rospy在ROS中创建服务端和客户端。通过服务文件srv定义接口,分别编写service节点(add_two_ints_server.py)和服务请求客户端(add_two_ints_client.py),并演示了编译和运行过程。
最低0.47元/天 解锁文章
4161

被折叠的 条评论
为什么被折叠?



