iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tests/test-GaussianPDF.C
/*! @file
@author Unknown
@copyright GNU Public License (GPL v3)
@section License
@verbatim
// ////////////////////////////////////////////////////////////////////////
// The iLab Neuromorphic Robotics Toolkit (NRT) //
// Copyright 2010-2012 by the University of Southern California (USC) //
// and the iLab at USC. //
// //
// iLab - University of Southern California //
// Hedco Neurociences Building, Room HNB-10 //
// Los Angeles, Ca 90089-2520 - USA //
// //
// See http://ilab.usc.edu for information about this project. //
// ////////////////////////////////////////////////////////////////////////
// This file is part of The iLab Neuromorphic Robotics Toolkit. //
// //
// The iLab Neuromorphic Robotics Toolkit is free software: you can //
// redistribute it and/or modify it under the terms of the GNU General //
// Public License as published by the Free Software Foundation, either //
// version 3 of the License, or (at your option) any later version. //
// //
// The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
// that it will be useful, but WITHOUT ANY WARRANTY; without even the //
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
// PURPOSE. See the GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with The iLab Neuromorphic Robotics Toolkit. If not, see //
// <http://www.gnu.org/licenses/>. //
// ////////////////////////////////////////////////////////////////////////
@endverbatim */
NRT_CREATE_STATE_FIELD_GROUP(Position2D,(x)(y));
NRT_CREATE_STATE_FIELD_GROUP(Velocity2D,(x)(y));
NRT_CREATE_STATE_FIELD_GROUP(Acceleration2D,(x)(y));
int main()
{
// Write to the mean elements
vehicle.mean<Position2D::x>() = 1;
vehicle.mean<Position2D::y>() = 2;
vehicle.mean<Velocity2D>() = Eigen::Vector2d(3, 4);
vehicle.mean<Velocity2D>() << 3, 4;
// Read from the mean elements
double pos_x_mean = vehicle.mean<Position2D::x>();
double pos_y_mean = vehicle.mean<Position2D::y>();
Eigen::Vector2d vel_mean = vehicle.mean<Velocity2D>();
std::cout << "Mean Position x: " << pos_x_mean << std::endl;
std::cout << "Mean Position y: " << pos_y_mean << std::endl;
std::cout << "Mean Velocity: " << std::endl << vel_mean << std::endl;
// Grab the entire mean vector
Eigen::Vector4d mean = vehicle.mean<>();
std::cout << "Mean: " << std::endl << mean << std::endl;
// Write to some covariance elements
vehicle.covariance<Position2D::x, Position2D::y>() = 1;
vehicle.covariance<Position2D::x>() = 2;
vehicle.covariance<Velocity2D>() << 3, 4,
4, 6;
// Read from some covariance elements
double pos_xy_cov = vehicle.covariance<Position2D::x, Position2D::y>();
double pos_xx_cov = vehicle.covariance<Position2D::x>();
Eigen::Matrix2d vel_cov = vehicle.covariance<Velocity2D>();
std::cout << "Covariance Position xy: " << pos_xy_cov << std::endl;
std::cout << "Covariance Position xx: " << pos_xx_cov << std::endl;
std::cout << "Covariance Velocity: " << std::endl << vel_cov << std::endl;
vehicle.covariance<Position2D::x, Velocity2D::y>() = 3;
Eigen::Matrix2d posVelCovariance = vehicle.covariance<Position2D, Velocity2D>();
std::cout << "---" << std::endl;
std::cout << posVelCovariance << std::endl;
std::cout << "---" << std::endl;
std::cout << vehicle.covariance<>() << std::endl;
// The following will cause nicely-worded compile time errors
// vehicle.mean<Acceleration2D>();
// vehicle.mean<Acceleration2D::x>();
return 0;
}