Colour sensors calibrated

Dependencies:   mbed-rtos mbed Servo QEI

Fork of ICRSEurobot13 by Thomas Branch

Committer:
xiaxia686
Date:
Fri Apr 12 20:59:18 2013 +0000
Revision:
46:adcd57a5e402
Parent:
15:9c5aaeda36dc
Colours Sensors fixed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
madcowswe 15:9c5aaeda36dc 1 /*
madcowswe 15:9c5aaeda36dc 2 * Tiny Vector Matrix Library
madcowswe 15:9c5aaeda36dc 3 * Dense Vector Matrix Libary of Tiny size using Expression Templates
madcowswe 15:9c5aaeda36dc 4 *
madcowswe 15:9c5aaeda36dc 5 * Copyright (C) 2001 - 2007 Olaf Petzold <opetzold@users.sourceforge.net>
madcowswe 15:9c5aaeda36dc 6 *
madcowswe 15:9c5aaeda36dc 7 * This library is free software; you can redistribute it and/or
madcowswe 15:9c5aaeda36dc 8 * modify it under the terms of the GNU Lesser General Public
madcowswe 15:9c5aaeda36dc 9 * License as published by the Free Software Foundation; either
madcowswe 15:9c5aaeda36dc 10 * version 2.1 of the License, or (at your option) any later version.
madcowswe 15:9c5aaeda36dc 11 *
madcowswe 15:9c5aaeda36dc 12 * This library is distributed in the hope that it will be useful,
madcowswe 15:9c5aaeda36dc 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
madcowswe 15:9c5aaeda36dc 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
madcowswe 15:9c5aaeda36dc 15 * Lesser General Public License for more details.
madcowswe 15:9c5aaeda36dc 16 *
madcowswe 15:9c5aaeda36dc 17 * You should have received a copy of the GNU Lesser General Public
madcowswe 15:9c5aaeda36dc 18 * License along with this library; if not, write to the Free Software
madcowswe 15:9c5aaeda36dc 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
madcowswe 15:9c5aaeda36dc 20 *
madcowswe 15:9c5aaeda36dc 21 * $Id: Eval.h,v 1.13 2007-06-23 15:58:59 opetzold Exp $
madcowswe 15:9c5aaeda36dc 22 */
madcowswe 15:9c5aaeda36dc 23
madcowswe 15:9c5aaeda36dc 24 #ifndef TVMET_XPR_EVAL_H
madcowswe 15:9c5aaeda36dc 25 #define TVMET_XPR_EVAL_H
madcowswe 15:9c5aaeda36dc 26
madcowswe 15:9c5aaeda36dc 27 namespace tvmet {
madcowswe 15:9c5aaeda36dc 28
madcowswe 15:9c5aaeda36dc 29
madcowswe 15:9c5aaeda36dc 30 /**
madcowswe 15:9c5aaeda36dc 31 * \class XprEval Eval.h "tvmet/xpr/Eval.h"
madcowswe 15:9c5aaeda36dc 32 * \brief evaluate the expression
madcowswe 15:9c5aaeda36dc 33 *
madcowswe 15:9c5aaeda36dc 34 * Since we can't overwrite the ? operator we have to write a wrapper
madcowswe 15:9c5aaeda36dc 35 * for expression like return v1>v2 ? true : false
madcowswe 15:9c5aaeda36dc 36 */
madcowswe 15:9c5aaeda36dc 37 template<class E1, class E2, class E3>
madcowswe 15:9c5aaeda36dc 38 class XprEval
madcowswe 15:9c5aaeda36dc 39 : public TvmetBase< XprEval<E1, E2, E3> >
madcowswe 15:9c5aaeda36dc 40 {
madcowswe 15:9c5aaeda36dc 41 public:
madcowswe 15:9c5aaeda36dc 42 typedef E1 expr1_type;
madcowswe 15:9c5aaeda36dc 43 typedef E2 expr2_type;
madcowswe 15:9c5aaeda36dc 44 typedef E3 expr3_type;
madcowswe 15:9c5aaeda36dc 45
madcowswe 15:9c5aaeda36dc 46 typedef typename expr2_type::value_type value2_type;
madcowswe 15:9c5aaeda36dc 47 typedef typename expr3_type::value_type value3_type;
madcowswe 15:9c5aaeda36dc 48
madcowswe 15:9c5aaeda36dc 49 typedef typename
madcowswe 15:9c5aaeda36dc 50 PromoteTraits<value2_type, value3_type>::value_type value_type;
madcowswe 15:9c5aaeda36dc 51
madcowswe 15:9c5aaeda36dc 52 public:
madcowswe 15:9c5aaeda36dc 53 /** Complexity Counter */
madcowswe 15:9c5aaeda36dc 54 enum {
madcowswe 15:9c5aaeda36dc 55 ops_expr1 = E1::ops,
madcowswe 15:9c5aaeda36dc 56 ops_expr2 = E2::ops,
madcowswe 15:9c5aaeda36dc 57 ops_expr3 = E3::ops,
madcowswe 15:9c5aaeda36dc 58 ops = ops_expr1 // only (e1 op e2) are evaluated
madcowswe 15:9c5aaeda36dc 59 };
madcowswe 15:9c5aaeda36dc 60
madcowswe 15:9c5aaeda36dc 61 private:
madcowswe 15:9c5aaeda36dc 62 XprEval();
madcowswe 15:9c5aaeda36dc 63 XprEval& operator=(const XprEval<expr1_type, expr2_type, expr3_type>&);
madcowswe 15:9c5aaeda36dc 64
madcowswe 15:9c5aaeda36dc 65 public:
madcowswe 15:9c5aaeda36dc 66 /** Constructor */
madcowswe 15:9c5aaeda36dc 67 explicit XprEval(const expr1_type& e1, const expr2_type& e2, const expr3_type& e3)
madcowswe 15:9c5aaeda36dc 68 : m_expr1(e1), m_expr2(e2), m_expr3(e3)
madcowswe 15:9c5aaeda36dc 69 { }
madcowswe 15:9c5aaeda36dc 70
madcowswe 15:9c5aaeda36dc 71 /** Copy Constructor. Not explicit! */
madcowswe 15:9c5aaeda36dc 72 #if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR)
madcowswe 15:9c5aaeda36dc 73 XprEval(const XprEval& rhs)
madcowswe 15:9c5aaeda36dc 74 : m_expr1(rhs.m_expr1), m_expr2(rhs.m_expr2), m_expr3(rhs.m_expr3)
madcowswe 15:9c5aaeda36dc 75 { }
madcowswe 15:9c5aaeda36dc 76 #endif
madcowswe 15:9c5aaeda36dc 77
madcowswe 15:9c5aaeda36dc 78 public: //access
madcowswe 15:9c5aaeda36dc 79 /** index operator for vectors. */
madcowswe 15:9c5aaeda36dc 80 value_type operator()(std::size_t i) const {
madcowswe 15:9c5aaeda36dc 81 return m_expr1(i) ? m_expr2(i) : m_expr3(i);
madcowswe 15:9c5aaeda36dc 82 }
madcowswe 15:9c5aaeda36dc 83
madcowswe 15:9c5aaeda36dc 84 /** index operator for matrizes. */
madcowswe 15:9c5aaeda36dc 85 value_type operator()(std::size_t i, std::size_t j) const {
madcowswe 15:9c5aaeda36dc 86 return m_expr1(i, j) ? m_expr2(i, j) : m_expr3(i, j);
madcowswe 15:9c5aaeda36dc 87 }
madcowswe 15:9c5aaeda36dc 88
madcowswe 15:9c5aaeda36dc 89 public: // debugging Xpr parse tree
madcowswe 15:9c5aaeda36dc 90 void print_xpr(std::ostream& os, std::size_t l=0) const {
madcowswe 15:9c5aaeda36dc 91 os << IndentLevel(l++)
madcowswe 15:9c5aaeda36dc 92 << "XprEval[" << ops << ", ("
madcowswe 15:9c5aaeda36dc 93 << ops_expr1 << ", " << ops_expr2 << ", " << ops_expr3 << ")]<"
madcowswe 15:9c5aaeda36dc 94 << std::endl;
madcowswe 15:9c5aaeda36dc 95 m_expr1.print_xpr(os, l);
madcowswe 15:9c5aaeda36dc 96 m_expr2.print_xpr(os, l);
madcowswe 15:9c5aaeda36dc 97 m_expr3.print_xpr(os, l);
madcowswe 15:9c5aaeda36dc 98 os << IndentLevel(--l)
madcowswe 15:9c5aaeda36dc 99 << ">," << std::endl;
madcowswe 15:9c5aaeda36dc 100 }
madcowswe 15:9c5aaeda36dc 101
madcowswe 15:9c5aaeda36dc 102 private:
madcowswe 15:9c5aaeda36dc 103 const expr1_type m_expr1;
madcowswe 15:9c5aaeda36dc 104 const expr2_type m_expr2;
madcowswe 15:9c5aaeda36dc 105 const expr3_type m_expr3;
madcowswe 15:9c5aaeda36dc 106 };
madcowswe 15:9c5aaeda36dc 107
madcowswe 15:9c5aaeda36dc 108
madcowswe 15:9c5aaeda36dc 109 } // namespace tvmet
madcowswe 15:9c5aaeda36dc 110
madcowswe 15:9c5aaeda36dc 111 #endif // TVMET_XPR_EVAL_H
madcowswe 15:9c5aaeda36dc 112
madcowswe 15:9c5aaeda36dc 113 // Local Variables:
madcowswe 15:9c5aaeda36dc 114 // mode:C++
madcowswe 15:9c5aaeda36dc 115 // tab-width:8
madcowswe 15:9c5aaeda36dc 116 // End: