📄 cpendulummodel.h
字号:
// Copyright (C) 2003
// Gerhard Neumann (gerhard@igi.tu-graz.ac.at)
//
// This file is part of RL Toolbox.
// http://www.igi.tugraz.at/ril_toolbox
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef __CPENDULUMMODEL_H
#define __CPENDULUMMODEL_H
#include "cqtconfig.h"
#include "ril_debug.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#include "ctransitionfunction.h"
#include "ctestsuit.h"
#ifdef RL_TOOLBOX_USE_QT
#include "cqtmodelvisualizer.h"
#endif
class CPendulumModel : public CDynamicLinearActionContinuousTimeModel
{
protected:
virtual void doSimulationStep(CState *state, rlt_real timestep, CAction *action, CActionData *data);
public:
rlt_real uMax;
rlt_real dPhiMax;
rlt_real g;
rlt_real mass;
rlt_real length;
rlt_real mu; // friction
CPendulumModel(rlt_real dt, rlt_real uMax = 5, rlt_real dPhiMax = 10, rlt_real length = 1, rlt_real mass = 1, rlt_real mu = 1.0, rlt_real g = 9.81);
~CPendulumModel();
virtual CMyMatrix *getB(CState *state);
virtual CMyVector *getA(CState *state);
virtual bool isFailedState(CState *state);
virtual void getResetState(CState *resetState);
virtual void setParameter(string paramName, rlt_real value);
};
class CPendulumRewardFunction : public CStateReward
{
public:
rlt_real rewardFactor;
CPendulumRewardFunction(CPendulumModel *model);
virtual rlt_real getStateReward(CState *state);
virtual void getInputDerivation(CState *modelState, CMyVector *targetState);
};
class CPendulumUpTimeCalculator : public CSemiMDPListener
{
protected:
rlt_real phi_up;
rlt_real dt;
int up_steps;
public:
CPendulumUpTimeCalculator(rlt_real phi_up, rlt_real dt);
virtual void nextStep(CStateCollection *oldState, CAction *action, CStateCollection *nextState);
virtual void newEpisode();
rlt_real getUpTime();
int getUpSteps();
};
/*
class CTestSuitePendulumUpTimeCalculatorEvaluator : public CTestSuiteEpisodesToLearnEvaluator
{
protected:
int neededUpSteps;
CPendulumUpTimeCalculator *upTimeCalc;
virtual bool isEpisodeSuccessFull(FILE *stream);
public:
CTestSuitePendulumUpTimeCalculatorEvaluator(CAgent *agent, int neededSuccEpisodes, int maxEpisodes, int stepsPerEpisode, int neededUpSteps,rlt_real phi_up);
~CTestSuitePendulumUpTimeCalculatorEvaluator();
};*/
#ifdef RL_TOOLBOX_USE_QT
class CQTPendulumVisualizer : public CQTModelVisualizer
{
protected:
rlt_real phi;
rlt_real dphi;
CPendulumModel *pendModel;
virtual void doDrawState( QPainter *painter);
public:
CQTPendulumVisualizer(CPendulumModel *pendModel, QWidget *parent=0, const char *name=0);
virtual void newDrawState(CStateCollection *state);
};
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -