ROS入门3.1

3.1client library(客户端库)

提供ROS编程库,例如:建立node,发布消息,调用服务。
有多种版本如roscpp(c++),rospy(Python),roslisp等

3.2roscpp

https://wiki.ros.org/roscpp
在这里插入图片描述void ros::init(); //解析参数,为本node命名

ros::NodeHandle Class常用成员函数

ros::Publisher advertise(const string &topic,uint32_t queue_size); //创建topic的publisher

ros::Subscriber subscribe(const string &topic,uint_32_t queue_size,void(*)(M)); //创建topic的subscriber

ros::ServiceServer advertiseService(const string &service,bool(*srv_func)(Mreq&,Mres&)); //创建service的server

ros::ServiceClient serviceClient(const string &service_name,bool persistent=false); //创建service的client

bool getParam(const string &key, void &val); //查询某个参数的值

bool setParam(const string &key,void val); //给某个参数赋值

调用:ros::NodeHandle nh;
ros::Publiser pub = nh.advertise(参数);
pub.publish(msg);
ros::master Namespace常用函数

bool check(); //检查master是否启动

const string& getHost(); //返回master所在的hostname
bool getNodes(V_string&nodes); //从master返回已知node名称列表

bool getTopics(V_TopicInfo &topics); //返回正在被发布的topic列表

bool getURI(); //返回到master的URI地址,如http://host:port/

uint32_t getPOrt();返回mater运行在的端口

调用:ros::master::check();
在这里插入图片描述在这里插入图片描述在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值