This package connects onboard embedded system with ground control station using mavlink protocol
This package is designed as a library and can be included in various platforms. It is implemented in C++ and depended on mavlink library. A simple ROS node is provided to bringup the dji2mav package.
Dji2mav connects the onboard computer with ground control station using UDP. And it is required to call functions to send heartbeat and sensors data. All the mavlink status and message encode/decode will be handled inside the dji2mav package. So far it is tested on Ubuntu 14.0 with ROS indigo.
Since a ROS node is provided inside this package, it is easy to put the dji2mav to use.
It is recommanded to do sufficient tests on simulator first. Please turn on your drone, connect your drone to the PC and properly set the API Control to Enable on N1-Assistant. Remember to switch to "P" mode on RC. Then open DJISimulator, click Start Simulation and Display simulator. You should see M100 on the ground in simulator.
Connect onboard computer with your ground control station. Any ground control station using mavlink protocol is fitted. Please do sufficient tests on simulator before a real flight. We will be appreciated if you put forward any bug.
Make sure the onboard computer and ground control station are in the same LAN and can successfully ping each other.
Firstly, fire up dji sdk main launch:
Record the IP and port of ground control station, modified the corresponding param in dji2mav_bringup.launch. Then run:
In the terminal that launched sdk_manifold, you should see the log information that the drone has been successfully activated and the control of the drone has got, as the picture shows below.
In the terminal that launched dji2mav_bringup, you should see it notifies that the connection to specific IP and port succeeds and all the modules is launched, as the picture shows below.
If the output of these ROS nodes prompt that every thing goes okay, please move to next step.
Now please turn on your mavlink-protocol-adapted ground control station. Let's take QGround Control v2.7.1 for win32 as an example. Before clicking Connect, please check the connection settings. The Link Type should be UDP, and the Listening Port should be consistent with the port number that is set on the launch file which is mentioned on step 2. A UDP setting example is shown below.
Then click Connect. If everything is ready, you can see your ground control station receives the heartbeat. On Analyze tag some sensors data from the vehicle are also displayed.
Now you can do some simple waypoint test on simulator.
Before test waypoint module, please unlock the drone and takeoff using RC. On Plan tag inside QGround Station, you should see a marker on the map to show the current position of drone(You can set the initial location in DJISimulator).
Double click on the map to lay markers of the waypoint. On the dashboard, please set the type of waypoint to Global/Abs. Alt(global position with absolute altitude). And choose NAV: Waypoint to be the navigation type.
Check lat, lon and alt data of every waypoint. Be careful that there is a default value of alt. Make sure it is what you expect. You can also set desired yaw angle and stay time for every waypoint. An example of creating waypoint task is shown below.
After the confirmation of the waypoint data in dashboard, you should click Set to send the whole mission to onboard computer. And a downloading process will be automatically execute after the uploading. You should double check the waypoint data which are downloaded from Onboard Embedded System (OES). A double check is necessary because there is no "Stop" buttom on the QGround Station. Repeated uploading process is allowed and a newer mission will cover the old one.
To start the mission, click the first ckeck box of the waypoint list. This action will send a "set current target" command to the onboard computer. The vehicle will start from the current target to the end of the waypoint list. The picture shown below displays the results of downloading waypoint task from onboard computer. The "set current target" check box is on the right of every point.
In waypoint function module, users can set latitude, longitude, altitude, heading and staytime for the waypoint. Users can upload waypoint list to the vehicle. The vehicle will wait till a current target is set by the users in the ground control station. After that, the vehicle will directly go to that target waypoint and automatically carry out the rest of the waypoint list mission, as the picture shown below.
The dji2mav is designed to meet multi ground control stations and easy expansibility demands. Some classes are designed as lazy-mode singleton.
It is easy to access dji2mav interface by getting instance of Config. There are two important methods in config:
These two methods must be called BEFORE any data transporting between ground control station and onboard computer. They can be called like this:
To send heartbeat to all GCS(ground control station), use:
To send heartbeat to specific GCS, use the corresponding GCS index:
The send buffer of heartbeat module is particular. So it is safe to be called in a thread that periodically send heartbeat and it is recommanded to do so.
The sending process of sensors data is similar to the heartbeat module. To update the data, please use setters. All the data are stored inside the relative sensor class.
Take ROS platform as an example. Since all the sensors data are published to specific topics, we can update data in the callback function:
Once waypoint module has been launched, it is ready to receive command from ground control station and reply automatically. All you need to do is keeping the distribution process running(an example of ROS platform):