Closed Dubbauril closed 8 years ago
Hi,
The easiest way is to add a public member function in ARDrone class as below.
// AR.Drone class
class ARDrone {
public:
// Constructor / Destructor
ARDrone();
ARDrone(const char *ardrone_addr);
virtual ~ARDrone();
// Initialize
virtual int open(const char *ardrone_addr = ARDRONE_DEFAULT_ADDR);
// Update
virtual int update(void);
// Finalize (Automatically called)
virtual void close(void);
// Get an image
virtual ARDRONE_IMAGE getImage(void);
virtual ARDrone& operator >> (cv::Mat &image);
virtual bool willGetNewImage(void);
// Get AR.Drone's firmware version
virtual int getVersion(int *major = NULL, int *minor = NULL, int *revision = NULL);
// ---------- ADD HERE, FOR INSTANCE ! ----------
virtual ARDRONE_NAVDATA getNavdata(void)
{
ARDRONE_NAVDATA ret = {0};
// Copy the Navdata
if (mutexNavdata) pthread_mutex_lock(mutexNavdata);
ret = navdata;
if (mutexNavdata) pthread_mutex_unlock(mutexNavdata);
return ret;
}
Then, in "main.cpp", you can display the link quality by using the above function and cv::putText().
int main(int argc, char *argv[])
{
// AR.Drone class
ARDrone ardrone;
// Initialize
if (!ardrone.open()) {
std::cout << "Failed to initialize." << std::endl;
return -1;
}
while (1) {
// Key input
int key = cv::waitKey(33);
if (key == 0x1b) break;
// Get an image
cv::Mat image = ardrone.getImage();
// Get Navdata
ARDRONE_NAVDATA navdata = ardrone.getNavdata();
// Show link quality
cv::putText(image, "Link quality=" + navdata.wifi.link_quality, cv::Point(10, 20), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 255), 1, 16);
// Display the image
cv::imshow("camera", image);
}
return 0;
}
Regards, puku0x
Hey!
Id love to see the link quality on screen while flying and if possible, to save that in a log file. I have near 0 experience with c++ but I'm trying my best,( so far I result only in getting errors.) Any tips or even code for this?
Thank you!