Here , it states we can use the DJISimulator
object to help facilitate continuous integration (ie unit/integration tests). But I can't seem to figure out how thats possible. DJISimulator
and DJIFlightController
do not conform to the same basic protocol, nor do they have the similar delegates.
What I'd love to be able to do is in my unit tests, is to simulate (without attaching drone hardware or running DJIAssistant 2) the drone taking off and flying the waypoint missions we build and upload, and upon completion, coming home and landing; following the same code flow that would execute if we were flying with a real drone and our custom iOS app that has the DJISDK integrated into it.
Is this possible?
At the moment, running the simulator without the hardware (drone + RC) physically in the loop is not possible . That is because the actual simulation takes place on the drone, and each different flight controller model for the different drones have their own little quirks which makes it very difficult to accurately simulate the entire thing completely in software.
However, you can simulate waypoint missions without actually flying the drone by having it connected and powered on in your testing loop.
To start the simulation, fetch the DJISimulator
object from the aircraft's flightController , and then call the start simulation method with your desired location, frequency, etc. Once you have started the simulator, you can listen to the simulator's delegate method to get the state of the drone in the simulated world.
Edit :
To add more as to how to go about writing unit tests, here's what a rough series of steps would look like to test for example a mission like this [Take off, yaw to north, waypoint mission, go home and land]:
PS If you want even more granular updates on a mission (waypoint, hotpoint, etc.), you can also subscribe to listen to the MissionOperator listeners (WaypointMissionOperator, HotpointMissionOperator, etc.). Those have upload/download listeners which might be of interest.
Also, during any point in the test, you don't need to listen to the simulator's state listener at all because you can just probe the drone for its state (location, whether motors are on, etc.) and it will give the simulated values that you can check with your expected values.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.