00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2010 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 #ifndef CSwissRanger3DCamera_H 00029 #define CSwissRanger3DCamera_H 00030 00031 #include <mrpt/hwdrivers/CGenericSensor.h> 00032 #include <mrpt/slam/CObservationImage.h> 00033 #include <mrpt/slam/CObservation3DRangeScan.h> 00034 00035 #include <mrpt/gui/CDisplayWindow.h> 00036 00037 #include <mrpt/hwdrivers/link_pragmas.h> 00038 00039 namespace mrpt 00040 { 00041 namespace hwdrivers 00042 { 00043 /** A class for grabing "range images" from a MESA imaging SwissRanger 3D cameras (SR-2, SR-3000, SR-4k). 00044 * NOTES: 00045 * - This class requires a vendor specific driver installed in the system in order to build MRPT with support for this sensor. 00046 * 00047 * As with any other CGenericSensor class, the normal sequence of methods to be called is: 00048 * - loadConfig() - Or calls to the individual setXXX() to configure the camera parameters. 00049 * - initialize() - to init the comms with the camera 00050 * - call getNextObservation() for getting the frames. 00051 * 00052 * \code 00053 * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS: 00054 * ------------------------------------------------------- 00055 * [supplied_section_name] 00056 * sensorLabel = CAM3D // A text description 00057 * preview_window = true // Show a window with a preview of the grabbed data in real-time 00058 * 00059 * open_USB = true // false means ethernet (default: true) 00060 * USB_serial = 0x4000002f // only for open_USB=true. If not set, the first camera will be open. Serial is the last part of S/N (e.g. for the camera SN: 00-00-40-00-00-2F). 00061 * IP_address = 192.168.2.14 // only for open_USB=false. The IP of the camera. 00062 * 00063 * // Options for the data to save in each CObservation3DRangeScan 00064 * save_3d = true // Save the 3D point cloud (default: true) 00065 * save_range_img = true // Save the 2D range image (default: true) 00066 * save_intensity_img = true // Save the 2D intensity image (default: true) 00067 * save_confidence = true // Save the estimated confidence 2D image (default: false) 00068 * 00069 * enable_img_hist_equal = false // Enable intensity image histogram equalization (default: false) 00070 * enable_median_filter = true // Enable median filter in range data (default: true) 00071 * enable_mediancross_filter = false // Enable median cross-filter (default: false) 00072 * enable_conv_gray = false // Enable intensity image scale with range (default: false) 00073 * enable_denoise_anf = true // Enable this noise filter (default: true) 00074 * 00075 * pose_x=0.21 // Camera position in the robot (meters) 00076 * pose_y=0 00077 * pose_z=0.34 00078 * pose_yaw=0 // Angles in degrees 00079 * pose_pitch=0 00080 * pose_roll=0 00081 * 00082 * \endcode 00083 */ 00084 class HWDRIVERS_IMPEXP CSwissRanger3DCamera : public mrpt::hwdrivers::CGenericSensor 00085 { 00086 DEFINE_GENERIC_SENSOR(CSwissRanger3DCamera) 00087 00088 public: 00089 CSwissRanger3DCamera(); //!< Default ctor 00090 ~CSwissRanger3DCamera(); //!< Default ctor 00091 00092 /** Initializes the 3D camera - should be invoked after calling loadConfig() 00093 * \exception This method must throw an exception with a descriptive message if some critical error is found. 00094 */ 00095 virtual void initialize(); 00096 00097 /** To be called at a high rate (>XX Hz), this method populates the internal buffer of received observations. 00098 * This method is mainly intended for usage within rawlog-grabber or similar programs. 00099 * For an alternative, see getNextObservation() 00100 * \exception This method must throw an exception with a descriptive message if some critical error is found. 00101 * \sa getNextObservation 00102 */ 00103 virtual void doProcess(); 00104 00105 /** The main data retrieving function, to be called after calling loadConfig() and initialize(). 00106 * \param out_obs The output retrieved observation (only if there_is_obs=true). 00107 * \param there_is_obs If set to false, there was no new observation. 00108 * \param hardware_error True on hardware/comms error. 00109 * 00110 * \sa doProcess 00111 */ 00112 void getNextObservation( mrpt::slam::CObservation3DRangeScan &out_obs, bool &there_is_obs, bool &hardware_error ); 00113 00114 00115 bool open(); //!< return false on error - Called automatically from initialize(), no need normally for the user to call this. 00116 void close(); 00117 00118 bool isOpen() const; //!< whether the camera is open and comms work ok. To be called after initialize() 00119 00120 /** Get the row count in the camera images, loaded automatically upon camera open(). */ 00121 size_t getRowCount() const { return m_rows; } 00122 /** Get the col count in the camera images, loaded automatically upon camera open(). */ 00123 size_t getColCount() const { return m_cols; } 00124 00125 /** Get the camera serial number, loaded automatically upon camera open(). */ 00126 unsigned int getCameraSerialNumber() const { return m_cam_serial_num; } 00127 00128 /** Returns the maximum camera range, as deduced from its operating frequency. */ 00129 double getMaxRange() const { return m_maxRange; } 00130 00131 00132 /** @name Capture configuration methods (apart from loadConfig) 00133 @{ */ 00134 00135 /** true: open from USB, false: open from ethernet. */ 00136 inline void setOpenFromUSB(bool USB) { m_open_from_usb = USB; } 00137 inline bool getOpenFromUSBMode() const { return m_open_from_usb; } 00138 00139 inline void setSave3D(bool save) { m_save_3d = save; } 00140 inline void setSaveRangeImage(bool save) { m_save_range_img = save; } 00141 inline void setSaveIntensityImage(bool save) { m_save_intensity_img = save; } 00142 inline void setSaveConfidenceImage(bool save) { m_save_confidence = save; } 00143 00144 inline void enableImageHistEqualization(bool enable) { m_enable_img_hist_equal = enable; } 00145 inline bool isEnabledImageHistEqualization() const { return m_enable_img_hist_equal; } 00146 00147 inline void enableMedianFilter(bool enable) { m_enable_median_filter = enable; internal_resendParamsToCamera(); } 00148 inline bool isEnabledMedianFilter() const { return m_enable_median_filter; } 00149 00150 inline void enableMedianCrossFilter(bool enable) { m_enable_mediancross_filter = enable; internal_resendParamsToCamera(); } 00151 inline bool isEnabledMedianCrossFilter() const { return m_enable_mediancross_filter; } 00152 00153 inline void enableConvGray(bool enable) { m_enable_conv_gray = enable; internal_resendParamsToCamera(); } 00154 inline bool isEnabledConvGray() const { return m_enable_conv_gray; } 00155 00156 inline void enableDenoiseANF(bool enable) { m_enable_denoise_anf = enable; internal_resendParamsToCamera(); } 00157 inline bool isEnabledDenoiseANF() const { return m_enable_denoise_anf; } 00158 00159 inline void enablePreviewWindow(bool enable=true) { m_preview_window = enable; } 00160 inline bool isEnabledPreviewWindow() const { return m_preview_window; } 00161 00162 /** @} */ 00163 00164 00165 // List of small functions to be implemented differently in Win/Lin. 00166 00167 /** Get the version of the MESA library. 00168 * \return false on error 00169 */ 00170 bool getMesaLibVersion(std::string &out_version) const; 00171 00172 00173 protected: 00174 /** Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes) 00175 * \exception This method must throw an exception with a descriptive message if some critical parameter is missing or has an invalid value. 00176 */ 00177 virtual void loadConfig_sensorSpecific( 00178 const mrpt::utils::CConfigFileBase &configSource, 00179 const std::string §ion ); 00180 00181 void internal_resendParamsToCamera() const; 00182 00183 mrpt::poses::CPose3D m_sensorPoseOnRobot; 00184 00185 bool m_save_3d; //!< Save the 3D point cloud (default: true) 00186 bool m_save_range_img; //!< Save the 2D range image (default: true) 00187 bool m_save_intensity_img; //!< Save the 2D intensity image (default: true) 00188 bool m_save_confidence; //!< Save the estimated confidence 2D image (default: false) 00189 00190 bool m_enable_img_hist_equal; 00191 bool m_enable_median_filter; 00192 bool m_enable_mediancross_filter; 00193 bool m_enable_conv_gray; 00194 bool m_enable_denoise_anf; 00195 00196 00197 bool m_open_from_usb; //!< true: USB, false: ETH 00198 size_t m_usb_serial; 00199 std::string m_ip_address; 00200 00201 size_t m_rows, m_cols; //!< Size of camera images, set on open() 00202 unsigned int m_cam_serial_num; //!< Serial number of the camera, set on open() 00203 double m_maxRange; //!< Max range, as deducted from the camera frequency. 00204 00205 bool m_preview_window; //!< Show preview window while grabbing 00206 mrpt::gui::CDisplayWindowPtr m_win2d; 00207 00208 std::string m_sensorLabel; 00209 00210 void *m_cam; //!< opaque handler to SRCAM. NULL means it's not open yet. 00211 00212 private: 00213 00214 }; // End of class 00215 00216 } // End of NS 00217 } // End of NS 00218 00219 00220 #endif
| Page generated by Doxygen 1.6.1 for MRPT 0.9.0 SVN: at Mon Jun 7 06:47:58 UTC 2010 |
