MotorStateFeedback.java

/*
 * $Id$
 *
 * Copyright (C) 2004 Koga Laboratory. All rights reserved.
 *
 */
package org.mklab.tool.control.model.matxbook;

import org.mklab.nfc.matrix.DoubleMatrix;
import org.mklab.tool.control.system.continuous.DoubleBaseContinuousExplicitDynamicSystem;


/**
 * モーターの状態フィードバック制御システムを表すクラスです。
 * 
 * @author koga
 * @version $Revision$, 2004/04/23
 */
public class MotorStateFeedback extends DoubleBaseContinuousExplicitDynamicSystem {

  /** モーター */
  MotorWithFullState motor = new MotorWithFullState();
  /** 状態フィードバック制御器 */
  StateFeedback stateFeedback = new StateFeedback();

  /**
   * 新しく生成された<code>MotorStateFeedback</code>オブジェクトを初期化します。
   */
  public MotorStateFeedback() {
    super(1, 1, 2);
    setHasDirectFeedthrough(false);
  }

  /**
   * {@inheritDoc}
   */
  public DoubleMatrix stateEquation(double t, DoubleMatrix x, DoubleMatrix u) {
    return this.motor.stateEquation(t, x, u);
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public DoubleMatrix inputOutputEquation(double t, DoubleMatrix x) {
    DoubleMatrix y = this.motor.outputEquation(t, x);
    DoubleMatrix u = this.stateFeedback.outputEquation(t, y).unaryMinus();
    return u.appendDown(y);
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public DoubleMatrix outputEquation(double t, DoubleMatrix x) {
    return this.motor.outputEquation(t, x);
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public void setInitialState(DoubleMatrix initialState) {
    this.motor.setInitialState(initialState);
  }

  /**
   * @see org.mklab.tool.control.system.DynamicSystem#getInitialState()
   */
  @Override
  public DoubleMatrix getInitialState() {
    return this.motor.getInitialState();
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public void setState(DoubleMatrix state) {
    this.motor.setState(state);
  }

  /**
   * @see org.mklab.tool.control.system.DynamicSystem#getState()
   */
  @Override
  public DoubleMatrix getState() {
    return this.motor.getState();
  }
}