| 85 | } |
| 86 | |
| 87 | int SR::open(int auto_exposure, int integration_time, int modulation_freq, int amp_threshold, std::string ðer_addr) |
| 88 | { |
| 89 | // ---[ Open the camera ]--- |
| 90 | int res = 0; |
| 91 | if(ether_addr != "") |
| 92 | { |
| 93 | // ---[ set callback function ] --- |
| 94 | SR_SetCallback((SR_FuncCB *)SR_ROS_FuncCB); |
| 95 | res = SR_OpenETH (&srCam_, ether_addr.c_str()); |
| 96 | } |
| 97 | else |
| 98 | res = SR_OpenUSB (&srCam_, 0); //returns the device ID used in |
| 99 | |
| 100 | if (res <= 0) |
| 101 | { |
| 102 | SafeCleanup(); |
| 103 | SR_EXCEPT(sr::Exception, "Failed to open device!"); |
| 104 | return (-1); |
| 105 | } |
| 106 | |
| 107 | device_id_ = getDeviceString (); |
| 108 | lib_version_ = getLibraryVersion (); |
| 109 | // ---[ Get the number of rows, cols, ... ]--- |
| 110 | int rows_ = SR_GetRows (srCam_); |
| 111 | int cols_ = SR_GetCols (srCam_); |
| 112 | |
| 113 | // ---[ Set the acquisition mode ]--- |
| 114 | SR_SetMode (srCam_, MODE); |
| 115 | |
| 116 | int inr_ = SR_GetImageList (srCam_, &imgEntryArray_); |
| 117 | |
| 118 | ROS_INFO ("[SwissRanger device::open] Number of images available: %d", inr_); |
| 119 | |
| 120 | if ( (cols_ != SR_COLS) || (rows_ != SR_ROWS) || (inr_ < SR_IMAGES) || (imgEntryArray_ == 0) ) |
| 121 | { |
| 122 | SafeCleanup(); |
| 123 | SR_EXCEPT_ARGS(sr::Exception, |
| 124 | "Invalid data images: %d %dx%d images received from camera!\n Expected %d %dx%d images.", |
| 125 | inr_, cols_, rows_, SR_IMAGES, SR_COLS, SR_ROWS); |
| 126 | return (-1); |
| 127 | } |
| 128 | |
| 129 | if (auto_exposure >= 0) |
| 130 | setAutoExposure(auto_exposure); |
| 131 | |
| 132 | if (integration_time >=0 && integration_time != getIntegrationTime()) |
| 133 | setIntegrationTime(integration_time); |
| 134 | |
| 135 | if (modulation_freq >=0 && modulation_freq != getModulationFrequency()) |
| 136 | setModulationFrequency(modulation_freq); |
| 137 | |
| 138 | if (amp_threshold >=0 && amp_threshold != getAmplitudeThreshold()) |
| 139 | setAmplitudeThreshold(amp_threshold); |
| 140 | |
| 141 | // Points array |
| 142 | size_t buffer_size = rows_ * cols_ * 3 * sizeof (float); |
| 143 | buffer_ = (float*)malloc (buffer_size); |
| 144 | memset (buffer_, 0xaf, buffer_size); |
no outgoing calls
no test coverage detected