ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
void new_callback(std_msgs::String::ConstPtr msg)
{ ClassOutsideROS obj;
obj.callback()
2 | No.2 Revision |
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) } }; 3 | No.3 Revision |
You could create a class that inherits from the class outside ROS.
class Child : public OutsideROSCLass {
public:
4 | No.4 Revision |
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)
}
5 | No.5 Revision |
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);
6 | No.6 Revision |
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);
}
7 | No.7 Revision |
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);
}
8 | No.8 Revision |
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);
}
9 | No.9 Revision |
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);
}
10 | No.10 Revision |
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);
}
11 | No.11 Revision |
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);
}