当前位置:网站首页>Nodehandle common member functions

Nodehandle common member functions

2022-06-25 08:16:00 N1CROWN

NodeHandle Common member functions include :

  1. To create a topic publisher
    ros::Publisher advertise(const string &topic,uint32_t queue_size, bool latch=false);
    // The first parameter is the name of the publishing topic
    // The second is the maximum length of the message queue , If the published message exceeds this length and is not received , Then the news will be out of the team . It is usually set as a
    A smaller number is enough .
    // The third parameter is whether to latch . Some topics are not published at a certain frequency , such as /map This topic, Only for initial subscription or map update
    Under different circumstances ,/map Will release the news . The latch is used here .

  2. To create a topic subscriber
    ros::Subscriber subscribe(const string &topic,uint32_t queue_size, void(*)(M));
    // The first parameter is the name of the subscription topic
    // The second parameter is the length of the subscription queue , If the received message is not handled in time , So new news joins the team , As soon as the news comes out
    // The third parameter is the callback function pointer , Point to the callback function to process the received message

  3. Service creation server, Provide services
    ros::ServiceServer advertiseService(const string &service, bool(*srv_func)(Mreq &, Mres &));
    // The first parameter is service name
    // The second parameter is the pointer to the service function , Point to the service function . The function pointed to should have two arguments , Accept requests and responses separately .

  4. Service creation client
    ros::ServiceClient serviceClient(const string&service_name, bool persistent=false);
    // The first functional expression service name
    // The second parameter is used to set whether the service connection lasts , If true,client Will remain connected to the remote host , This will make subsequent requests faster . Usually we set flase

  5. Query the value of a parameter
    bool getParam(const string &key, std::string &s);
    boolgetParam (const std::string &key, double &d) const;
    bool getParam(const std::string &key, int &i) const;
    // Get... From the parameter server key Corresponding value , Multiple types have been overloaded

  6. Assign parameters
    void setParam (const std::string &key, const std::string &s)const;
    void setParam (const std::string &key, const char *s) const;
    void setParam (const std::string &key, int i) const;
    // to key Corresponding val assignment , Overloaded multiple types of val

原网站

版权声明
本文为[N1CROWN]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202200557409541.html