OpenRTM / OpenRTP-aist

OpenRTP-aist: RT-Middleware and OMG RTC based component and system development tools implemented by AIST
Other
1 stars 6 forks source link

[RTSE] FSM型コンポーネントの状態遷移を可視化する #546

Open Nobu19800 opened 2 weeks ago

Nobu19800 commented 2 weeks ago

Is your feature request related to a problem? Please describe. 実行中のFSM型コンポーネントが何の状態なのか分かりづらい。

Describe the solution you'd like RTSystemEditor上で、実行中のFSM型コンポーネントの状態を表示してほしい。

Describe alternatives you've considered まずは、実行龍のFSM型コンポーネントから、現在の状態とFSMエディタで設計した状態遷移を取得する方法を検討する。

Additional context

n-ando commented 1 week ago

これを実現するには以下の実装が必要

n-ando commented 1 week ago

RTCBuilderのFSMエディタが出力する情報

SCXMLサンプル

<scxml initial="InitialState" name="Top" version="1.0" xmlns="http://www.w3.org/2005/07/scxml"><!--   node-size-and-position x=0 y=0 w=212 h=513  -->
 <state id="InitialState">
  <transition id="13" target="State01"></transition>
 </state>
 <state id="State01">
  <transition cond="Cond01" event="Event01_02" id="15" target="State02"></transition>
 </state>
 <state id="State02"><!--   node-size-and-position x=68.36 y=293 w=75 h=75  -->
  <transition cond="Cond02" event="Event02_Final" id="17" target="FinalState"></transition>
 </state>
 <final id="FinalState"><!--   node-size-and-position x=65.86 y=418 w=80 h=75  --></final>
</scxml>

Machoのサンプルコード

// -*- C++ -*-
/*!
 * @file  ModuleNameFSM.cpp
 * @date $Date$
 * $Id$
 */

#include "ModuleNameFSM.h"

namespace ModuleNameFsm {

// Top state
RTC::ReturnCode_t Top::onInit() {
  setState<State01>();
  return RTC::RTC_OK;
}

RTC::ReturnCode_t Top::onEntry() {
  return RTC::RTC_OK;
}

RTC::ReturnCode_t Top::onExit() {
  return RTC::RTC_OK;
}

//============================================================
// State State01
RTC::ReturnCode_t State01::onInit() {

  return RTC::RTC_OK;
}

void State01::Event01_02() {
  setState<State02>();
}

//============================================================
// State State02
RTC::ReturnCode_t State02::onInit() {

  return RTC::RTC_OK;
}

void State02::Event02_Final() {
  setState<FinalState>();
}

//============================================================
// State FinalState
RTC::ReturnCode_t FinalState::onInit() {

  return RTC::RTC_OK;
}

} //end namespace 'ModuleNameFSM'
n-ando commented 1 week ago

参考 (FSM4RTC IDL)

#ifndef _EXTENDED_FSM_SERVICE_IDL_
#define _EXTENDED_FSM_SERVICE_IDL_

#include <RTC.idl>

#pragma prefix "omg.org"

module RTC
{
    struct FsmEventProfile
    {
        string name;
        string data_type;
    };
    #pragma version FsmEventProfile 1.0
    typedef sequence<FsmEventProfile> FsmEventProfileList;

    struct FsmStructure
    {
        string name;
        string structure;
        FsmEventProfileList event_profiles;
        NVList properties;
    };
    #pragma version FsmStructure 1.0

    interface ExtendedFsmService : SDOPackage::SDOService
    {
        string get_current_state();
        ReturnCode_t set_fsm_structure(in FsmStructure fsm_structure);
        ReturnCode_t get_fsm_structure(out FsmStructure fsm_structure);
    };
    #pragma version ExtendedFsmService 1.0
};

#endif // _EXTENDED_FSM_SERVICE_IDL_