当前位置:网站首页>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的一些库
边栏推荐
- R语言ggplot2可视化:使用patchwork包(直接使用加号+)将一个ggplot2可视化结果和一个plot函数可视化结果横向组合起来形成最终结果图、将两个可视的组合结果对齐
- 笔试面试算法经典–最长回文子串
- Vscode writes markdown file and generates pdf
- Which is safer, a securities company or a bank? How to open an account is the safest
- [C language] how to implement plural types
- 腾讯再遭大股东Prosus减持:后者还从京东套现37亿美元
- Rails进阶——框架理论认知与构建方案建设(一)
- PostgreSQL实现按年、月、日、周、时、分、秒的分组统计
- Jingyuan's safe sprint to the Growth Enterprise Market: it plans to raise 400million yuan for investment and Yunyou software is the shareholder
- How does Seata server 1.5.0 support mysql8.0?
猜你喜欢
一文教你快速生成MySQL数据库关系图
Leetcode 48. Rotate image (yes, resolved)
MySQL主从切换的超详细步骤
Halcon basic summary (I) cutting pictures and rotating images
Kwai investment e-commerce service provider Yixin optimization
Softing epgate Pb series Gateway - integrates the Profibus bus into the ethernet/ip network
dolphinscheduler2.X的安装(亲测有效)
新零售线下店逆势起飞,通膨乌云下的消费热情
[spatial & single cellomics] phase 1: Study on PDAC tumor microenvironment by single cell binding spatial transcriptome
[C language] nextday problem
随机推荐
324. swinging sort II: not a simple construction problem
R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用回归系数及其标准误计算每个系数对应的Z统计量的值
【数字IC精品文章收录】近500篇文章|学习路线|基础知识|接口|总线|脚本语言|芯片求职|安全|EDA|工具|低功耗设计|Verilog|低功耗|STA|设计|验证|FPGA|架构|AMBA|书籍|
Seata数据库中出现以下问题要怎么解决呀?
Jackie Chan and fast brand, who is the Savior of Kwai?
一文教你快速生成MySQL数据库关系图
兼顾企业抗疫和发展的5个解决方案,来自IBM
第四大运营商,难成「鲶鱼」
seata-server 1.5.0 如何支持mysql8.0?
成龙和快品牌,谁才是快手的救星?
解决Unable to create process using ‘D:\Program File
动力电池,是这样被“瓜分”的
Case driven: a detailed guide from getting started to mastering shell programming
Softing epGate PB系列网关-可将PROFIBUS总线集成到EtherNet/IP网络
Vscode writes markdown file and generates pdf
验证回文串
Leetcode (167) -- sum of two numbers II - input ordered array
Leetcode (665) -- non decreasing column
2022年最新PyCharm激活破解码永久_详细安装教程(适用多版本)
Not being a meta universe now is like not buying a house 20 years ago!