This code shows how to takeoff, fly to the corners of a 1.5 m size square and land a drone equipped with a Pixhawk connected to a Jetson TX2 that runs this test using ViSP. The drone is localized thanks to Qualisys Mocap. Communication between the Jetson and the Pixhawk is based on Mavlink using mavsdk 3rd party.
#include <iostream>
#include <visp3/core/vpConfig.h>
#if defined(VISP_HAVE_MAVSDK) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_17)
#include <visp3/robot/vpRobotMavsdk.h>
void usage(const std::string &bin_name)
{
std::cerr << "Usage : " << bin_name << " <connection information>\n"
<< "Connection URL format should be :\n"
<< " - For TCP : tcp://[server_host][:server_port]\n"
<< " - For UDP : udp://[bind_host][:bind_port]\n"
<< " - For Serial : serial:///path/to/serial/dev[:baudrate]\n"
<< "For example, to connect to the simulator use URL: udp://:14540\n";
}
int main(int argc, char **argv)
{
if (argc != 2) {
usage(argv[0]);
return 1;
}
drone.takeOff();
drone.setPosition(0.0, 1.5, 0.0, 0.0);
drone.setPosition(1.5, 0.0, 0.0, 0.0);
drone.setPosition(0.0, -1.5, 0.0, 0.0);
drone.setPosition(-1.5, 0.0, 0.0, 0.0);
drone.land();
return EXIT_SUCCESS;
}
#else
int main()
{
#ifndef VISP_HAVE_MAVSDK
std::cout << "\nThis example requires mavsdk library. You should install it, configure and rebuid ViSP.\n"
<< std::endl;
#endif
#if !(VISP_CXX_STANDARD >= VISP_CXX_STANDARD_17)
std::cout
<< "\nThis example requires at least cxx17. You should enable cxx17 during ViSP configuration with cmake and "
"rebuild ViSP.\n"
<< std::endl;
#endif
return EXIT_SUCCESS;
}
#endif