Receive original messages in AirSDK(fsup) from GroundSDK

Hi

Modified with reference to the Hello Drone project.
Message reception from Drone to GroundSDK was successful.
But, I tried to send original message from GroundSDK of Android app but failed.
Receive ‘_on_ui_msg_cmd’ event not executed.
And where is the reference for functions like ‘make_airsdk_service_pair’?

Please help me!

Original message:

syntax = “proto3”;

package parrot.missions.samples.hello.airsdk.messages;

import ‘google/protobuf/empty.proto’;
import ‘parrot/protobuf/extensions.proto’;

// for the application-side of the mission
// (ie. “com” prefix + “drone” intermediate package)
option java_package = “com.parrot.drone.missions.samples.hello.airsdk”;
option java_outer_classname = “Hello”;

option (olympe_package) = “parrot.missions.samples.hello”;

// Union of all possible commands of this package.
message Command {
oneof id {
// Ask to start say hello (ground)
google.protobuf.Empty say = 1;
// Ask to stop say hello (ground)
google.protobuf.Empty hold = 2;

    //===========================================
    // Add : Request Mode        
    int32 req_mode=3;
}

}

// Union of all possible events of this package.
message Event {
oneof id {
// Count of hello (ground)
uint32 count = 1;
// Stereo sees something close (all)
bool stereo_close = 2;
// Drone is moving/steady (ground)
bool drone_moving = 3;
// Mean depth to closest object
float depth_mean = 4;

    //===========================================
    // Add : Drone status
    float pitch = 5;
    float roll = 6;
    float yaw = 7;
    string comment = 8;
}

}

Ground SDK(MainActivity.kt):

private fun startMissionManagement() {
    missionManagerRef = drone?.getPeripheral(MissionManager::class.java){

        it?.load(mssionId)
        it?.activate(mssionId)

        var cmdTmp = Command.newBuilder()
        cmdTmp.reqMode = 99
        var pld = cmdTmp.build()?.toByteArray()
        if (pld!=null) {
            var message = MissionManager.Message(mssionId, 6507, Command.REQ_MODE_FIELD_NUMBER, pld)
            it?.sendMessage(message)
        }
    }
}

AirSDK fsup(mission.py)

class Mission(AbstractMission):
def init(self, env):
super().init(env)
self.ext_ui_msgs = None
self.cv_service_msgs_channel = None
self.cv_service_msgs = None
self.gdnc_grd_mode_msgs = None
self.observer = None
self.dbg_observer = None
self.get_req = False

def on_load(self):
    ##################################
    # Messages / communication setup #
    ##################################
    # The airsdk service assumes that the mission is a server: as such it
    # sends events and receive commands.
    self.ext_ui_msgs = self.env.make_airsdk_service_pair(hello_msgs)

def on_unload(self):
    ####################################
    # Messages / communication cleanup #
    ####################################
    self.ext_ui_msgs = None

def on_activate(self):
    ##################################
    # Messages / communication setup #
    ##################################

    # All messages are forwarded to the supervisor's message
    # center, which feeds the state machine and makes transitions
    # based on those messages possible

    # Attach mission UI messages
    self.ext_ui_msgs.attach(self.env.airsdk_channel, True)


    # For debugging, also observe UI messages manually using an observer
    self.dbg_observer = self.ext_ui_msgs.cmd.observe({
        events.Service.MESSAGE: self._on_ui_msg_cmd
        })

def _on_ui_msg_cmd(self, event, message):
    # It is recommended that log functions are only called with a
    # format string and additional arguments, instead of a string
    # that is already interpolated (e.g. with % or .format()),
    # especially in a context where logs happen frequently. This
    # is due to the fact that string interpolation need only be
    # done when the record is actually logged (for example, by
    # default log.debug(...) is not logged).
    self.log.debug("%s: UI command message %s", UID, message)

This topic was automatically closed after 30 days. New replies are no longer allowed.