calibration_job_definition.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (Apache License)
00003  *
00004  * Copyright (c) 2014, Southwest Research Institute
00005  *
00006  * Licensed under the Apache License, Version 2.0 (the "License");
00007  * you may not use this file except in compliance with the License.
00008  * You may obtain a copy of the License at
00009  *
00010  *   http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  */
00018 
00019 #ifndef CALIBRATION_JOB_DEFINITION_H_
00020 #define CALIBRATION_JOB_DEFINITION_H_
00021 
00022 
00023 #include <industrial_extrinsic_cal/basic_types.h>
00024 #include <industrial_extrinsic_cal/camera_observer.hpp>
00025 #include <industrial_extrinsic_cal/camera_definition.h>
00026 #include <industrial_extrinsic_cal/observation_scene.h>
00027 #include <industrial_extrinsic_cal/observation_data_point.h>
00028 #include <industrial_extrinsic_cal/ceres_blocks.h>
00029 #include <industrial_extrinsic_cal/ros_camera_observer.h>
00030 #include <industrial_extrinsic_cal/ceres_costs_utils.hpp>
00031 #include <boost/shared_ptr.hpp>
00032 #include <boost/foreach.hpp>
00033 #include "ceres/ceres.h"
00034 #include "ceres/rotation.h"
00035 #include <ros/console.h>
00036 #include <yaml-cpp/yaml.h>
00037 #include <fstream>
00038 #include <iostream>
00039 
00040 namespace industrial_extrinsic_cal
00041 {
00042 
00044 class CalibrationJob
00045 {
00046 public:
00048   CalibrationJob(std::string camera_fn, std::string target_fn, std::string caljob_fn) :
00049       camera_def_file_name_(camera_fn), target_def_file_name_(target_fn), caljob_def_file_name_(caljob_fn)
00050   {
00051   }
00052   ;
00053 
00055   ~CalibrationJob()
00056   {
00057   }
00058   ;
00059 
00063   bool load();
00064 
00068   bool store();
00069 
00073   bool run();
00074 
00078   bool clearJobCameraObservers();
00079 
00083   bool clearJobTargets();
00084 
00088   bool clearObservationData();
00089 
00094   const std::vector<P_BLOCK> getExtrinsics() const
00095   {
00096     return extrinsics_;
00097   }
00098 
00103   const std::vector<P_BLOCK> getOriginalExtrinsics() const
00104   {
00105     return original_extrinsics_;
00106   }
00107 
00112   const std::vector<P_BLOCK> getTargetPose() const
00113   {
00114     return target_pose_;
00115   }
00116 
00117   const std::vector<std::string>& getCameraIntermediateFrame() const
00118   {
00119     return camera_intermediate_frames_;
00120   }
00121 
00122   const std::vector<std::string>& getCameraOpticalFrame() const
00123   {
00124     return camera_optical_frames_;
00125   }
00126 
00127   const std::string& getReferenceFrame() const
00128   {
00129     return reference_frame_;
00130   }
00131 
00132   const std::vector<std::string>& getTargetFrames() const
00133   {
00134     return target_frames_;
00135   }
00136 
00137   //    ::std::ostream& operator<<(::std::ostream& os, const CalibrationJob& C){ return os<< "TODO";}
00138 protected:
00143   bool loadTarget();
00144 
00149   bool loadCamera();
00150 
00155   bool loadCalJob();
00156 
00160   bool runObservations();
00161 
00165   bool runOptimization();
00166 
00171   bool addCameraObserver(Camera camera_to_add);
00172 
00177   bool addTarget(Target target_to_add);
00178 
00182   bool selectScene(int scene_id);
00183 
00189   bool addObservationToCurrentScene(boost::shared_ptr<ROSCameraObserver> camera_observer,
00190                                     boost::shared_ptr<Target> target);
00191 
00195   bool clearCurrentScene();
00196 
00201   bool appendNewScene(Trigger trig);
00202 
00203 private:
00204   std::vector<ObservationDataPointList> observation_data_point_list_;
00205   std::vector<ObservationScene> scene_list_; 
00206   std::string camera_def_file_name_; 
00207   std::string target_def_file_name_; 
00208   std::string caljob_def_file_name_; 
00209   std::string reference_frame_; 
00210   std::vector<std::string> target_frames_; 
00211   std::vector<std::string> camera_optical_frames_; 
00212   std::vector<std::string> camera_intermediate_frames_; 
00213   int current_scene_; 
00214   std::vector<ROSCameraObserver> camera_observers_; 
00215   std::vector<Target> defined_target_set_; 
00216   CeresBlocks ceres_blocks_; 
00217   ceres::Problem problem_; 
00218   std::vector<P_BLOCK> extrinsics_; 
00219   std::vector<P_BLOCK> original_extrinsics_; 
00220   std::vector<P_BLOCK> target_pose_; 
00222 };//end class
00223 
00224 }//end namespace industrial_extrinsic_cal
00225 
00226 #endif /* CALIBRATION_JOB_DEFINITION_H_ */


industrial_extrinsic_cal
Author(s): Chris Lewis
autogenerated on Wed Aug 26 2015 12:00:27