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();