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
void new_callback(std_msgs::String::ConstPtr msg)

{ ClassOutsideROS obj;

   obj.callback()
void new_callback(std_msgs::String::ConstPtr msg)

You could create a class that inherits from the class outside ROS.

class Child : public OutsideROSCLass { public:
ROSChild
{ ClassOutsideROS obj;

 obj.callback()
// Parent Constructor goes here } void new_callback(std_msgs::String::ConstPtr msg) { std::string msg_string; // Do Type Conversion from std_msgs::String::ConstPtr to obj.callback(msg_string) } };

You could create a class that inherits from the class outside ROS.

class Child : public OutsideROSCLass {
public:
 public: 
ROSChild { // Parent Constructor goes here } void new_callback(std_msgs::String::ConstPtr new_callback(std_msgs::String::ConstPtr msg) { std::string msg_string; // Do Type Conversion from std_msgs::String::ConstPtr to obj.callback(msg_string) obj.callback(msg_string) } };

} };

You could create a class that inherits from the class outside ROS.

class Child : InsideROS: public OutsideROSCLass ClassOutsideROS {
public:
    ROSChild {
InsideROS{
      // Parent Constructor goes here
      }

    void new_callback(std_msgs::String::ConstPtr msg)  {
        std::string msg_string;
        // Do Perform Type Conversion from std_msgs::String::ConstPtr to
        obj.callback(msg_string)
old_callback(msg_string)
     }
};
}; 
// Register Callback
ros::NodeHandle n;
InsideROS obj;
ros::Subscriber sub = n.subscribe(topic, 1000, &InsideROS::new_callback, &obj);

But if all you need is the member function and no other properties of the class, you could just create a function. ClassOutsideROS obj_;

void new_callback(std_msgs::String::ConstPtr msg)  {  
    std::string msg_string;
   // Do Type Conversion from std_msgs::String::ConstPtr to
   obj_.callback(msg_string) 
}

You could create a class that inherits from the class outside ROS.

class InsideROS: public ClassOutsideROS {
public:
    InsideROS{
      // Parent Constructor goes here
      }

    void new_callback(std_msgs::String::ConstPtr msg)  {
        std::string msg_string;
        // Perform Type Conversion from std_msgs::String::ConstPtr to
        old_callback(msg_string)
     }
}; };

// Register Callback
ros::NodeHandle n;
InsideROS obj;
ros::Subscriber sub = n.subscribe(topic, 1000, &InsideROS::new_callback, &obj);

But if all you need is the member function and no other properties of the class, you could just create a function. ClassOutsideROS obj_;function.

ClassOutsideROS obj_;

void new_callback(std_msgs::String::ConstPtr msg)  {  
    std::string msg_string;
   // Do Type Conversion from std_msgs::String::ConstPtr to
   obj_.callback(msg_string) 
}

// Register Callback ros::NodeHandle n; InsideROS obj; ros::Subscriber sub = n.subscribe(topic, 1000, &InsideROS::new_callback, &obj);

You could create a class that inherits from the class outside ROS.

class InsideROS: public ClassOutsideROS {
public:
    InsideROS{
      // Parent Constructor goes here
      }

    void new_callback(std_msgs::String::ConstPtr msg)  {
        std::string msg_string;
        // Perform Type Conversion from std_msgs::String::ConstPtr to
        old_callback(msg_string)
     }
};

// Register Callback
ros::NodeHandle n;
InsideROS obj;
ros::Subscriber sub = n.subscribe(topic, 1000, &InsideROS::new_callback, &obj);

But if all you need is the member function and no other properties of the class, you could just create a function.

ClassOutsideROS obj_;

void new_callback(std_msgs::String::ConstPtr msg)  {  
    std::string msg_string;
   // Do Type Conversion from std_msgs::String::ConstPtr to
   obj_.callback(msg_string) 
}

void main() {

// Register Callback ros::NodeHandle n; InsideROS obj; ros::Subscriber sub = n.subscribe(topic, 1000, &InsideROS::new_callback, &obj);&obj); }

You could create a class that inherits from the class outside ROS.

class InsideROS: ClassInsideROS: public ClassOutsideROS {
public:
    InsideROS{
ClassInsideROS{
      // Parent Constructor goes here
      }

    void new_callback(std_msgs::String::ConstPtr msg)  {
        std::string msg_string;
        // Perform Type Conversion from std_msgs::String::ConstPtr to
        old_callback(msg_string)
     }
};

 void main() {
   // Register Callback
 ros::NodeHandle n;
 InsideROS obj;
 ros::Subscriber sub = n.subscribe(topic, 1000, &InsideROS::new_callback, &ClassInsideROS::new_callback, &obj);
}

But if all you need is the member function and no other properties of the class, you could just create a function.

ClassOutsideROS obj_;

void new_callback(std_msgs::String::ConstPtr msg)  {  
    std::string msg_string;
   // Do Perform Type Conversion from std_msgs::String::ConstPtr to
   obj_.callback(msg_string) 
}

void main() {

// Register Callback ros::NodeHandle n; InsideROS obj; ros::Subscriber sub = n.subscribe(topic, 1000, &InsideROS::new_callback, &ClassOutsideROS::new_callback, &obj); }

}

You could create a class that inherits from the class outside ROS.

class ClassInsideROS: public ClassOutsideROS {
public:
    ClassInsideROS{
      // Parent Constructor goes here
      }

    void new_callback(std_msgs::String::ConstPtr msg)  {
        std::string msg_string;
        // Perform Type Conversion from std_msgs::String::ConstPtr to
        old_callback(msg_string)
     }
};

 void main() {
   // Register Callback
   ros::NodeHandle n;
   InsideROS obj;
ClassInsideROSobj;
   ros::Subscriber sub = n.subscribe(topic, 1000, &ClassInsideROS::new_callback, &obj);
}

But if all you need is the member function and no other properties of the class, you could just create a function.

ClassOutsideROS obj_;

void new_callback(std_msgs::String::ConstPtr msg)  {  
    std::string msg_string;
   // Perform Type Conversion from std_msgs::String::ConstPtr to
   obj_.callback(msg_string) 
}

void main() {
  // Register Callback
   ros::NodeHandle n;
   InsideROS obj;
   ros::Subscriber sub = n.subscribe(topic, 1000, &ClassOutsideROS::new_callback, &obj);
}

You could create a class that inherits from the class outside ROS.

class ClassInsideROS: public ClassOutsideROS {
public:
    ClassInsideROS{
      // Parent Constructor goes here
      }

    void new_callback(std_msgs::String::ConstPtr msg)  {
        std::string msg_string;
        // Perform Type Conversion from std_msgs::String::ConstPtr to
        old_callback(msg_string)
     }
};

 void main() {
   // Register Callback
   ros::NodeHandle n;
   ClassInsideROSobj;
   ros::Subscriber sub = n.subscribe(topic, 1000, &ClassInsideROS::new_callback, &obj);
}

But if all you need is the member function and no other properties of the class, you could just create a function.

ClassOutsideROS obj_;

void new_callback(std_msgs::String::ConstPtr msg)  {  
    std::string msg_string;
   // Perform Type Conversion from std_msgs::String::ConstPtr to
   obj_.callback(msg_string) 
}

void main() {
  // Register Callback
   ros::NodeHandle n;
   InsideROS obj;
   ros::Subscriber sub = n.subscribe(topic, 1000, &ClassOutsideROS::new_callback, &obj);
}

From a quick glance at the ROS API, I don't think there is a way to do it implicitly. You could create a class that inherits from the class outside ROS.

class ClassInsideROS: public ClassOutsideROS {
public:
    ClassInsideROS{
      // Parent Constructor goes here
      }

    void new_callback(std_msgs::String::ConstPtr msg)  {
        std::string msg_string;
        // Perform Type Conversion from std_msgs::String::ConstPtr to
        old_callback(msg_string)
     }
};

 void main() {
   // Register Callback
   ros::NodeHandle n;
   ClassInsideROSobj;
   ros::Subscriber sub = n.subscribe(topic, 1000, &ClassInsideROS::new_callback, &obj);
}

But if all you need is the member function and no other properties of the class, you could just create a function.

ClassOutsideROS obj_;

void new_callback(std_msgs::String::ConstPtr msg)  {  
   std::string msg_string;
   // Perform Type Conversion from std_msgs::String::ConstPtr to
   obj_.callback(msg_string) 
}

void main() {
  // Register Callback
   ros::NodeHandle n;
   InsideROS obj;
   ros::Subscriber sub = n.subscribe(topic, 1000, &ClassOutsideROS::new_callback, &obj);
}

From a quick glance at the ROS API, I don't think there is a way to do it implicitly. I guess its more of a C++ function redefinition functionaility than a ROS functionaility.

You could create a class that inherits from the class outside ROS.

class ClassInsideROS: public ClassOutsideROS {
public:
    ClassInsideROS{
      // Parent Constructor goes here
      }

    void new_callback(std_msgs::String::ConstPtr msg)  {
        std::string msg_string;
        // Perform Type Conversion from std_msgs::String::ConstPtr to
        old_callback(msg_string)
     }
};

 void main() {
   // Register Callback
   ros::NodeHandle n;
   ClassInsideROSobj;
   ros::Subscriber sub = n.subscribe(topic, 1000, &ClassInsideROS::new_callback, &obj);
}

But if all you need is the member function and no other properties of the class, you could just create a function.

ClassOutsideROS obj_;

void new_callback(std_msgs::String::ConstPtr msg)  {  
   std::string msg_string;
   // Perform Type Conversion from std_msgs::String::ConstPtr to
   obj_.callback(msg_string) 
}

void main() {
  // Register Callback
   ros::NodeHandle n;
   InsideROS obj;
   ros::Subscriber sub = n.subscribe(topic, 1000, &ClassOutsideROS::new_callback, &obj);
}