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;
}
Asked by RaoBrother on 2017-07-01 21:35:40 UTC
Comments
It looks like you're written the basic subscriber.
Asked by ahendrix on 2017-07-01 21:54:44 UTC
yes , its basic subscriber .. is there any other idea please give me answer ....
Thanks very much u r responses.
Asked by RaoBrother on 2017-07-02 02:18:06 UTC
I don't understand what your question is. You asked how to write a subscriber but you have written the subscriber.
Asked by ahendrix on 2017-07-02 15:53:38 UTC
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 .
Asked by RaoBrother on 2017-07-02 22:40:15 UTC
is this code is worng way or if you have have better solution .. please shared with me ..
Thanks
Asked by RaoBrother on 2017-07-02 22:41:02 UTC