Calling another class object member function in a ROS cpp node
Hi below is the code, how do i create object, initialize and call my B class object member function inside the rosnode point_callback function as below is my structure ?.
"in A.h header file"
class A{
public:
A(){};
virtual ~A(){};
virtual float dosomething(int a) = 0;
};
"in B.h header file"
class B: public A{
public:
B(){};
virtual ~B(){};
virtual float dosomething(int a ) override;
};
"In B.cpp header file"
"include B.h"
float B::dosomething(int a){
//some code
return b;
}
"in test_ros_node.cpp"
include "B.h"
class TestROSNode{
private:
ros::Subscriber ik_sub;
public:
IKnode(ros::NodeHandle *nh){
ik_sub = nh->subscribe("/testpoint", 1000, &TestROSNode::point_callback, this);
}
void point_callback(const geometry_msgs::Point::ConstPtr& msg){
//some code
// I WANT TO ACCESS THE B CLASS dosomething(int a ) function here (how should i and where should i initialize the object and access the function here? )
}
}
int main(){
ros::init(argc, argv, "IKnode");
ros::NodeHandle nh;
TestROSNode ik_node = TestROSNode(&nh);
ros::spin();
return 0;
}