ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Personally, using kind a fixed Major's version:

class ROSCommonNode
{
    ROSBaseNode(int argc, char **argv, const char *node_name)
    {
        ros::init(argc, argv, node_name);
    }
};

class ROSCommonWorker : ROSCommonNode
{
public:
    ROSCommonWorker(int argc, char **argv, const char *node_name) : ROSBaseNode(argc, argv, node_name)
    {
        //register some common publishers/subscribers or deal with global param service, whatever
    }

private:
    ros::NodeHandle node_handle;
};

Motivation: couple of duplicated lines of code saved, also centralized way of changing how all of my common nodes/services/workers/etc. works with logging/dealing with parameters/etc.

Personally, using kind a fixed Major's version:

class ROSCommonNode
{
protected:
 ROSBaseNode(int ROSCommonNode(int argc, char **argv, const char *node_name)
    {
        ros::init(argc, argv, node_name);
    }
};

class ROSCommonWorker : ROSCommonNode
{
public:
    ROSCommonWorker(int argc, char **argv, const char *node_name) : ROSBaseNode(argc, argv, node_name)
    {
        //register some common publishers/subscribers or deal with global param service, whatever
    }

private:
    ros::NodeHandle node_handle;
};

Motivation: couple of duplicated lines of code saved, also centralized way of changing how all of my common nodes/services/workers/etc. works with logging/dealing with parameters/etc.