how to subscriber from /diagnastic
Hi All, Please help me for how to subscriber from /diagnastic according levels(OK , WARN , ERROR). below my example code ...
Example :
DiagnosticSubscriber::DiagnosticSubscriber()
{
cout<<"Constructor calling"<<endl;
}
void DiagnosticSubscriber::msgCallback(const diagnostic_msgs::DiagnosticStatus::ConstPtr& DiagnosticStatusmsg)
{
cout<<"msgCallback calling"<<endl;
ROS_INFO("CPP Subscriber ");
}
void DiagnosticSubscriber::display()
{
cout<<"display calling"<<endl;
sub = nh.subscribe("/diagnostics",1,&DiagnosticSubscriber::msgCallback,this);
}
int main(int argc , char **argv)
{
ros::init(argc,argv,"DiagnosticSubscriber");
DiagnosticSubscriber obj;
obj.display();
ros::spin();
return 0;
}
It looks like you're written the basic subscriber.
yes , its basic subscriber .. is there any other idea please give me answer ....
Thanks very much u r responses.
I don't understand what your question is. You asked how to write a subscriber but you have written the subscriber.
yes sir i have written code for subscriber . Using /diagnastic topic i am publishing three levels like Ok , warn , error . my gole is the write code for subscriber on topic /diagnostic so if i code get any warn or error / ok .. but is not working .
is this code is worng way or if you have have better solution .. please shared with me ..
Thanks