How to use default mission Manager

I want to use visual_tracking_manager.

I would like to receive advice on a specific implementation level.

The current situation is below.

on fusp/mission.py

class Mission(AbstractMission):
...............
   def on_activate(self):
      ...............
      self.get_manager("What should I put as arguments?");

What should I put as an argument in get_namager()?

The documentation mentions class_type.
What exactly is the value of class_type?

probably, from fsup.missions.default.flying.stage import FLYING_STAGE as DEF_FLYING_STAGE
Does this apply to items that can be imported with, etc.?
https://developer.parrot.com/docs/airsdk/general/default_mission.html#visual_tracking_manager.VisualTrackingManager:~:text=ある状態%20(たとえば、クリティカル/ランディングでは%20AutoLandingAlertsManager%20を使用)%20または別のマネージャー%20(たとえば、RthManager%20は%20AutoLandingAlertsManager%20を使用)%20でインポートして使用できます。

1 Like

Hi @atsumu-arch ,

Thank you for your question.

Because visual_tracking_manager is belong to mission default, first of all, you have to import the manager by using this code:

from fsup.missions.default.features.visual_tracking_manager import (
    VisualTrackingManager
)

Then in your code, you can call the function get_manager of class AbstractMission

self.visual_tracking_mng = mission.get_manager(VisualTrackingManager)

So the class_type argument is VisualTrackingManager (you can get the class name here in the document)

Based on this document section, it is better to import and get the manager in a state. This is an example code of a state named YourState using VisualTrackingManager. Remember to name your code file as your_mission_name/fsup/flying/your_state.py if you want to use this state in flying stage

from fsup.missions.default.features.visual_tracking_manager import (
    VisualTrackingManager
)
from fsup.genstate import State

class YourState(State):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.visual_tracking_mng = self.mission.get_manager(VisualTrackingManager)

# Then you can use your manager in YourState

# Create your state's description to be used in stage/transition machine
YOUR_STATE = {
    "name": "your_state",
    "class": YourState,
}

After that, to apply YourState in stage flying which contains also DEF_FLYING_STAGE, you need to create a flying stage of your own mission (your_mission_name/fsup/flying/stage.py) using the code like below:

from fsup.missions.default.flying.stage import FLYING_STAGE as DEF_FLYING_STAGE
from fsup.genstate import State
# import your state description
from .your_state import YOUR_STATE

class Flying(State):
    def can_enter(self, msg):
        # You can add your own condition
        return True

    def enter(self, msg):
        # Your code here
        pass

    def step(self, msg):
        # Your code here
        pass

    def exit(self, msg):
        # Your code here
        pass

FLYING_STAGE = {
    "name": "flying",
     # if you don't need to re-create your own Flying class 
     # and use the default mission one, you can do: 
     # "class": DEF_FLYING_STAGE['class']
    "class": Flying,
    # put the name of state that you want to make it as initial
    # the name is found in attribute "name" of your state's description 
    # or you can use the default mission initial state DEF_FLYING_STAGE['initial']
    "initial": "name_of_initial_state",
    "children": [
    # get all children states of default mission
        child
        for child in DEF_FLYING_STAGE["children"]
    ]
    + [
    # also concatenate it with your own state
       YOUR_STATE,
    ],
}

I hope that this answer is clear for you.

Best regards,

Trang

1 Like

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