当前位置:网站首页>ROS21讲
ROS21讲
2022-06-28 15:04:00 【Jerry_Sea】
1 客户端Client的编程实现
参考:https://www.guyuehome.com/34660
catkin_create_pkg learning_service roscpp rospy std_msgs geometry_msgs turtlesim
//turtlesim中包含了服务数据类型turtlesim::Spawn
#include<ros/ros.h>
#include<turtlesim/Spawn.h> //服务数据类型turtlesim::Spawn
int main(int argc, char** argv)
{
ros::init(argc, argv, "turtle_spawn");//1初始化ros客户端
ros::NodeHandle node;
ros::service::waitForService("/spawn");//2查询当前系统是不是有/spawn该服务,如果没有就会一直wait。
ros::ServiceClient add_turtle = node.serviceClient<turtlesim::Spawn>("/spawn");//2如果有该服务,创建一个客户端client实例
turtlesim::Spawn srv;// 初始化turtlesim::Spawn的请求数据(封装请求数据)
srv.request.x = 2.0;
srv.request.y = 2.0;
srv.request.name = "turtle2";
ROS_INFO("Call service to spawn turtle[x:%0.6f,y:%0.6f,name:%s]", srv.request.x, srv.request.y, srv.request.name.c_str());
add_turtle.call(srv);//客户端call发布请求,请求发出去等待回馈数据,回馈成功继续
return 0;
}
target_link_libraries(turtle_spawn ${catkin_LIBRARIES})
//连接到ros的一些库
边栏推荐
- 3. caller service call - dapr
- Seata数据库中出现以下问题要怎么解决啊?
- 【空间&单细胞组学】第1期:单细胞结合空间转录组研究PDAC肿瘤微环境
- 老板嘱咐了三遍:低调、低调、低调
- Ding! Techo day Tencent technology open day arrived as scheduled!
- 一文教你快速生成MySQL数据库关系图
- 3. Caller 服务调用 - dapr
- How to solve the following problems in the Seata database?
- [MySQL learning notes 24] index design principles
- Leetcode (167) -- sum of two numbers II - input ordered array
猜你喜欢

Performance comparison of deep learning models on cat and dog image data sets

坐拥1200亿,她又要IPO敲钟了

With a return of 5000 times, the South African newspaper invested in Tencent to make a province

Mingchuangyou products passed the listing hearing: seeking dual main listing with an annual revenue of 9.1 billion

After nearly 20 years of operation, the Mars probe software based on win 98 has been upgraded for the first time

3. Caller 服务调用 - dapr

Maingene listed on the Hong Kong Stock Exchange: IPO with a market value of HK $4.3 billion was ignored by the market

Leetcode 705. Design hash collection

Youju new material rushes to Shenzhen Stock Exchange: it plans to raise 650million yuan, with an annual revenue of 333million yuan

优巨新材冲刺深交所:拟募资6.5亿 年营收3.33亿
随机推荐
猫狗图像数据集上的深度学习模型性能对比
Angers medical sprint scientific innovation board: annual revenue of RMB 300million and proposed fund raising of RMB 770million
Jackie Chan and fast brand, who is the Savior of Kwai?
美因基因港交所上市:市值43亿港元 IPO被市场忽略
智能化转型被加速,企业需要新的工具箱
PMP认证证书的续证费用是多少?
With 120billion yuan, she will ring the bell for IPO again
张同学还没学会当主播
vscode编写markdown文件并生成pdf
老板囑咐了三遍:低調、低調、低調
安杰思医学冲刺科创板:年营收3亿 拟募资7.7亿
老板嘱咐了三遍:低调、低调、低调
使用Karmada实现Helm应用的跨集群部署
[MySQL learning notes 24] index design principles
Vector explanation + topic
324. swinging sort II: not a simple construction problem
动力电池,是这样被“瓜分”的
Seata数据库中出现以下问题要怎么解决呀?
【mysql学习笔记24】索引设计原则
spacy教程(持续更新ing...)