コード例 #1
0
ファイル: _Automaton.cpp プロジェクト: yankailab/OpenKAI
bool _Automaton::init(void* pKiss)
{
	CHECK_F(!this->_ThreadBase::init(pKiss));
	Kiss* pK = (Kiss*)pKiss;
	pK->m_pInst = this;

	//create state instances
	Kiss** pItr = pK->getChildItr();

	int i = 0;
	while (pItr[i])
	{
		Kiss* pState = pItr[i++];

		CHECK_F(m_nState >= N_STATE);
		F_ERROR_F(pState->v("state", &m_pStateName[m_nState]));
		m_nState++;
	}

	string startState = "";
	F_ERROR_F(pK->v("startState", &startState));
	m_iState = getStateIdx(&startState);
	CHECK_F(m_iState<0);

	return true;
}
コード例 #2
0
ファイル: _AutoPilot.cpp プロジェクト: yankailab/OpenKAI
bool _AutoPilot::init(void* pKiss)
{
    CHECK_F(!this->_ThreadBase::init(pKiss));
    Kiss* pK = (Kiss*)pKiss;
    pK->m_pInst = this;

    //create action instance
    Kiss* pCC = pK->o("action");
    CHECK_T(pCC->empty());
    Kiss** pItr = pCC->getChildItr();

    int i = 0;
    while (pItr[i])
    {
        Kiss* pAction = pItr[i];
        i++;

        bool bInst = false;
        F_INFO(pAction->v("bInst", &bInst));
        if (!bInst)continue;
        if (m_nAction >= N_ACTION)LOG(FATAL);

        ActionBase** pA = &m_pAction[m_nAction];
        m_nAction++;

        //Add action modules below

        ADD_ACTION(RC_visualFollow);
        ADD_ACTION(APMcopter_landing);
        ADD_ACTION(APMcopter_guided);
        ADD_ACTION(HM_base);
        ADD_ACTION(HM_follow);
        ADD_ACTION(APMrover_base);
        ADD_ACTION(APMrover_follow);

        //Add action modules above

        LOG_E("Unknown action class: "+pAction->m_class);
    }

    return true;
}