GCOP  1.0
systemceview.h
Go to the documentation of this file.
00001 // This file is part of libgcop, a library for Geometric Control, Optimization, and Planning (GCOP)
00002 //
00003 // Copyright (C) 2004-2014 Marin Kobilarov <marin(at)jhu.edu>
00004 //
00005 // This Source Code Form is subject to the terms of the Mozilla
00006 // Public License v. 2.0. If a copy of the MPL was not distributed
00007 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008 
00009 #ifndef GCOP_SYSTEMCEVIEW_H
00010 #define GCOP_SYSTEMCEVIEW_H
00011 
00012 #include <Eigen/Dense>
00013 #include <vector>
00014 #include <type_traits>
00015 #include <algorithm>
00016 #include <iterator>
00017 #include "systemce.h"
00018 #include "view.h"
00019 #include <cmath>
00020 #include <limits>
00021 
00022 namespace gcop {
00023   
00024   using namespace std;
00025   using namespace Eigen;
00026  
00032   template <typename T, int n = Dynamic, int c = Dynamic, int np = Dynamic, int ntp = Dynamic> 
00033     class SystemCeView : public View {
00034     
00035     typedef Matrix<double, n, 1> Vectornd;
00036     typedef Matrix<double, c, 1> Vectorcd;
00037     typedef Matrix<double, np, 1> Vectormd;
00038 
00039     typedef Matrix<double, n, n> Matrixnd;
00040     typedef Matrix<double, n, c> Matrixncd;
00041     typedef Matrix<double, c, n> Matrixcnd;
00042     typedef Matrix<double, c, c> Matrixcd;  
00043 
00044     typedef Matrix<double, ntp, 1> Vectortpd;  
00045     typedef Matrix<double, ntp, ntp> Matrixtpd;  
00046     
00047   public:
00048     SystemCeView(SystemCe<T, n, c, np, ntp> &ce,
00049                  SystemView<T, Vectorcd> &view);
00050     
00051     virtual void Render();
00052     
00053     virtual bool RenderFrame(int i);   
00054     
00055     SystemCe<T, n, c, np, ntp> &ce;
00056     
00057     SystemView<T, Vectorcd> &view;
00058 
00059   };
00060 
00061   using namespace std;
00062   using namespace Eigen;
00063   
00064   template <typename T, int n, int c, int np, int ntp> 
00065     SystemCeView<T, n, c, np, ntp>::SystemCeView(SystemCe<T, n, c, np, ntp> &ce, 
00066                                                  SystemView<T, Vectorcd> &view) : 
00067     ce(ce), view(view)
00068   {
00069   }
00070   
00071   template <typename T, int n, int c, int np, int ntp> 
00072     void SystemCeView<T, n, c, np, ntp>::Render() {
00073     
00074     for (int j = 0; j < ce.xsas.size() && j < ce.usas.size(); ++j) {
00075       view.xs = &ce.xsas[j];
00076       view.us = &ce.usas[j]; 
00077       view.Render();
00078     }
00079   }
00080 
00081   template <typename T, int n, int c, int np, int ntp> 
00082     bool SystemCeView<T, n, c, np, ntp>::RenderFrame(int i) {    
00083     bool res = false;
00084     for (int j = 0; j < ce.xsas.size() && j < ce.usas.size(); ++j) {
00085       view.xs = &ce.xsas[j];
00086       view.us = &ce.usas[j]; 
00087       res = (view.RenderFrame(i) || res);
00088     }
00089     return res;  // return false only after all frames are rendered
00090   }
00091 }
00092 
00093 #endif