示例#1
0
文件: parser.py 项目: JungYT/fym
    # ``parser.parse``
    import fym.utils.parser as parser
    from fym.core import BaseEnv, BaseSystem

    json_dict = {
        "env.kwargs": dict(dt=0.01, max_t=10),
        "multicopter.nrotor": 6,
        "multicopter.m": 3.,
        "multicopter.LQRGain": {
            "Q": [1, 1, 1, 1],
            "R": [1, 1],
        },
        "actuator.tau": 1e-1,
    }

    cfg = parser.parse(json_dict)

#     # ``parser.update``
#     cfg = parser.parse()

#     def load_config():
#         parser.update(cfg, {
#             "env.kwargs": dict(dt=0.01, max_t=10),
#             "agent.memory_size": 1000,
#             "agent.minibatch_size": 32,
#         })

#     load_config()
#     cfg.env.kwargs.dt = 0.001

#     # ``parser.decode``
示例#2
0
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from matplotlib.patches import Circle
import mpl_toolkits.mplot3d.art3d as art3d

from fym.core import BaseEnv, BaseSystem
from fym.utils.linearization import jacob_analytic
from fym.agents import LQR
from fym.utils import parser
import fym.logging
from fym.models.quadrotor import Quadrotor

import agents
import logs

cfg = parser.parse()


def load_config():
    fym.parser.update(cfg, {"path.base": Path("data", "exp7")})
    fym.parser.update(
        cfg, {
            "path": {
                "sample":
                Path(cfg.path.base, "sampled_data"),
                "train.sql":
                Path(cfg.path.base, "train", "result-sql.h5"),
                "train.klm":
                Path(cfg.path.base, "train", "result-klm.h5"),
                "train.sql_stable":
                Path(cfg.path.base, "train", "result-sql-stable.h5"),
示例#3
0
import fym.utils.parser as parser


cfg = parser.parse({
    "env.kwargs": dict(dt=0.01, max_t=10),
    "multicopter.nrotor": 6,
    "multicopter.m": 3.,
    "multicopter.LQRGain": {
        "Q": [1, 1, 1, 1],
        "R": [1, 1],
    },
    "actuator.tau": 1e-1,
})


class LQR:
    def __init__(self):
        self.Q = cfg.multicopter.LQRGain.Q
        self.R = cfg.multicopter.LQRGain.R
示例#4
0
文件: baseline.py 项目: seong-hun/fym
    return np.array([[2 * x1, 0], [x2, x1], [0, 2 * x2]])


np.random.seed(0)

# Parameter setup
cfg = parser.parse({
    "env": {
        "max_t": 20,
        "dt": 0.0025,
    },
    "initial": {
        "X": np.deg2rad(np.vstack((5, -5))),
        "W1": 0.01 * np.random.rand(3, 1),
        "W2": 0.01 * np.random.rand(3, 1),
    },
    "Q": np.diag([0.1, 0.1]),
    "R": np.diag([0.1]),
    "T": 1,
    "agent": {
        "F1": 1,
        "F2": 1,
        "alp1": 1e3,
        "alp2": 1,
    },
})

aerodata = scipy.io.loadmat("Data.mat", squeeze_me=True)
parser.update(
    cfg, {
        "A": np.array([[aerodata["Za"], 1], [aerodata["Ma"], aerodata["Mq"]]]),
        "B": np.vstack([aerodata["Zdp"], aerodata["Mdp"]]),