ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ardrone navdata callBack error

asked 2015-12-09 02:57:37 -0600

Sriherams gravatar image

In my program after subscribing navdata using callBack function, the values returning as zero. The values inside the callBack is giving the actual rot.Z data, but after exiting the function the value 'roll' returned as 0.

//Initiate the ROS

ros::init(argc, argv, "waypoint_nav");
ros::NodeHandle n;

velocity_publisher = n.advertise<geometry_msgs::Twist>("/cmd_vel", 10);

pose_subscriber = n.subscribe("/ardrone/navdata", 10, poseCallback);

cout<<endl<<"Roll :"<<roll<<endl;

    ros::spinOnce();

}

void poseCallback(const ardrone_autonomy::Navdata::ConstPtr & pose_message )

{

roll= pose_message->rotX;

cout<<"navdata x"<<roll<<endl;

}

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-12-12 07:39:36 -0600

Ameer Hamza Khan gravatar image

The callback function for subscriber nodes are called on ros::spinOnce() execution. Modify your code like this:

//Initiate the ROS

ros::init(argc, argv, "waypoint_nav");
ros::NodeHandle n;

velocity_publisher = n.advertise<geometry_msgs::Twist>("/cmd_vel", 10);

pose_subscriber = n.subscribe("/ardrone/navdata", 10, poseCallback);

while(ros::ok())
{
    ros::spinOnce();
    cout<<endl<<"Roll :"<<roll<<endl;
}
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-12-09 02:57:37 -0600

Seen: 408 times

Last updated: Dec 12 '15