ArDrone navdata reading error

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

Ameer Hamza Khan gravatar image

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

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 image Gary Servin  ( 2015-11-01 10:22:53 -0500 )edit

@Gray Servin, yes that was missing. Thanks.

Ameer Hamza Khan gravatar image Ameer Hamza Khan  ( 2015-11-01 22:32:44 -0500 )edit