Stop rotation when exiting mode

Hi,

I’m writing a mode in which the drone rotates at a given speed.

void RotationMode::generateDroneReference() 
{
    guidance::Output *output = getOutput();
    output->mHasYawReference = true;
    output->mYawReference.mutable_rate()->set_config(ColibryLite::Messages::YawControlConfig::Enum::SOFT);
    float speed = 50.f;
    output->mYawReference.mutable_rate()->set_ref(speed*M_PI_2/180.f);
}

I’d like the rotation to stop when the mode is exited. What’s the best way to do it ? I’ve tried to use the exit() function Guidance API - 7.7 but it does not work.

Thanks,

Hello,

The way to do it is to add a transition in the mission transition table to switch flight supervisor state (i.e switch from the state making the drone rotate to a state making making the drone hovering).

This transition should be based either:

  1. On a message (event) sent by your guidance mode or by an internal message of the flight supervisor.

To declare a message in a guidance mode you need to add it to the protobuf associated to the guidance mode and create an event sender in the guidance mode.

  1. On an internal message (event) of the flight supervisor state machine

To declare an internal message endpoint (aka service) in the flight supervisor state machine:

self.vintl = self.mc.attach_internal_service_pair(self.mc.intl_channel, mymission_fsup_msgs, True)

the protobuf file mymission_fsup_msgs can be created in the fsup directoy under fsup/protobuf/mymission/fsup/messages.proto with the Command/Event msghub structure and rules to build it added in the main fsup ‘atom.mk’ by adding the following code:

################################################################################
# Fsup mymission protobuf library (Python)
################################################################################

mymission_fsup_proto_path := fsup/protobuf
mymission_fsup_proto_files := \
	$(call all-files-under,$(mymission_fsup_proto_path),.proto)

include $(CLEAR_VARS)

LOCAL_MODULE := libairsdk-mymission-fsup-pbpy
LOCAL_DESCRIPTION := Protobuf python code for mymission fsup
LOCAL_CATEGORY_PATH := airsdk/missions/mymission
LOCAL_LIBRARIES := \
	protobuf-python

$(foreach __f,$(mymission_fsup_proto_files), \
	$(eval LOCAL_CUSTOM_MACROS += $(subst $(space),,protoc-macro:python, \
		$(TARGET_OUT_STAGING)/usr/lib/python/site-packages, \
		$(LOCAL_PATH)/$(__f), \
		$(LOCAL_PATH)/$(mymission_fsup_proto_path))) \
)

include $(BUILD_CUSTOM)

Thanks,

1 Like

Thank you @Ronan

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.