How can I store the AR.Drone's height in order to control it?
I am trying to get the int32 message published in /ardrone/navdata/altd
in order to control the ARDrone's height. Here is the code I have:
#include <ros/ros.h>
#include "std_msgs/Int32.h"
using namespace std;
void heightControl(const std_msgs::Int32::ConstPtr& height)
{
cout << height << endl;
}
from ardrone_autonomy.msg import Navdata
int main(int argc, char **argv)
{
ros::init(argc,argv,"Height_Control");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("ardrone/navdata/altd", 1, heightControl);
ros::spin();
return 0;
}
When I run this, the altitude value is not shown in the terminal screen. However, if I do rostopic echo /ardrone/navdata/altd
I do get the height shown in the terminal window. Using rosmsg show ardrone_autonomy/Navdata
I can see that altd
is type int32
.