ArDrone navdata reading error

asked 2015-11-01 04:33:57 -0600

Ameer Hamza Khan gravatar image

updated 2015-11-01 05:49:47 -0600

I am trying to read navdata from ardrone using following callback function,

int     state, battery;

void callBack(const ardrone_autonomy::Navdata::ConstPtr& msg) {
state = msg->state;
battery = msg->batteryPercent;

std::cout<<"State is: " << state << std::endl;
std::cout<<"battery is: " << battery;
}

But this is always returing 0 value, but when i echo navdata in linux terminal, these topics are publishing non-zero value. where is the error?

Edit: After some debugging i found that this callBack function is not being called at all. I wrote my subscriber node like this ros::Subscriber sub = ardrone.subscribe<ardrone_autonomy::Navdata>("/ardrone/navdata",1,callBack); What is going wrong here?

edit retag flag offensive close merge delete

Comments

are you doing a ros::spin() or ros::spin_once() in your main loop?

Gary Servin gravatar imageGary Servin ( 2015-11-01 10:22:53 -0600 )edit

@Gray Servin, yes that was missing. Thanks.

Ameer Hamza Khan gravatar imageAmeer Hamza Khan ( 2015-11-01 22:32:44 -0600 )edit