00001 // Copyright (C) 2010-2011 Institut de Robotica i Informatica Industrial, CSIC-UPC. 00002 // Author 00003 // All rights reserved. 00004 // 00005 // This file is part of iri-ros-pkg 00006 // iri-ros-pkg is free software: you can redistribute it and/or modify 00007 // it under the terms of the GNU Lesser General Public License as published by 00008 // the Free Software Foundation, either version 3 of the License, or 00009 // at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public License 00017 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 // 00019 // IMPORTANT NOTE: This code has been generated through a script from the 00020 // iri_ros_scripts. Please do NOT delete any comments to guarantee the correctness 00021 // of the scripts. ROS topics can be easly add by using those scripts. Please 00022 // refer to the IRI wiki page for more information: 00023 // http://wikiri.upc.es/index.php/Robotics_Lab 00024 00025 #ifndef _poseslam_alg_h_ 00026 #define _poseslam_alg_h_ 00027 00028 #include <iri_poseslam/PoseslamConfig.h> 00029 #include "mutex.h" 00030 #include "poseSLAM.h" 00031 #include <geometry_msgs/PoseWithCovarianceStamped.h> 00032 #include <tf/transform_broadcaster.h> 00033 #include <tf/transform_datatypes.h> 00034 00035 //include poseslam_alg main library 00036 00042 class PoseslamAlgorithm 00043 { 00044 protected: 00045 00046 CMutex alg_mutex_; 00047 00048 00049 // private attributes and methods 00050 00051 public: 00058 typedef iri_poseslam::PoseslamConfig Config; 00059 00066 Config config_; 00067 00076 PoseslamAlgorithm(void); 00077 00083 void lock(void) { alg_mutex_.enter(); }; 00084 00090 void unlock(void) { alg_mutex_.exit(); }; 00091 00099 bool try_enter(void) { return alg_mutex_.try_enter(); }; 00100 00112 void config_update(Config& new_cfg, uint32_t level=0); 00113 00120 ~PoseslamAlgorithm(void); 00121 00122 // here define all poseslam_alg interface methods to retrieve and set 00123 // the driver parameters 00124 00137 void augmentation(const uint& step, const geometry_msgs::PoseWithCovarianceStamped& odom); 00138 00146 void create_candidates_list(const bool& realOdometryCov); 00147 00155 void redundant_evaluation(); 00156 00164 bool loop_closure_requeriments() const; 00165 00178 bool try_loop_closure(const geometry_msgs::PoseWithCovarianceStamped& odom); 00179 00189 void update_candidates_list(const bool LoopClosure, const bool& realOdometryCov); 00190 00198 bool any_candidate() const; 00199 00206 void select_best_candidate(); 00207 00215 uint get_candidate_step() const; 00216 00224 geometry_msgs::Pose get_candidate_d() const; 00225 00233 double get_candidate_ig() const; 00234 00242 bool is_redundant() const; 00243 00251 std::vector<VectorXd> get_trajectory() const; 00252 00260 std::vector<std::vector<double> > get_trajectory_covariance() const; 00261 00269 std::vector<uint> get_trajectory_steps() const; 00270 00278 std::vector<VectorXd> get_trajectory_no_loops() const; 00279 00287 std::vector<std::vector<double> > get_trajectory_covariance_no_loops() const; 00288 00296 VectorXd get_last_pose() const; 00297 00305 std::vector<double> get_last_covariance() const; 00306 00314 uint get_last_step() const; 00315 00323 VectorXd get_last_pose_no_loops() const; 00324 00332 std::vector<double> get_last_covariance_no_loops() const; 00333 00341 uint get_nStates() const; 00342 00351 void print_matrix_in_file(const MatrixXd& M, std::fstream& file) const; 00352 00361 void print_vector_in_file(const std::vector<double>& v, std::fstream& file) const; 00362 00371 void print_vector_in_file(const std::vector<uint>& v, std::fstream& file) const; 00372 00380 void print_time_file(std::fstream& file) const; 00381 00382 //Create object 00383 CPoseSLAM* pose_SLAM_; 00384 CPoseSLAM* pose_SLAM_noLoops_; 00385 bool inicialitzat_; 00386 std::vector<Eigen::MatrixXd> Q_aug_; 00387 std::vector<Eigen::MatrixXd> Q_loop_; 00388 std::vector<Eigen::VectorXd> d_aug_; 00389 std::vector<Eigen::VectorXd> d_loop_; 00390 std::vector<bool> success_loop_; 00391 Eigen::MatrixXd Q_odom_; 00392 std::vector<double> timePub; 00393 std::vector<double> timeSensOpen; 00394 std::vector<double> timeSensClose; 00395 double tPub, tSens; 00396 }; 00397 00398 #endif