📄 ccartpolemodel.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 __CCARTPOLE_H
#define __CCARTPOLE_H
#include "cqtconfig.h"
#include "ctransitionfunction.h"
#include "crewardfunction.h"
#include "ril_debug.h"
#ifdef RL_TOOLBOX_USE_QT
#include "cqtmodelvisualizer.h"
#endif
class CCartPoleModel : public CDynamicLinearActionContinuousTimeModel
{
protected:
virtual void doSimulationStep(CState *state, rlt_real timestep, CAction *action, CActionData *data);
public:
rlt_real uMax;
rlt_real lengthTrack;
rlt_real g;
rlt_real massCart;
rlt_real massPole;
rlt_real lengthPole;
rlt_real mu_c; // friction cart
rlt_real mu_p; // friction pole
bool endLeaveTrack;
bool endOverRotate;
rlt_real failedReward;
CCartPoleModel(rlt_real dt, rlt_real uMax = 10, rlt_real lengthTrack = 4.8, rlt_real lengthPole = 0.5, rlt_real massCart = 1.0, rlt_real massPole = 0.5, rlt_real mu_c = 1.0, rlt_real mu_p = 0.1, rlt_real g = 9.8, bool endLeaveTrack = true,bool endOverRotate = true);
~CCartPoleModel();
virtual CMyMatrix *getB(CState *state);
virtual CMyVector *getA(CState *state);
virtual bool isFailedState(CState *state);
virtual void getResetState(CState *state);
};
class CCartPoleRewardFunction : public CStateReward
{
protected:
CCartPoleModel *cartpoleModel;
public:
bool useHeighPeak;
bool punishOverRotate;
CCartPoleRewardFunction(CCartPoleModel *model);
virtual rlt_real getStateReward(CState *state);
virtual void getInputDerivation(CState *modelState, CMyVector *targetState);
};
class CCartPoleHeightRewardFunction : public CStateReward
{
protected:
CCartPoleModel *cartpoleModel;
public:
CCartPoleHeightRewardFunction(CCartPoleModel *model);
virtual rlt_real getStateReward(CState *state);
virtual void getInputDerivation(CState *modelState, CMyVector *targetState);
};
#ifdef RL_TOOLBOX_USE_QT
class CQTCartPoleVisualizer : public CQTModelVisualizer
{
protected:
rlt_real phi;
rlt_real dphi;
rlt_real x;
rlt_real dx;
CCartPoleModel *cartModel;
virtual void doDrawState( QPainter *painter);
public:
CQTCartPoleVisualizer( CCartPoleModel *model, QWidget *parent = NULL, const char *name = NULL);
virtual void newDrawState(CStateCollection *state);
};
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -