Drone Controller Software -- Part 1

With looking at the last post, I'm detailing out 4 main modules. The largest of the modules is the Drone Software module. This module is the executable that actually runs on the drone itself. This post will detail the architecture of the drone executable module; along with how to get started writing it.

First, let's talk about how to get navigator libraries to work in Android Studio. Remember that we're linking in a dependent pre-built library. I suggest using CMake as it has strong integration within Android Studio and is well supported. To use CMake, create the project as detailed here. Now, edit the CMakeLists.txt file and add the library dependency like so:

include_directories(
            ${CMAKE_CURRENT_SOURCE_DIR}/snav/1.2.31_8/include
)
add_executable( drone-controller ${SourceList} )
add_library( libsnav-arm SHARED IMPORTED )
set_target_properties(
            libsnav-arm
            PROPERTIES
            IMPORTED_LOCATION
            ${CMAKE_CURRENT_SOURCE_DIR}/snav/1.2.31_8/libs/${ANDROID_ABI}/libsnav-arm.so
        )
target_link_executable(
            drone-controller ${libsnav-arm}
)

In the above you'll notice that I moved the libraries around. This is to follow the Android standard practice for library locations so packaging works easier. Now follow the same steps to include Snapdragon Math libraries. The reasoning for these libraries will become apparent in the future when we work on the neural network. For now, it's great practice to get aquatinted with the process. Don't worry if you have trouble with this, I'll detail it out and provide the open sourced project at the end of the blog series.

You should now be able to build the drone project. However, we need to get to the point where we can deploy the application to the drone and then start / stop it so let's look at some gradle code. If you're on windows, install winscp and ensure it is within the command path. If you're on OSX or Linux, just make sure you have ssh installed. Then the following gradle code should do a deployment:

tasks.create(name: "deployApp", type: Exec, description: "send drone executable along with dependent libs") {
    //noinspection GroovyAssignabilityCheck
    def cmdStr
    if(System.properties['os.name'].toLowerCase(Locale.ROOT).contains('windows'))
        cmdStr = "scp.exe"
    else
        cmdStr = "scp"
    commandLine cmdStr,
            "-p",
            "bin/out/*", "$DRONE_IP_ADDR:"
}

tasks.create(name: "runApp", type: Exec, description: "start the drone app") {
    //noinspection GroovyAssignabilityCheck
    def cmdStr
    if(System.properties['os.name'].toLowerCase(Locale.ROOT).contains('windows'))
        cmdStr = "ssh.exe"
    else
        cmdStr = "ssh"
    commandLine cmdStr,
            "$DRONE_IP_ADDR", "-C", "DroneApplication"
}

Okay so the last little bit here for this part 1 is to start researching the API docs found here. The next post will detail putting this API to use.

Comments

Popular posts from this blog

Drone VR Software Architecture

Build Snapdragon Flight Drone

Status of the blog